Skip to content

Commit abe51ef

Browse files
committed
[build] Build additional $(TargetFramework) values.
Now that most projects are Short-Form projects (cedf4d0), we can use MSBuild multitargeting and the [`$(TargetFrameworks)`][0] MSBuild property to build for multiple target frameworks at once. This in turn will allow us to determine which apps can be built against the `.NETCoreApp,Version=v3.1` framework, which is our current "stepping stone" to eventual .NET 5 compatibility. Rename `Configuration.props` to `Directory.Build.props`, so that it doesn't need to be explicitly `<Import/>`ed everywhere. Update all projects so that `$(OutputPath)` is in turn a variable defined in `Directory.Build.props`: * `$(BuildToolOutputFullPath)`: Build-time utilities, e.g. files that belong in `bin/BuildDebug`. * `$(ToolOutputFullPath)`: "Normal" output, e.g. `bin/Debug`. * `$(TestOutputFullPath)`: Test-related artifacts, e.g. `bin/TestDebug`. * `$(UtilityOutputFullPath)`: "Normal" output that is shared with xamarin-android and needs an alternate installation location when built from xamarin-android. Of note is that when `$(TargetFramework)` starts with `netcoreapp`, the above properties are changed to have a `-$(TargetFramework)` suffix. Update a few tools projects so that they build for both `net472` and `netcoreapp3.1` frameworks, e.g. `tools/logcat-parse` now produces: * `bin/Debug-netcoreapp3.1/logcat-parse.deps.json` * `bin/Debug-netcoreapp3.1/logcat-parse.dll` * `bin/Debug-netcoreapp3.1/logcat-parse.pdb` * `bin/Debug-netcoreapp3.1/logcat-parse.runtimeconfig.dev.json` * `bin/Debug-netcoreapp3.1/logcat-parse.runtimeconfig.json` * `bin/Debug/logcat-parse.exe` * `bin/Debug/logcat-parse.exe.config` * `bin/Debug/logcat-parse.pdb` Some projects fail when building for `netcoreapp3.1`. These projects will be fixed separately. [0]: https://docs.microsoft.com/en-us/dotnet/standard/frameworks
1 parent cedf4d0 commit abe51ef

File tree

41 files changed

+83
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+83
-164
lines changed

Configuration.props renamed to Directory.Build.props

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,22 @@
1818
Project="$(_OutputPath)MonoInfo.props"
1919
Condition="Exists('$(_OutputPath)MonoInfo.props')"
2020
/>
21+
<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>
25+
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPathCoreApps)' != '' ">$(UtilityOutputFullPathCoreApps)</UtilityOutputFullPath>
26+
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPathCoreApps)' == '' ">$(ToolOutputFullPath)</UtilityOutputFullPath>
27+
</PropertyGroup>
28+
<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>
32+
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPath)' == '' ">$(ToolOutputFullPath)</UtilityOutputFullPath>
33+
</PropertyGroup>
2134
<PropertyGroup>
2235
<CecilRestoreConfiguration Condition=" '$(CecilRestoreConfiguration)' == '' ">$(Configuration)</CecilRestoreConfiguration>
2336
<CecilSourceDirectory Condition=" '$(CecilSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\cecil</CecilSourceDirectory>
24-
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPath)' == '' ">$(MSBuildThisFileDirectory)bin\$(_Configuration)\</UtilityOutputFullPath>
2537
<XamarinAndroidToolsDirectory Condition=" '$(XamarinAndroidToolsDirectory)' == '' ">$(MSBuildThisFileDirectory)external\xamarin-android-tools</XamarinAndroidToolsDirectory>
2638
</PropertyGroup>
2739
<PropertyGroup>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ MSbuild properties may be placed into the file `Configuration.Override.props`,
6565
which can be copied from
6666
[`Configuration.Override.props.in`](Configuration.Override.props.in).
6767
The `Configuration.Override.props` file is `<Import/>`ed by
68-
[`Configuration.props`](Configuration.props); there is no need to `<Import/>`
69-
it within other project files.
68+
[`Directory.Build.props`](Directory.Build.props); there is no need to
69+
`<Import/>` it within other project files.
7070

7171
Overridable MSBuild properties include:
7272

build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<ProductVersion>8.0.30703</ProductVersion>
1212
<SchemaVersion>2.0</SchemaVersion>
1313
</PropertyGroup>
14-
<Import Project="..\..\Configuration.props" />
1514
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1615
<DebugSymbols>True</DebugSymbols>
1716
<DebugType>Full</DebugType>

build-tools/jnienv-gen/jnienv-gen.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
<AssemblyName>jnienv-gen</AssemblyName>
1212
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
1313
</PropertyGroup>
14+
<Import Project="..\..\Directory.Build.props" />
1415
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' Or '$(Configuration)|$(Platform)' == 'Gendarme|AnyCPU' ">
1516
<DebugSymbols>true</DebugSymbols>
1617
<DebugType>full</DebugType>
1718
<Optimize>false</Optimize>
18-
<OutputPath>..\..\bin\BuildDebug</OutputPath>
19+
<OutputPath>$(BuildToolOutputFullPath)</OutputPath>
1920
<DefineConstants>DEBUG;</DefineConstants>
2021
<ErrorReport>prompt</ErrorReport>
2122
<WarningLevel>4</WarningLevel>
@@ -24,7 +25,7 @@
2425
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2526
<DebugType>full</DebugType>
2627
<Optimize>true</Optimize>
27-
<OutputPath>..\..\bin\BuildRelease</OutputPath>
28+
<OutputPath>$(BuildToolOutputFullPath)</OutputPath>
2829
<ErrorReport>prompt</ErrorReport>
2930
<WarningLevel>4</WarningLevel>
3031
<Externalconsole>true</Externalconsole>

build-tools/scripts/PrepareWindows.targets

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<_NuGetPath>$(_TopDir)\.nuget</_NuGetPath>
88
<_NuGet>$(_NuGetPath)\NuGet.exe</_NuGet>
99
</PropertyGroup>
10-
<Import Project="$(_TopDir)\Configuration.props" />
1110
<UsingTask AssemblyFile="$(_TopDir)\bin\Build$(Configuration)\Java.Interop.BootstrapTasks.dll" TaskName="Java.Interop.BootstrapTasks.JdkInfo" />
1211
<UsingTask AssemblyFile="$(_TopDir)\bin\Build$(Configuration)\Java.Interop.BootstrapTasks.dll" TaskName="Java.Interop.BootstrapTasks.DownloadUri" />
1312
<Target Name="Prepare">

samples/Hello/Hello.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
99
</PropertyGroup>
1010

11+
<PropertyGroup>
12+
<OutputPath>$(TestOutputFullPath)</OutputPath>
13+
</PropertyGroup>
14+
1115
<ItemGroup>
1216
<ProjectReference Include="..\..\src\Java.Interop\Java.Interop.csproj" />
1317
<ProjectReference Include="..\..\src\Java.Runtime.Environment\Java.Runtime.Environment.csproj" />

src/Java.Interop.Dynamic/Java.Interop.Dynamic.csproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212
<AssemblyVersion>0.1.0.0</AssemblyVersion>
1313
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1414
</PropertyGroup>
15-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16-
<OutputPath>..\..\bin\Debug</OutputPath>
17-
</PropertyGroup>
18-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
19-
<OutputPath>..\..\bin\Release</OutputPath>
15+
<PropertyGroup>
16+
<OutputPath>$(ToolOutputFullPath)</OutputPath>
2017
</PropertyGroup>
2118
<ItemGroup>
2219
<ProjectReference Include="..\Java.Interop\Java.Interop.csproj">

src/Java.Interop.Export/Java.Interop.Export.csproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@
1111
<AssemblyVersion>0.1.0.0</AssemblyVersion>
1212
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1313
</PropertyGroup>
14-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
15-
<OutputPath>..\..\bin\Debug</OutputPath>
16-
</PropertyGroup>
17-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
18-
<OutputPath>..\..\bin\Release</OutputPath>
14+
<PropertyGroup>
15+
<OutputPath>$(ToolOutputFullPath)</OutputPath>
1916
</PropertyGroup>
2017
<ItemGroup>
2118
<ProjectReference Include="..\Java.Interop\Java.Interop.csproj">

src/Java.Interop.GenericMarshaler/Java.Interop.GenericMarshaler.csproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212
<AssemblyVersion>0.1.0.0</AssemblyVersion>
1313
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1414
</PropertyGroup>
15-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16-
<OutputPath>..\..\bin\Debug</OutputPath>
17-
</PropertyGroup>
18-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
19-
<OutputPath>..\..\bin\Release</OutputPath>
15+
<PropertyGroup>
16+
<OutputPath>$(ToolOutputFullPath)</OutputPath>
2017
</PropertyGroup>
2118
<ItemGroup>
2219
<None Include="Java.Interop.GenericMarshaler\JniPeerInstanceMethodsExtensions.tt">

src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil.csproj

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@
55
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
66
</PropertyGroup>
77

8-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
9-
<OutputPath>..\..\bin\Debug</OutputPath>
10-
</PropertyGroup>
11-
12-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
13-
<OutputPath>..\..\bin\Release</OutputPath>
8+
<PropertyGroup>
9+
<OutputPath>$(ToolOutputFullPath)</OutputPath>
1410
</PropertyGroup>
1511

1612
<ItemGroup>

0 commit comments

Comments
 (0)