How to override a configuration property?

I am trying to run both release and Debug on .Net v4.0, where I have the MSBuild project file, not the solution file. I want to use the same build project file, but just override the Configuration property, switching between "Debug" and "Release".

When I do the following

c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj
/target:rebuild "/property:Configuration=Debug" /verbosity:Diagnostic

I get the following error

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=''.

I see that the error is occurring in _CheckForInvalidConfigurationAndPlatform.

If I pass the OutputPath property, it will work

c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj
/target:rebuild "/property:Configuration=Debug" "/property:OutputPath=."

Is this a known bug? When I need to override the Configuration property, I will have to force override the OutputPath property, even if I do not want it.

Thanks in advance.

+5
source share
3 answers

OutputPath , . , OutputPath , .

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

Platform :

c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj /target:rebuild "/property:Configuration=Debug;Platform=AnyCPU" /verbosity:Diagnostic
+4

, OutputPath :

c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj /target:rebuild "/property:Configuration=Debug;OutputPath=C:\MyOutputPath" /verbosity:Diagnostic
+2

. , OutputPath . " =" PropertyGroup, OutputPath .

<PropertyGroup>
  <OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>

<PropertyGroup>
    <OutputPath>$(DefaultOutputDirectory)</OutputPath>
</PropertyGroup>
+1

All Articles