当前位置: 动力学知识库 > 问答 > 编程问答 >

Is it possible publish an ASP.NET a website using msbuild and only specify the publish profile (configuration parameter is not set)

问题描述:

I use the following command line to publish an ASP.NET website :

msbuild.exe "C:\somerepository/solution.sln" /p:Configuration="Production"

/p:DeployOnBuild=true /p:PublishProfile="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"

/p:DeployOnBuild=true /p:PublishProfile="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>
分享给朋友:
您可能感兴趣的文章:
随机阅读: