使用MSBuild将Web部署到服务器 [英] Web Deploy to Server with MSBuild

查看:219
本文介绍了使用MSBuild将Web部署到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS 2012项目中设置了发布配置文件。当我右键单击VS中的项目时,选择发布并单击[发布]按钮,它会使用发布配置文件中提供的设置将项目发布到服务器。



<当我使用msbuild和命令行时,使用以下语法:

  msbuild.exe。\ mvc.csproj / p:PublishProfile = DevServer 
/ p:DeployOnBuild = True / p:Password = MyPassword / p:AllowUntrustedCertificate = true

然后它构建项目,并给我一条消息:


包mvc.zip已成功创建为以下位置的单个文件:file:/// c:/ code / mvcsite / obj / Debug / Package


然后提供有关如何部署程序包的信息。



如何从命令行部署?我的最终目标是通过TeamCity运行部署,现在正试图让我的命令行属性正确。但是,我现在可以从命令行做的最多的事情是创建部署包,但不能运行实际部署。我怎么能这两个(最好用一个声明,复制VS2012从我那里部署时发生的事情)?

解决方案

你正在建造.csproj你错过了一个重要的财产

  /p:VisualStudioVersion=11.0 

此属性是在MSBuild 4.5中引入的,以便于VS 2010和VS 2012之间的项目共享。在构建.csproj时,您需要指定此属性的值。构建解决方案文件时,可以从解决方案文件版本派生值。在我的博客上阅读更多内容 http://sedodream.com/2013/01/06/CommandLineWebProjectPublishing.aspx


I have a publish profile set up in a VS 2012 project. When I right click on the project in VS, select Publish and click on the [Publish] button, it publishes the project to the server using the settings provided in the Publish Profile.

When I use msbuild and the command line, with the following syntax:

msbuild.exe .\mvc.csproj /p:PublishProfile=DevServer 
/p:DeployOnBuild=True /p:Password=MyPassword /p:AllowUntrustedCertificate=true

Then it builds the project, and gives me a message:

Package "mvc.zip" is successfully created as a single file at the following location: file:///c:/code/mvcsite/obj/Debug/Package

And then provides info on how to deploy the package.

How can I deploy from the command line? My ultimate goal is to run the deployment through TeamCity, and am right now trying to get my command line properties correct. However, the most that I can do from the command line right now is to create the deployment package, but not to run the actual deployment. How can I do both (preferably with one statement, to duplicate what happens in VS2012 when I deploy from there)?

解决方案

Since you are building the .csproj you missed one important property

/p:VisualStudioVersion=11.0

This property was introduced in MSBuild 4.5 to facilitate project sharing between VS 2010 and VS 2012. A drawback; when building the .csproj you need to specify the value for this property. When building the solution file the value can be derived from the solution file version. Read more at my blog http://sedodream.com/2013/01/06/CommandLineWebProjectPublishing.aspx.

这篇关于使用MSBuild将Web部署到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆