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

Remove net471 as target framework. #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

havarnov
Copy link
Contributor

This project only requires netstandard2.0 and can therefore skip the
net471 as target framework.

And the test project is more cross-platform friendly without net471
as target framework.

This project only requires netstandard2.0 and can therefore skip the
net471 as target framework.

And the test project is more cross-platform friendly without net471
as target framework.
@havarnov
Copy link
Contributor Author

There might be some issues with this that I don't see. In that case, please be free to disregard.

@Washi1337
Copy link
Owner

Washi1337 commented Nov 22, 2019

If I am not mistaken, dotnet will not include too many standard libraries when it is build/published along with another projects targeting .net framework. This was the primary reason why net471 was added. There could be another way of doing this though, however. If you know of a more elegant solution, please let me know.

Also note that you are not required to build the project for every platform that the csproj specifies. If your intention is to only build the project and not really change anything, you can grab a build from the build server or use

dotnet build --framework=netstandard2.0

to only build the target for netstandard 2.0.

@havarnov
Copy link
Contributor Author

In an article on docs.microsoft.com there are some general guidelines for choosing target framework. And the main advice is to target netstandard2.0 if the library doesn't need any platform specific api's.

Although it says something about issues with netstandard2.0:

Using .NET Standard 2.0 from .NET Framework has some issues that were addressed in .NET Framework 4.7.2. You can improve the experience for developers that are still on .NET Framework 4.6.1 - 4.7.1 by offering them a binary that is built for .NET Framework 4.6.1.

In this github issue someone asks what kind of issues, but there's no more information about those issues provided.

If that information is correct this library should target net461 I guess, but I still think netstandard2.0 is the best options for Rivers.

I'm aware of dotnet build --framework <targetframework> and to be fair that worked out of the box for me, but I did have some issues with omnisharp and vscode due to the multitargeting. Maybe that could be fixed in another way, though.

@havarnov
Copy link
Contributor Author

Actually dotnet build --framework <targetframework> doesn't work on the solution file:

➜ Rivers git:(feature/depth-info-on-traversal) ✗ dotnet build --framework netstandard2.0
Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 46.56 ms for /Users/havarnov/dev/csharp/Rivers/Rivers/Rivers.csproj.
  Restore completed in 49.86 ms for /Users/havarnov/dev/csharp/Rivers/Rivers.Test/Rivers.Test.csproj.
/usr/local/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1005: Assets file '/Users/havarnov/dev/csharp/Rivers/Rivers.Test/obj/project.assets.json' doesn't have a target for '.NETStandard,Version=v2.0'. Ensure that restore has run and that you have included 'netstandard2.0' in the TargetFrameworks for your project. [/Users/havarnov/dev/csharp/Rivers/Rivers.Test/Rivers.Test.csproj]
  Rivers -> /Users/havarnov/dev/csharp/Rivers/Rivers/bin/Debug/netstandard2.0/Rivers.dll

Build FAILED.

/usr/local/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1005: Assets file '/Users/havarnov/dev/csharp/Rivers/Rivers.Test/obj/project.assets.json' doesn't have a target for '.NETStandard,Version=v2.0'. Ensure that restore has run and that you have included 'netstandard2.0' in the TargetFrameworks for your project. [/Users/havarnov/dev/csharp/Rivers/Rivers.Test/Rivers.Test.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.14

And neither does netcoreapp2.2:

➜ Rivers git:(feature/depth-info-on-traversal) ✗ dotnet build --framework netcoreapp2.2  
Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 30.14 ms for /Users/havarnov/dev/csharp/Rivers/Rivers/Rivers.csproj.
  Restore completed in 29.42 ms for /Users/havarnov/dev/csharp/Rivers/Rivers.Test/Rivers.Test.csproj.
/usr/local/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1005: Assets file '/Users/havarnov/dev/csharp/Rivers/Rivers/obj/project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.2'. Ensure that restore has run and that you have included 'netcoreapp2.2' in the TargetFrameworks for your project. [/Users/havarnov/dev/csharp/Rivers/Rivers/Rivers.csproj]
  Rivers -> /Users/havarnov/dev/csharp/Rivers/Rivers/bin/Debug/netstandard2.0/Rivers.dll
  Rivers.Test -> /Users/havarnov/dev/csharp/Rivers/Rivers.Test/bin/Debug/netcoreapp2.2/Rivers.Test.dll

Build FAILED.

/usr/local/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1005: Assets file '/Users/havarnov/dev/csharp/Rivers/Rivers/obj/project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.2'. Ensure that restore has run and that you have included 'netcoreapp2.2' in the TargetFrameworks for your project. [/Users/havarnov/dev/csharp/Rivers/Rivers/Rivers.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.89

But the following works:

dotnet build --framework netstandard2.0 Rivers/Rivers.csproj 
dotnet test --framework netcoreapp2.2 Rivers.Test/Rivers.Test.csproj 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants