Web Deploy to Server with MSBuild

自作多情 提交于 2019-12-21 17:29:35

问题


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)?


回答1:


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.



来源:https://stackoverflow.com/questions/14230272/web-deploy-to-server-with-msbuild

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