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

Support .NET Core 3.1 #291

Merged
merged 12 commits into from
Jan 6, 2020
Merged

Support .NET Core 3.1 #291

merged 12 commits into from
Jan 6, 2020

Conversation

imback82
Copy link
Contributor

@imback82 imback82 commented Oct 12, 2019

Now that .NET Core 3.0 is officially released, we are moving worker binaries from netcoreapp2.1 to netcoreapp3.1.

@imback82
Copy link
Contributor Author

I will also update docs that are related to building from source.

@imback82 imback82 self-assigned this Oct 13, 2019
@imback82 imback82 added the enhancement New feature or request label Oct 13, 2019
@imback82
Copy link
Contributor Author

cc: @eerhardt, can you check if I am missing anything migrating to netcore 3.0? Thanks!

@@ -20,7 +20,7 @@ Building Spark .NET on Windows

If you already have all the pre-requisites, skip to the [build](windows-instructions.md#building) steps below.

1. Download and install the **[.NET Core SDK](https://dotnet.microsoft.com/download/dotnet-core/2.1)** - installing the SDK will add the `dotnet` toolchain to your path. .NET Core 2.1, 2.2 and 3.0 preview are supported.
1. Download and install the **[.NET Core 3.0 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.0)** - installing the SDK will add the `dotnet` toolchain to your path.
2. Install any edition of **[Visual Studio 2019](https://www.visualstudio.com/downloads/)** or [Visual Studio 2017](https://www.visualstudio.com/downloads/). The Community version is completely free. When configuring your installation, include these components at minimum:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are now building for netcoreapp3.0, we now require VS 2019 Update 3. So this should be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to install 16.4 or higher. thanks!

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to make this change. You can just target netstandard2.0 and everything will work find on .NET Core 3.0.

The only reason you would multi-target for standard 2.0 and 2.1 is if you wanted to use a new API in 2.1 that wasn't available in 2.0, which it doesn't appear that we are doing.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consideration with targeting netstandard2.1:

.NET Framework won't support .NET Standard 2.1 or later versions. For more details, see the announcement of .NET Standard 2.1.

Source: https://docs.microsoft.com/en-us/dotnet/standard/net-standard

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why it is targeting both netstandard2.0 and netstandard2.1. .NET Framework will use the netstandard2.0 compatible version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted.

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to make this change. You can just target netstandard2.0 and everything will work find on .NET Core 3.0.

The only reason you would multi-target for standard 2.0 and 2.1 is if you wanted to use a new API in 2.1 that wasn't available in 2.0, which it doesn't appear that we are doing.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consideration with targeting netstandard2.1:

.NET Framework won't support .NET Standard 2.1 or later versions. For more details, see the announcement of .NET Standard 2.1.

Source: https://docs.microsoft.com/en-us/dotnet/standard/net-standard

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted

@@ -10,7 +10,7 @@
<PackageReference Include="System.Memory" Version="4.5.2" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'netcoreapp2.1' ">
<ItemGroup Condition=" '$(TargetFramework)' != 'netcoreapp3.0' ">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can just get removed. There is never a case where TargetFramework != netcoreapp3.0.

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want to make sure you are aware of the .NET Core support policy:

https://github.com/dotnet/core/blob/master/microsoft-support.md
https://github.com/dotnet/core/blob/master/roadmap.md

3.0 is the Current release of .NET Core. While 2.1 is still the LTS (long-term support) version. 3.1 will be the next LTS version shipping next month. Which means 3.0 will go out of support in about 4 months. So we will need to upgrade to 3.1 when it comes out. This shouldn't block us from upgrading to 3.0 today, but I just wanted to ensure you were aware of the policy.

@imback82
Copy link
Contributor Author

3.0 is the Current release of .NET Core. While 2.1 is still the LTS (long-term support) version. 3.1 will be the next LTS version shipping next month. Which means 3.0 will go out of support in about 4 months. So we will need to upgrade to 3.1 when it comes out. This shouldn't block us from upgrading to 3.0 today, but I just wanted to ensure you were aware of the policy.

Thanks @eerhardt. In this case, I will leave this PR open and update it to 3.1 when it's released next month.


<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See other netstandard2.1 comments on this PR.

@imback82
Copy link
Contributor Author

imback82 commented Dec 3, 2019

Now that .NET Core 3.1 is released, I will resume this work.

@imback82 imback82 changed the title Support .NET Core 3.0 Support .NET Core 3.1 Jan 3, 2020
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp2.1;netstandard2.1</TargetFrameworks>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eerhardt Should I add netcoreapp3.1 instead of replacing netcoreapp2.1?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For libraries (like Microsoft.Spark.csproj), you don't need to target all the frameworks you support running on. You just need to target the lowest/earliest frameworks that you support.

For example, if you just target netstandard2.0, your library will run on any desktop .NET Framework 4.6.1 or higher. And it will run on .NET Core 2.0 or higher.

The reason you would multi-target a library is so you can have different code that will execute when running on different frameworks. For example, .NET Core 3.1 adds a new API you want to use, so you multi-target to netstandard2.0;netcoreapp3.1. And now you can use #if conditions in your code to compile different code when building for netstandard2.0, and use the new API when building for netcoreapp3.1.

Since you don't have netcoreapp3.1 specific code in this library, it isn't necessary to put netcoreapp3.1 in this list at all.

The only framework-specific code I see in this project is:

private static string NormalizeTypeName(string typeName)
{
#if !NETSTANDARD2_0
return string.Create(typeName.Length - 4, typeName, (span, name) =>
{
name.AsSpan(0, name.Length - 4).ToLower(span, CultureInfo.CurrentCulture);
});
#else
return typeName.Substring(0, typeName.Length - 4).ToLower();
#endif
}
}

So in all actuality, if you want to drop 1st class support for .NET Core 2.1, you would really only need:

<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks> on this line. (Because .NET Core 3.1 is compatible with netstandard2.1, so the netstandard2.1 compiled assemblies will be used when running on .NET Core 3.1.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @eerhardt. netcoreapp2.1 was added from this discussion: #364 (comment). I will remove netcoreapp2.1 for now and will add it if it is absolutely needed.

Copy link
Member

@eerhardt eerhardt Jan 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only effect this will cause is if someone is on .NET Core 2.1 and uses the Microsoft.Spark library, the above code will use the slower Substring/ToLower code since the netstandard2.0 built version will be used. That doesn't seem too bad, especially if you aren't supporting .NET Core 2.1 on the worker anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, and this code is driver side and not used by worker anyway. Thanks @eerhardt!

@imback82 imback82 merged commit f83a1eb into dotnet:master Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants