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
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:
/
, e.g. /t[arget]:foo /p[roperty]:var=value
/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.
/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.