Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .NET 8 target (Avalonia 11.1) #14535

Merged
merged 25 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b367d4a
Add .NET 8 target to packable projects
maxkatz6 Feb 8, 2024
85d242e
Update test projects
maxkatz6 Feb 8, 2024
4b94124
Update sample projects to target .NET 8
maxkatz6 Feb 8, 2024
eefa2a6
Update main Avalonia package to target .NET 8 as well
maxkatz6 Feb 8, 2024
cd662ba
Remove MSBuildEnableWorkloadResolver hack and some minor change
maxkatz6 Feb 8, 2024
8c30cd3
Use net8.0 in nuke build as well
maxkatz6 Feb 8, 2024
da03612
Pin 8.0.0 SDK
maxkatz6 Feb 8, 2024
d85ab03
Adjust API validation
maxkatz6 Feb 8, 2024
e310888
Pin a valid version
maxkatz6 Feb 8, 2024
956fec5
Remove net461 target from Avalonia package
maxkatz6 Feb 8, 2024
4fea742
Remove unused net6.0 target from Avalonia.Designer.HostApp
maxkatz6 Feb 8, 2024
f83f798
Adjust API diff
maxkatz6 Feb 8, 2024
552cffe
Update ControlCatalog.Android.csproj
maxkatz6 Feb 9, 2024
29aa7fb
Remove MSBuildEnableWorkloadResolver
maxkatz6 Feb 15, 2024
11d51fc
Fix Browser issues on .NET 8
maxkatz6 Feb 15, 2024
c3f1fd4
Merge branch 'master' into target-net-8
maxkatz6 Feb 20, 2024
e6de72a
Fix .NET 8 error
maxkatz6 Feb 20, 2024
c5ec089
Fix merge conflicts
maxkatz6 Feb 24, 2024
910352c
Merge branch 'master' into target-net-8
maxkatz6 Feb 27, 2024
5030693
Merge branch 'master' into target-net-8
maxkatz6 Mar 2, 2024
c60bed1
Replace explicit TFMs in .csproj files with a centralized registry
kekekeks Feb 24, 2024
c0f27fa
Fix merge conflict
maxkatz6 Mar 2, 2024
0c04adc
Fix AvsLegacyWindowsTargetFrameworks and add hacks for the tests
maxkatz6 Mar 2, 2024
b03b8f5
Update XCode project CommandLineArgument
maxkatz6 Mar 5, 2024
afc6214
Merge remote-tracking branch 'origin/master' into target-net-8
maxkatz6 Mar 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Avalonia.sln
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Props", "Props", "{F3AC8BC1
build\TrimmingEnable.props = build\TrimmingEnable.props
build\UnitTests.NetFX.props = build\UnitTests.NetFX.props
build\XUnit.props = build\XUnit.props
build\TargetFrameworks.props = build\TargetFrameworks.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Targets", "Targets", "{4D6FAF79-58B4-482F-9122-0668C346364C}"
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project>
<Import Project="$(MSBuildThisFileDirectory)/build/AvaloniaPublicKey.props"/>
<Import Project="$(MSBuildThisFileDirectory)/build/TargetFrameworks.props"/>
<PropertyGroup>
<PackageOutputPath Condition="'$(PackageOutputPath)' == ''">$(MSBuildThisFileDirectory)build-intermediate/nuget</PackageOutputPath>
<AvaloniaPreviewerNetCoreToolPath>$(MSBuildThisFileDirectory)\src\tools\Avalonia.Designer.HostApp\bin\$(Configuration)\netstandard2.0\Avalonia.Designer.HostApp.dll</AvaloniaPreviewerNetCoreToolPath>
<!-- https://github.com/dotnet/msbuild/issues/2661 -->
<AddSyntheticProjectReferencesForSolutionDependencies>false</AddSyntheticProjectReferencesForSolutionDependencies>
<MSBuildEnableWorkloadResolver>false</MSBuildEnableWorkloadResolver>
<RunApiCompat>False</RunApiCompat>
<LangVersion>11</LangVersion>
</PropertyGroup>
Expand Down
94 changes: 94 additions & 0 deletions api/Avalonia.Android.nupkg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Android.Internal.Resource.Animation</Target>
<Left>baseline/net6.0-android31.0/Avalonia.Android.dll</Left>
<Right>target/net8.0-android34.0/Avalonia.Android.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Android.Internal.Resource.Animator</Target>
<Left>baseline/net6.0-android31.0/Avalonia.Android.dll</Left>
<Right>target/net8.0-android34.0/Avalonia.Android.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Android.Internal.Resource.Attribute</Target>
<Left>baseline/net6.0-android31.0/Avalonia.Android.dll</Left>
<Right>target/net8.0-android34.0/Avalonia.Android.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Android.Internal.Resource.Boolean</Target>
<Left>baseline/net6.0-android31.0/Avalonia.Android.dll</Left>
<Right>target/net8.0-android34.0/Avalonia.Android.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Android.Internal.Resource.Color</Target>
<Left>baseline/net6.0-android31.0/Avalonia.Android.dll</Left>
<Right>target/net8.0-android34.0/Avalonia.Android.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Android.Internal.Resource.Dimension</Target>
<Left>baseline/net6.0-android31.0/Avalonia.Android.dll</Left>
<Right>target/net8.0-android34.0/Avalonia.Android.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Android.Internal.Resource.Drawable</Target>
<Left>baseline/net6.0-android31.0/Avalonia.Android.dll</Left>
<Right>target/net8.0-android34.0/Avalonia.Android.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Android.Internal.Resource.Id</Target>
<Left>baseline/net6.0-android31.0/Avalonia.Android.dll</Left>
<Right>target/net8.0-android34.0/Avalonia.Android.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Android.Internal.Resource.Integer</Target>
<Left>baseline/net6.0-android31.0/Avalonia.Android.dll</Left>
<Right>target/net8.0-android34.0/Avalonia.Android.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Android.Internal.Resource.Interpolator</Target>
<Left>baseline/net6.0-android31.0/Avalonia.Android.dll</Left>
<Right>target/net8.0-android34.0/Avalonia.Android.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Android.Internal.Resource.Layout</Target>
<Left>baseline/net6.0-android31.0/Avalonia.Android.dll</Left>
<Right>target/net8.0-android34.0/Avalonia.Android.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Android.Internal.Resource.String</Target>
<Left>baseline/net6.0-android31.0/Avalonia.Android.dll</Left>
<Right>target/net8.0-android34.0/Avalonia.Android.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Android.Internal.Resource.Style</Target>
<Left>baseline/net6.0-android31.0/Avalonia.Android.dll</Left>
<Right>target/net8.0-android34.0/Avalonia.Android.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Android.Internal.Resource.Styleable</Target>
<Left>baseline/net6.0-android31.0/Avalonia.Android.dll</Left>
<Right>target/net8.0-android34.0/Avalonia.Android.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0007</DiagnosticId>
<Target>T:Avalonia.Android.Internal.Resource</Target>
<Left>baseline/net6.0-android31.0/Avalonia.Android.dll</Left>
<Right>target/net8.0-android34.0/Avalonia.Android.dll</Right>
</Suppression>
</Suppressions>
6 changes: 3 additions & 3 deletions azure-pipelines-integrationtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
version: 6.0.x

- task: UseDotNet@2
displayName: 'Use .NET 7.0 SDK'
displayName: 'Use .NET 8.0 SDK'
inputs:
packageType: sdk
useGlobalJson: true
Expand All @@ -33,7 +33,7 @@ jobs:
rm -rf $(osascript -e "POSIX path of (path to application id \"net.avaloniaui.avalonia.integrationtestapp\")")
pkill IntegrationTestApp
./samples/IntegrationTestApp/bundle.sh
open -n ./samples/IntegrationTestApp/bin/Debug/net7.0/osx-$arch/publish/IntegrationTestApp.app
open -n ./samples/IntegrationTestApp/bin/Debug/net8.0/osx-$arch/publish/IntegrationTestApp.app
pkill IntegrationTestApp
displayName: 'Build IntegrationTestApp'

Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
version: 6.0.x

- task: UseDotNet@2
displayName: 'Use .NET 7.0 SDK'
displayName: 'Use .NET 8.0 SDK'
inputs:
packageType: sdk
useGlobalJson: true
Expand Down
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
version: 6.0.x

- task: UseDotNet@2
displayName: 'Use .NET 7.0 SDK'
displayName: 'Use .NET 8.0 SDK'
inputs:
packageType: sdk
useGlobalJson: true
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
version: 6.0.x

- task: UseDotNet@2
displayName: 'Use .NET 7.0 SDK'
displayName: 'Use .NET 8.0 SDK'
inputs:
packageType: sdk
useGlobalJson: true
Expand Down Expand Up @@ -162,7 +162,7 @@ jobs:
version: 6.0.x

- task: UseDotNet@2
displayName: 'Use .NET 7.0 SDK'
displayName: 'Use .NET 8.0 SDK'
inputs:
packageType: sdk
useGlobalJson: true
Expand Down
15 changes: 15 additions & 0 deletions build/TargetFrameworks.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project>
<PropertyGroup>
<AvsCurrentTargetFramework>net8.0</AvsCurrentTargetFramework>
<AvsCurrentWindowsTargetFramework>$(AvsCurrentTargetFramework)-windows</AvsCurrentWindowsTargetFramework>
<AvsCurrentAndroidTargetFramework>$(AvsCurrentTargetFramework)-android34</AvsCurrentAndroidTargetFramework>
<AvsCurrentIOSTargetFramework>$(AvsCurrentTargetFramework)-ios17.0</AvsCurrentIOSTargetFramework>
<AvsCurrentTvOSTargetFramework>$(AvsCurrentTargetFramework)-tvos17</AvsCurrentTvOSTargetFramework>
<AvsCurrentBrowserTargetFramework>$(AvsCurrentTargetFramework)-browser</AvsCurrentBrowserTargetFramework>
<AvsCurrentTizenTargetFramework>$(AvsCurrentTargetFramework)-tizen</AvsCurrentTizenTargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(AvsSkipBuildingLegacyTargetFrameworks)' != 'True'">
<AvsLegacyTargetFrameworks>net6.0</AvsLegacyTargetFrameworks>
<AvsLegacyWindowsTargetFrameworks>net6.0-windows</AvsLegacyWindowsTargetFrameworks>
</PropertyGroup>
</Project>
14 changes: 7 additions & 7 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"sdk": {
"version": "7.0.404",
"rollForward": "latestFeature"
},
"msbuild-sdks": {
"Microsoft.Build.Traversal": "3.2.0"
}
"sdk": {
"version": "8.0.101",
"rollForward": "latestFeature"
},
"msbuild-sdks": {
"Microsoft.Build.Traversal": "3.2.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</MacroExpansion>
<CommandLineArguments>
<CommandLineArgument
argument = "bin/Debug/net6.0/ControlCatalog.NetCore.dll"
argument = "bin/Debug/net8.0/ControlCatalog.NetCore.dll"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
Expand Down
13 changes: 10 additions & 3 deletions nukebuild/ApiDiffHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ await Task.WhenAll(pairs.Select(p => Task.Run(() =>
private static readonly (string oldTfm, string newTfm)[] s_tfmRedirects = new[]
{
// We use StartsWith below comparing these tfm, as we ignore platform versions (like, net6.0-ios16.1)
("net6.0-android", "net7.0-android"),
("net6.0-ios", "net7.0-ios"),
("net6.0-android", "net8.0-android"),
("net6.0-ios", "net8.0-ios"),
// Designer was moved from netcoreapp to netstandard
("netcoreapp2.0", "netstandard2.0")
};
Expand Down Expand Up @@ -171,8 +171,15 @@ public static async Task ValidatePackage(

if (targetDll?.entry is null)
{
if (packageId == "Avalonia"
&& baselineDll.target is "net461" or "netcoreapp2.0")
{
// In 11.1 we have removed net461 and netcoreapp2.0 targets from Avalonia package.
continue;
}

var actualTargets = string.Join(", ",
targetDlls.Select(d => $"{d.target} ({baselineDll.entry.Name})"));
targetDlls.Select(d => $"{d.target} ({d.entry.Name})"));
throw new InvalidOperationException(
$"Some assemblies are missing in the new package {packageId}: {baselineDll.entry.Name} for {baselineDll.target}."
+ $"\r\nActual targets: {actualTargets}.");
Expand Down
18 changes: 14 additions & 4 deletions nukebuild/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,29 @@ void RunCoreTest(string projectName)

foreach (var fw in targetFrameworks)
{
if (fw.StartsWith("net4")
var tfm = fw;
if (tfm == "$(AvsCurrentTargetFramework)")
{
tfm = "net8.0";
}
if (tfm == "$(AvsLegacyTargetFrameworks)")
{
tfm = "net6.0";
}

if (tfm.StartsWith("net4")
&& (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
&& Environment.GetEnvironmentVariable("FORCE_LINUX_TESTS") != "1")
{
Information($"Skipping {projectName} ({fw}) tests on *nix - https://github.com/mono/mono/issues/13969");
Information($"Skipping {projectName} ({tfm}) tests on *nix - https://github.com/mono/mono/issues/13969");
continue;
}

Information($"Running for {projectName} ({fw}) ...");
Information($"Running for {projectName} ({tfm}) ...");

DotNetTest(c => ApplySetting(c)
.SetProjectFile(project)
.SetFramework(fw)
.SetFramework(tfm)
.EnableNoBuild()
.EnableNoRestore()
.When(Parameters.PublishTestResults, _ => _
Expand Down
4 changes: 3 additions & 1 deletion nukebuild/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<IsPackable>False</IsPackable>
<NoWarn>$(NoWarn);CS0649;CS0169;SYSLIB0011</NoWarn>
<NukeTelemetryVersion>1</NukeTelemetryVersion>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
<!-- See https://github.com/nuke-build/nuke/issues/818 -->
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
<!-- Necessary for Microsoft.DotNet.GenAPI.Tool -->
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8-transport/nuget/v3/index.json</RestoreAdditionalProjectSources>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion packages/Avalonia/Avalonia.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>$(AvsCurrentTargetFramework);$(AvsLegacyTargetFrameworks);netstandard2.0</TargetFrameworks>
<PackageId>Avalonia</PackageId>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion samples/AppWithoutLifetime/AppWithoutLifetime.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
<Nullable>enable</Nullable>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/BindingDemo/BindingDemo.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />
Expand Down
3 changes: 1 addition & 2 deletions samples/ControlCatalog.Android/ControlCatalog.Android.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-android</TargetFramework>
<TargetFramework>$(AvsCurrentAndroidTargetFramework)</TargetFramework>
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ApplicationId>com.Avalonia.ControlCatalog</ApplicationId>
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<AndroidPackageFormat>apk</AndroidPackageFormat>
<MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver>
</PropertyGroup>
<ItemGroup>
<AndroidResource Include="..\..\build\Assets\Icon.png">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>$(AvsCurrentBrowserTargetFramework)</TargetFramework>
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<Nullable>enable</Nullable>
<EmccTotalMemory>16777216</EmccTotalMemory>
Expand Down
3 changes: 1 addition & 2 deletions samples/ControlCatalog.Browser/ControlCatalog.Browser.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>$(AvsCurrentBrowserTargetFramework)</TargetFramework>
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<WasmMainJSPath>AppBundle/main.js</WasmMainJSPath>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver>
<WasmRuntimeAssetsLocation>./</WasmRuntimeAssetsLocation>
</PropertyGroup>

Expand Down
15 changes: 9 additions & 6 deletions samples/ControlCatalog.Browser/EmbedSample.Browser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ public IPlatformHandle CreateControl(bool isSecond, IPlatformHandle parent, Func
}
else
{
var defaultHandle = (JSObjectControlHandle)createDefault();
var parentContainer = (JSObjectControlHandle)createDefault();

_ = JSHost.ImportAsync("embed.js", "./embed.js").ContinueWith(_ =>
{
EmbedInterop.AddAppButton(defaultHandle.Object);
}, TaskScheduler.FromCurrentSynchronizationContext());
AddButton(parentContainer.Object);

return parentContainer;

return defaultHandle;
static async void AddButton(JSObject parent)
{
await JSHost.ImportAsync("embed.js", "./embed.js");
EmbedInterop.AddAppButton(parent);
}
}
}
}
Expand Down
Loading