Build and publish C# .NET Web App via command line

喜欢而已 提交于 2021-02-04 10:54:21

问题


I need to be able to generically and separately build and publish C# ASP.NET Web Applications. Ideally, I would like to use MSBuild to build the application, and if that succeeds, I would like to simply publish the site preferably solely with file copy.

Currently, I am able to build web application quite easily with MSBuild, but it is the publishing that is causing confusion. After the build, the binaries sit in the bin folder, but I am not sure what files to copy. What would be a good way to mimic the operations that VS's publish feature does, and still keeping everything generic?


回答1:


You can invoke the Visual Studio web publish pipeline using the command line, check out this tutorial it shows you step by step how to do it:

Specifying the publish profile

You can specify the publish profile by name or by the full path to the .pubxml file, as shown in the following example:

msbuild C:\ContosoUniversity\ContosoUniversity.sln /p:DeployOnBuild=true /p:PublishProfile=C:\ContosoUniversity\ContosoUniversity\Properties\PublishProfiles\Test.pubxml

Web publish methods supported for command-line publishing

Three publish methods are supported for command line publishing:

  • MSDeploy - Publish by using Web Deploy.

  • Package - Publish by creating a Web Deploy Package. You have to install the package separately from the MSBuild command that creates it.

  • FileSystem - Publish by copying files to a specified folder.

http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/command-line-deployment



来源:https://stackoverflow.com/questions/24063305/build-and-publish-c-sharp-net-web-app-via-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!