Question

For VS2010 and before I was utilizing Web Deployment Projects (WDP) to help package my website for production deployment. I had a MSBuild script that compiled the solution in release mode. An output of that was production ready website files compiled and cleaned by the WDP.

I see for 2012 WDP have been removed, and a new tab has been created in the properties for the web application. The options are the same, but now the invocation of this is done via the Publish option (before you just compiled in release mode).

So the question is this. From an MSBuild script, how do I invoke a Publish operation? I found some old posts that...

msbuild /target:publish

would do the trick. But that doesn't seem to work in 2012.

Also, I tried in my msbuild task...

<MSBuild Properties="Configuration=Publish;" 
         StopOnFirstFailure="true" 
         Projects="$(BuildDirectory)\MySolution.sln"></MSBuild>

...but msbuild just reported "unknown configuration".

How can I have msbuild run the publish option from the command line?

Was it helpful?

Solution 2

I wasn't able to get the publish to run, but looking at the output from Visual Studio I think I have found an alternate solution. Turns out the obj\Release\AspnetCompileMerge folder has a deployable and clean version of the project. It contains byte identical files to the final output folder.

I did have to change my msbuild script to include the DeployOnBuild option...

<MSBuild Properties="Configuration=Release;DeployOnBuild=True;" 
         StopOnFirstFailure="true" 
         Projects="$(BuildDirectory)\BigWave.ALL.sln"></MSBuild>

OTHER TIPS

It appears that there are now some other options for publishing from the command-line. Specifically something along the lines of the following seems possible now with some RC updates to Visual Studio 2012.

msbuild mywap.csproj /p:DeployOnBuild=true;PublishProfile=MyProfileName

For more details check out this post by Scott Hanselman and check out the section on Publishing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top