dotnet / dotnet/command-line-api
Multi-target to include down level `net4x` binaries in Nuget package
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
## Problem Background
When consuming a .NET Standard (`netstandardx.y`) package from a .NET Framework (`net4x`) project that's below .NET Framework 4.7.2 (for example `net461`) a bunch of extra support and shim binaries must be distributed due to some compatibility issues. This can balloon the size of the application that must be distributed to customers.
See https://docs.microsoft.com/en-us/dotnet/standard/net-standard#net-implementation-support, table footnote [2]:
> The versions listed here represent the rules that NuGet uses to determine whether a given .NET Standard library is applicable. **_While NuGet considers .NET Framework 4.6.1 as supporting .NET Standard 1.5 through 2.0, there are several issues with consuming .NET Standard libraries that were built for those versions from .NET Framework 4.6.1 projects._** For .NET Framework projects that need to use such libraries, we recommend that you upgrade the project to target .NET Framework 4.7.2 or higher.
In the multi-targeting documentation it is recommended that library authors should:
> ✔️ CONSIDER adding a target for net461 when you're offering a netstandard2.0 target.
>
> 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.
Source: https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/cross-platform-targeting#multi-targeting
When application authors wish to consume `System.CommandLine`, but are unable to target .NET Frameworks newer than 4.7.2 they must ship all these extra DLLs because the `System.CommandLine` package only supports .NET Standard 2.0 (`netstandard2.0`)
## Proposal
Introduce a `net461` target framework in the `System.CommandLine` project so that consumers that must target .NET Framework have a better experience.
In `src/System.CommandLine/System.CommandLine.csproj`:
```diff
System.CommandLine
- netstandard2.0
+ netstandard2.0;net461
8
```
Contributor guide
Assessment
This issue has not been assessed yet.