通过命令行构建和发布C#.NET Web App [英] Build and publish C# .NET Web App via command line
问题描述
我需要能够一般性地单独构建和发布C#ASP.NET Web应用程序.理想情况下,我想使用MSBuild来构建应用程序,如果成功,我想简单地发布站点,最好仅使用文件副本发布该站点.
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.
当前,我能够使用MSBuild轻松构建Web应用程序,但是正是引起发布的混乱.构建后,二进制文件位于bin文件夹中,但是我不确定要复制哪些文件.模仿VS的发布功能进行操作并保持所有通用属性的好方法是什么?
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?
推荐答案
您可以使用命令行调用Visual Studio Web发布管道,请查看本教程,它逐步向您展示如何做到这一点:
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:
您可以按名称或.pubxml文件的完整路径指定发布配置文件,如以下示例所示:
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发布方法
命令行发布支持三种发布方法:
Web publish methods supported for command-line publishing
Three publish methods are supported for command line publishing:
-
MSDeploy-使用Web Deploy发布.
MSDeploy - Publish by using Web Deploy.
软件包-通过创建Web部署软件包进行发布.您必须将软件包与创建它的MSBuild命令分开安装.
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
这篇关于通过命令行构建和发布C#.NET Web App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!