avalonia-dotnet-templates icon indicating copy to clipboard operation
avalonia-dotnet-templates copied to clipboard

Is https://github.com/AvaloniaUI/avalonia-dotnet-templates/blob/master/templates/csharp/xplat/AvaloniaTest/AvaloniaTest.csproj intentionally targetting .NET standard 2.0 while all platform specific projects target .NET 6.0?

Open martin-honnen opened this issue 2 years ago • 2 comments

I have tried to use the xplat template and was kind of surprised that the main project https://github.com/AvaloniaUI/avalonia-dotnet-templates/blob/master/templates/csharp/xplat/AvaloniaTest/AvaloniaTest.csproj has <TargetFramework>netstandard2.0</TargetFramework> while all the platform specific projects like https://github.com/AvaloniaUI/avalonia-dotnet-templates/blob/master/templates/csharp/xplat/AvaloniaTest.Android/AvaloniaTest.Android.csproj use .NET 6 e.g. <TargetFramework>net6.0-android</TargetFramework> or https://github.com/AvaloniaUI/avalonia-dotnet-templates/blob/master/templates/csharp/xplat/AvaloniaTest.Desktop/AvaloniaTest.Desktop.csproj has e.g. <TargetFramework>net6.0</TargetFramework>.

As the development, after creating a new project based on the template with e.g. dotnet new avalonia.xplat, happens on the main project where I, for instance, then tried to add a NuGet package written for .NET 5, I got a message that the package is not compatible with .NET standard 2.0. I had to edit the main project's TargetFramework before being able to add and use the NuGet package.

I am wondering what the reason is for having the main project use <TargetFramework>netstandard2.0</TargetFramework> although the dedicated projects derived from it all use .NET 6. Is there any advantage to use <TargetFramework>netstandard2.0</TargetFramework>? I think that is not in any way compatible with .NET 6.

martin-honnen avatar May 07 '22 11:05 martin-honnen

I think that is not in any way compatible with .NET 6.

Of course it is. There is no problem with using "netstandard2.0" project/package from the "net6.0" project. And before it was the only one possible way to multitarget, when not everything could use "net6.0" (like, legacy xamarin).

maxkatz6 avatar May 08 '22 16:05 maxkatz6

You are free to change target framework to whatever you want.

But since 6.0 now is LTS version, we probably can use it exclusively in our packages as well. So, it makes sense to update templates.

maxkatz6 avatar May 08 '22 16:05 maxkatz6