Visual Studio Profile Publish Publishes Incorrect Build Configuration

I am trying to automate the deployment of a Web Api 2 project using Visual Studio 2013. I published a publishing profile called Test, shown below

<?xml version="1.0" encoding="utf-8"?> <!-- This file is used by the publish/package process of your Web project. You can customize the behavior of this process by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121. --> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <WebPublishMethod>FileSystem</WebPublishMethod> <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration> <LastUsedPlatform>x86</LastUsedPlatform> <SiteUrlToLaunchAfterPublish /> <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish> <ExcludeApp_Data>False</ExcludeApp_Data> <publishUrl>C:\DbServiceDeploy</publishUrl> <DeleteExistingFiles>True</DeleteExistingFiles> </PropertyGroup> </Project> 

Even though it has the line <LastUsedBuildConfiguration> Release </LastUsedBuildConfiguration> it looks like Visual Studio is publishing my debug build. I call msbuild

  "C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" C:\somefolder\Myproj.csproj /p: DeployOnBuild=true /p:PublishProfile=Test 
+5
source share
1 answer

This great blog post led me to search for an answer http://sedodream.com/2012/10/27/MSBuildHowToSetTheConfigurationProperty.aspx . I will describe if the link freezes: when the assembly starts, MsBuild evaluates the properties once and uses this value for the rest of the assembly. Since the Configuration property was enabled for Debug, MsBuild used this as a published configuration.

TL; DR;

Pass the configuration on the command line, add

/ r: Configuration = Release

to invoke the command line

+5
source

All Articles