Skip to content

Commit c482ef4

Browse files
authored
[build] Update to net9.0 and netstandard2.0 (#251)
Introduces a `$(DotNetTargetFramework)` property to control the target framework version used for exe projects, and sets it to the latest stable .NET version (`net9.0`). Library and build task projects have been updated to only target `netstandard2.0`, which is compatible with both .NET Framework and .NET Core.
1 parent 0658bc6 commit c482ef4

File tree

7 files changed

+8
-27
lines changed

7 files changed

+8
-27
lines changed

Directory.Build.props

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
66
<!-- Disables the transitive restore of packages like Microsoft.AspNetCore.App.Ref, Microsoft.WindowsDesktop.App.Ref -->
77
<DisableTransitiveFrameworkReferenceDownloads>true</DisableTransitiveFrameworkReferenceDownloads>
8+
<DotNetTargetFrameworkVersion>9.0</DotNetTargetFrameworkVersion>
9+
<DotNetTargetFramework>net$(DotNetTargetFrameworkVersion)</DotNetTargetFramework>
810
</PropertyGroup>
911
<Import
1012
Project="$(MSBuildThisFileDirectory)Configuration.Override.props"
@@ -16,17 +18,6 @@
1618
/>
1719
<PropertyGroup>
1820
<BaseIntermediateOutputPath Condition=" '$(BaseIntermediateOutputPath)' == '' ">obj\</BaseIntermediateOutputPath>
19-
</PropertyGroup>
20-
<PropertyGroup Condition=" '$(TargetFramework)' != '' and '$(TargetFramework)' != 'net472' and '$(TargetFramework)' != 'netstandard2.0' ">
21-
<XATBuildingForNetCoreApp>True</XATBuildingForNetCoreApp>
22-
</PropertyGroup>
23-
<PropertyGroup Condition=" '$(XATBuildingForNetCoreApp)' == 'True' ">
24-
<IntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)-$(TargetFramework.ToLowerInvariant())</IntermediateOutputPath>
25-
<BuildToolOutputFullPath>$(MSBuildThisFileDirectory)bin\Build$(Configuration)\$(TargetFramework.ToLowerInvariant())\</BuildToolOutputFullPath>
26-
<ToolOutputFullPath>$(MSBuildThisFileDirectory)bin\$(Configuration)\$(TargetFramework.ToLowerInvariant())\</ToolOutputFullPath>
27-
<TestOutputFullPath>$(MSBuildThisFileDirectory)bin\Test$(Configuration)-$(TargetFramework.ToLowerInvariant())\</TestOutputFullPath>
28-
</PropertyGroup>
29-
<PropertyGroup Condition=" '$(XATBuildingForNetCoreApp)' != 'True' ">
3021
<IntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)</IntermediateOutputPath>
3122
<BuildToolOutputFullPath>$(MSBuildThisFileDirectory)bin\Build$(Configuration)\</BuildToolOutputFullPath>
3223
<ToolOutputFullPath>$(MSBuildThisFileDirectory)bin\$(Configuration)\</ToolOutputFullPath>

azure-pipelines.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
displayName: Run Tests
4747
inputs:
4848
command: test
49-
projects: bin/TestDebug-net*/**/*-Tests.dll
49+
projects: bin/TestDebug/**/*-Tests.dll
5050

5151
- powershell: |
5252
$hashOfLastVersionChange = & "git" "log" "--follow" "-1" "--pretty=%H" "nuget.version"

src/Microsoft.Android.Build.BaseTasks/Microsoft.Android.Build.BaseTasks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="MSBuildReferences.projitems" />
44

55
<PropertyGroup>
6-
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
6+
<TargetFramework>netstandard2.0</TargetFramework>
77
<RootNamespace>Microsoft.Android.Build.Tasks</RootNamespace>
88
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
99
<SignAssembly>true</SignAssembly>

src/Xamarin.Android.Tools.AndroidSdk/Xamarin.Android.Tools.AndroidSdk.csproj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
4+
<TargetFramework>netstandard2.0</TargetFramework>
55
<LangVersion>8.0</LangVersion>
66
<Nullable>enable</Nullable>
77
<DefineConstants>INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
@@ -17,10 +17,6 @@
1717
<AssemblyName>$(VendorPrefix)Xamarin.Android.Tools.AndroidSdk$(VendorSuffix)</AssemblyName>
1818
</PropertyGroup>
1919

20-
<ItemGroup>
21-
<Compile Condition=" '$(TargetFramework)' != 'netstandard2.0' " Remove="NullableAttributes.cs" />
22-
</ItemGroup>
23-
2420
<PropertyGroup>
2521
<OutputPath>$(ToolOutputFullPath)</OutputPath>
2622
</PropertyGroup>

tests/Microsoft.Android.Build.BaseTasks-Tests/Microsoft.Android.Build.BaseTasks-Tests.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<!-- $(TargetFrameworks) is used to allow the $(TargetFramework) check in Directory.Build.props to work.
5-
If $(TargetFramework) is declared here instead, it will not be evaluated before Directory.Build.props
6-
is loaded and the wrong $(TestOutputFullPath) will be used. -->
7-
<TargetFrameworks>net8.0</TargetFrameworks>
4+
<TargetFramework>$(DotNetTargetFramework)</TargetFramework>
85
<RootNamespace>Microsoft.Android.Build.BaseTasks.Tests</RootNamespace>
96
<IsPackable>false</IsPackable>
107
<OutputPath>$(TestOutputFullPath)</OutputPath>

tests/Xamarin.Android.Tools.AndroidSdk-Tests/Xamarin.Android.Tools.AndroidSdk-Tests.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<!-- $(TargetFrameworks) is used to allow the $(TargetFramework) check in Directory.Build.props to work.
5-
If $(TargetFramework) is declared here instead, it will not be evaluated before Directory.Build.props
6-
is loaded and the wrong $(TestOutputFullPath) will be used. -->
7-
<TargetFrameworks>net8.0</TargetFrameworks>
4+
<TargetFramework>$(DotNetTargetFramework)</TargetFramework>
85
<SignAssembly>true</SignAssembly>
96
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
107
<IsPackable>false</IsPackable>

tools/ls-jdks/ls-jdks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net472;net6.0</TargetFrameworks>
5+
<TargetFramework>$(DotNetTargetFramework)</TargetFramework>
66
<RootNamespace>Xamarin.Android.Tools</RootNamespace>
77
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
88
<OutputPath>$(ToolOutputFullPath)</OutputPath>

0 commit comments

Comments
 (0)