问题描述
我知道什么时候点击“重建解决方案”。就像下面这样。
[msbuild C:\Users\Micheal\source\repos\Calculator\Calculator.sln -t:publish]
但我不知道确切的发布命令是什么。
我猜是 [msbuild C:\Users\dkssu\source\repos\Calculator\Calculator.sln -t:publish] 但这是错误的。 它刚刚建成,并没有进一步发展。
这是我的问题。 当我在 Visual Studio 中单击某些内容时如何拦截命令 (2017/2019)
解决方法
实际上,命令是不同的,您应该注意 -t:publish
仅适用于 windows 应用程序项目的发布。
对于 asp net web 项目,您应该使用 PublishProfile
文件,它是一个发布指南文件。
使用这个:
msbuild xxx\xxx.sln /p:DeployOnBuild=true /p:PublishProfile=xxx\xxx\PublishProfiles\FolderProfile.pubxml
虽然 -t:publish
可以在asp net web项目上成功运行,但实际上并没有起到任何作用。毕竟,该命令是针对 windows 应用发布的。
对于 windows 应用项目,它实际上发布了项目,只是没有显示在默认的 MSBuild 日志中。
您应该另外使用 -v:detailed
命令查看详细日志。
msbuild xxx\xxx.sln -t:publish -v:detailed
并且当你完成这个命令后,你可以在构建输出文件夹(bin\xxx
)下查看,它确实在那里。