I'm trying to automate deploying a Web Api 2 project with Visual Studio 2013. I've made a publish profile named "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 seems like Visual Studio is publishing my debug build. I'm calling msbuild like so
"C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" C:\somefolder\Myproj.csproj /p:
DeployOnBuild=true /p:PublishProfile=Test
This excellent blog post led me to find the answer http://sedodream.com/2012/10/27/MSBuildHowToSetTheConfigurationProperty.aspx . I'll summarize in case the link dies: when a build is kicked off MsBuild evaluates the properties once and uses that value for the remainder of the build. Since the Configuration property was resolving to Debug MsBuild was using that as the Configuration to publish.
TLDR;
Pass the configuration on the command line, add
/p:Configuration=Release
to the command line call
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With