我正在尝试使用Visual Studio 2013自动部署Web Api 2项目。我已经创建了一个名为“Test”的发布配置文件,如下所示
<?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>
即使它有行&lt; LastUsedBuildConfiguration&gt; Release&lt; / LastUsedBuildConfiguration&gt;似乎Visual Studio正在发布我的调试版本。我正在调用msbuild
"C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" C:\somefolder\Myproj.csproj /p:
DeployOnBuild=true /p:PublishProfile=Test
答案 0 :(得分:8)
这篇优秀的博客文章让我找到了答案http://sedodream.com/2012/10/27/MSBuildHowToSetTheConfigurationProperty.aspx。我将总结链接死亡的情况:当一个构建被启动时,MsBuild会对属性进行一次评估,并将该值用于构建的其余部分。由于Configuration属性正在解析为Debug,因此MsBuild使用它作为要发布的配置。
TLDR;
在命令行上传递配置,添加
/ P:配置=释放
到命令行调用