本文介绍了运行dotnet在asp.net核心中的发布后事件中发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要在构建后发布我的网站.是否有任何方法可以在asp,net core的发布后事件中运行dotnet publish命令?这是我的project.json文件:
I want to publish my web site after building.Is there any way to run dotnet publish command in post build event in asp,net core?This is my project.json file:
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Model": "1.0.0-*",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [
//"bower install"
],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ],
"postbuild": "[call $(ProjectDir)Publish.bat]"
}
}
推荐答案
在构建后事件中,将--no-build
参数添加到dotnet publish
中.默认情况下,dotnet publish将运行一个构建,该构建将触发构建后事件,然后将尝试再次发布,这将导致无限循环,似乎使该构建挂起.
Add the --no-build
parameter to dotnet publish
in your post-build event. By default, dotnet publish will run a build, which will trigger post-build events, which will then try to publish again, which will cause an infinite loop that appears to make the build hang.
这篇关于运行dotnet在asp.net核心中的发布后事件中发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!