I use the following command line to publish an
ASP.NET website :
msbuild.exe "C:\somerepository/solution.sln" /p:Configuration="Production"
It works. However I have to specify both publish profile and configuration.
If configuration parameter is not set, it does not work (after publish web.config is not transformed with the right config file).
When you use the interface (by right clicking on the project and choose publish) it only ask you to select a profile (and based on that profile the configuration is read, there is no need to specify it) :
Could the same mechanism be used with msbuild command line ?
I also tried to specify the project (instead of solution) but it does not work :
msbuild.exe "C:\somerepository/project.csproj" /p:Configuration="Production"
You can edit your
.csproj and add a new conditional
Configuration property. Unfortunately you can't overwrite it from within the
.pubxml without shuffling
Import around as it is too far down to take effect.
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(PublishProfile)' != '' ">$(PublishProfile)</Configuration>