如何覆盖配置属性?

pmc*_*ath 5 msbuild-4.0

我试图在.Net v4.0上进行发布和调试构建,其中我有一个MSBuild项目文件而不是解决方案文件.我想使用相同的构建项目文件,但只是覆盖"Debug"和"Release"之间的Configuration属性切换.

当我执行如下

c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj
/target:rebuild "/property:Configuration=Debug" /verbosity:Diagnostic
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(483,9):
error : The OutputPath property is not set for project
'buildinv.proj'.  Please check to make sure that you have specified a
valid combination of Configuration and Platform for this project. 
Configuration='Debug'  Platform=''.
Run Code Online (Sandbox Code Playgroud)

我可以看到错误发生在_CheckForInvalidConfigurationAndPlatform.

如果我传递一个OutputPath属性,它将工作

c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj
/target:rebuild "/property:Configuration=Debug" "/property:OutputPath=."
Run Code Online (Sandbox Code Playgroud)

这是一个已知的错误 ?在我需要覆盖Configuration属性的地方,即使我不希望,我也会被迫覆盖OutputPath属性.

提前致谢.

Lud*_*dwo 4

在我的项目文件中,OutputPath 属性是在为每个配置和平台指定的属性组中定义的。如果您没有设置正确的平台,则不会设置 OutputPath 属性,并且您的构建将失败。

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  <OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)

将 Platform 属性添加到命令行中:

c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj /target:rebuild "/property:Configuration=Debug;Platform=AnyCPU" /verbosity:Diagnostic
Run Code Online (Sandbox Code Playgroud)