How to do the exact same functionality as the Publish inside visual studio from powershell

后端 未结 1 496
一个人的身影
一个人的身影 2020-12-28 17:18

I want to know how to publish from PowerShell the same way I can from Visual Studio.

When you launch Visual Studio with MVC project for example; then right-click on

相关标签:
1条回答
  • 2020-12-28 18:04

    The projectName.publish.xml files are only used via Visual Studio for the One-Click publishing. For MSBuild, you need to pass a bunch of parameters directly on the commandline (/p:Param1=value1;Param2=value2;...). For example:

    /p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:CreatePackageOnPublish=True /p:MSDeployPublishMethod=InProc /p:MSDeployServiceUrl=localhost /p:DeployIisAppPath="Default Web Site/NewOrleansJazz" /p:UserName=domain\user /p:Password=myPassword (source)

    Note that in the VS11 Preview (released at the BUILD conference), there is a new file replacing the projectName.publish.xml: MyPublishSettings.pubxml. This file is basically a combination of the publish.xml file and the projectName.wpp.targets rolled into one (yet also split for each profile instead of having them all saved into publish.xml, e.g. TestSettings.pubxml, ProductionSettings.pubxml), and can be used from the command line in a simpler fashion using msbuild MyProject.csproj /t:WebPublish /p:PublishProfile="myProfile"

    [edit:] a couple notes re: the info in your post:

    1. The error about only specifying a single project is probably due to specifying the target incorrectly. Other than the project name, all parameters passed to msbuild start with a /, e.g. /t[arget]:foo /p[roperty]:var=value
    2. The Publish target is actually not related to Web Publishing. IIRC, it's related to publishing a OneClick application. In VS2010, you should use /t:build /p:DeployOnBuild=true for Web projects to use the publishing tasks (as used above). New in VS11 is the /t:WebPublish which also takes a simpler set of parameters, namely the .pubxml file you wish to use.
      • additional note: when building a solution file, /t:WebPublish will fail as the target is not defined at the solution level. It can only be used directly on the project file for your Web project. You can still use /p:DeployOnBuild=true at the solution level as the parameter value is passed to each project being built, but will be ignored by any projects not consuming that value.
    0 讨论(0)
提交回复
热议问题