Skip to content

Commit 3091274

Browse files
authored
[build] Provide a default $(Configuration) value (#612)
When `Directory.Build.props` is imported by MSBuild, the `$(Configuration)` property will only be defined if it was excplitily provided on the command line. As such, when building the repo when using **make**(1), it builds: $ make prepare $ make all # works! After `make all`, if we attempt to manually build a single `.csproj`, it may fail: $ msbuild tests/Java.Interop-Tests/Java.Interop-Tests.csproj ... BuildInteropTestJar: "" -source 1.6 -target 1.6 -bootclasspath "" -d "obj/Debug/it-classes" -classpath … …: error MSB3073: The command """ -source 1.6 -target 1.6 …" exited with code 127. Building a single `.csproj` works if the `Configuration` property is explicitly provided: $ msbuild tests/Java.Interop-Tests/Java.Interop-Tests.csproj /p:Configuration=Debug # no error Update `Directory.Build.props` so that if no `$(Configuration)` is provided we default to the Debug configuration. This allows all the relevant `$(Configuration)`-dependent properties to have correct and consistent values, which allows projects to build as intended: $ msbuild tests/Java.Interop-Tests/Java.Interop-Tests.csproj # no errors
1 parent cf3e7c2 commit 3091274

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

Directory.Build.props

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<!-- Note: MUST be imported *after* $(Configuration) is set! -->
44
<PropertyGroup>
5-
<_Configuration Condition=" '$(Configuration)' != 'Gendarme' ">$(Configuration)</_Configuration>
6-
<_Configuration Condition=" '$(Configuration)' == 'Gendarme' ">Debug</_Configuration>
7-
<_OutputPath>$(MSBuildThisFileDirectory)bin\Build$(_Configuration)\</_OutputPath>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<_OutputPath>$(MSBuildThisFileDirectory)bin\Build$(Configuration)\</_OutputPath>
87
</PropertyGroup>
98
<Import
109
Project="$(MSBuildThisFileDirectory)Configuration.Override.props"
@@ -19,16 +18,16 @@
1918
Condition="Exists('$(_OutputPath)MonoInfo.props')"
2019
/>
2120
<PropertyGroup Condition=" '$(TargetFramework)' != '' And $(TargetFramework.StartsWith ('netcoreapp')) ">
22-
<BuildToolOutputFullPath>$(MSBuildThisFileDirectory)bin\Build$(_Configuration)-$(TargetFramework)\</BuildToolOutputFullPath>
23-
<ToolOutputFullPath>$(MSBuildThisFileDirectory)bin\$(_Configuration)-$(TargetFramework)\</ToolOutputFullPath>
24-
<TestOutputFullPath>$(MSBuildThisFileDirectory)bin\Test$(_Configuration)-$(TargetFramework)\</TestOutputFullPath>
21+
<BuildToolOutputFullPath>$(MSBuildThisFileDirectory)bin\Build$(Configuration)-$(TargetFramework)\</BuildToolOutputFullPath>
22+
<ToolOutputFullPath>$(MSBuildThisFileDirectory)bin\$(Configuration)-$(TargetFramework)\</ToolOutputFullPath>
23+
<TestOutputFullPath>$(MSBuildThisFileDirectory)bin\Test$(Configuration)-$(TargetFramework)\</TestOutputFullPath>
2524
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPathCoreApps)' != '' ">$(UtilityOutputFullPathCoreApps)</UtilityOutputFullPath>
2625
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPathCoreApps)' == '' ">$(ToolOutputFullPath)</UtilityOutputFullPath>
2726
</PropertyGroup>
2827
<PropertyGroup Condition=" '$(TargetFramework)' == '' Or !$(TargetFramework.StartsWith ('netcoreapp')) ">
29-
<BuildToolOutputFullPath>$(MSBuildThisFileDirectory)bin\Build$(_Configuration)\</BuildToolOutputFullPath>
30-
<ToolOutputFullPath>$(MSBuildThisFileDirectory)bin\$(_Configuration)\</ToolOutputFullPath>
31-
<TestOutputFullPath>$(MSBuildThisFileDirectory)bin\Test$(_Configuration)\</TestOutputFullPath>
28+
<BuildToolOutputFullPath>$(MSBuildThisFileDirectory)bin\Build$(Configuration)\</BuildToolOutputFullPath>
29+
<ToolOutputFullPath>$(MSBuildThisFileDirectory)bin\$(Configuration)\</ToolOutputFullPath>
30+
<TestOutputFullPath>$(MSBuildThisFileDirectory)bin\Test$(Configuration)\</TestOutputFullPath>
3231
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPath)' == '' ">$(ToolOutputFullPath)</UtilityOutputFullPath>
3332
</PropertyGroup>
3433
<PropertyGroup>

0 commit comments

Comments
 (0)