[PR #621] [MERGED] Add net461 target to clean up issues with system.* nuget dependencies #1132

Open
opened 2026-01-29 22:19:08 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/adamhathcock/sharpcompress/pull/621
Author: @inthemedium
Created: 9/29/2021
Status: Merged
Merged: 10/2/2021
Merged by: @adamhathcock

Base: masterHead: master


📝 Commits (3)

  • 1561bba Add net462 target to clean up issues with system.* nuget dependencies
  • 01f7336 Based on docs, the target should bet net461
  • 6983e66 Fix preprocessor condition

📊 Changes

9 files changed (+20 additions, -18 deletions)

View changed files

📝 src/SharpCompress/Algorithms/Alder32.cs (+5 -5)
📝 src/SharpCompress/Common/ArchiveEncoding.cs (+1 -1)
📝 src/SharpCompress/Compressors/BZip2/BZip2Stream.cs (+2 -2)
📝 src/SharpCompress/Compressors/LZMA/LZipStream.cs (+1 -1)
📝 src/SharpCompress/Crypto/Crc32Stream.cs (+1 -1)
📝 src/SharpCompress/IO/NonDisposingStream.cs (+2 -2)
📝 src/SharpCompress/Polyfills/StreamExtensions.cs (+1 -1)
📝 src/SharpCompress/Polyfills/StringExtensions.cs (+1 -1)
📝 src/SharpCompress/SharpCompress.csproj (+6 -4)

📄 Description

Reason for change

.NET has a few known issues for libraries that depend on System.* and only ship a netstandard2.0 target

  1. .NET has different assembly versions for netstandard2.0 versus net461 (see #591). Unless assembly binding redirects are carefully applied, there will be runtime errors.
  2. The build output will have tons of "façade" assemblies (see the blogpost in reference 2)

Given the two issues above official guidance is (see reference 1)

✔️ 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.

So this PR takes the above guidance to make it easier for those of us still stuck on .NET Framework < 4.7.2 :-)

Example from my recent experience

Due to the recent CVE, I upgraded SharpCompress to version 0.29. Our code is mostly .NETFramework, so we unfortunately have PackageReferences to System.Memory and System.Buffers. Everything appeared to be fine, however at runtime things were failing left and right because most of our projects/nuget dependencies require the latest System.Memory and System.Buffers while SharpCompress requires older versions. This is all avoid requiring a netstardard2.0 assembly that has an assembly version of 4.0.3.0 (see #591 ) .

After making my change, I found that .NETFramework projects work flawlessly without any tricky assembly binding redirects.

References

  1. https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/cross-platform-targeting
  2. https://weblog.west-wind.com/posts/2019/Feb/19/Using-NET-Standard-with-Full-Framework-NET

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/adamhathcock/sharpcompress/pull/621 **Author:** [@inthemedium](https://github.com/inthemedium) **Created:** 9/29/2021 **Status:** ✅ Merged **Merged:** 10/2/2021 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (3) - [`1561bba`](https://github.com/adamhathcock/sharpcompress/commit/1561bba538020f28bb175ff8d9a8cf1f6da23515) Add net462 target to clean up issues with system.* nuget dependencies - [`01f7336`](https://github.com/adamhathcock/sharpcompress/commit/01f7336d095047f11b8b320b604f214f86e914d8) Based on docs, the target should bet net461 - [`6983e66`](https://github.com/adamhathcock/sharpcompress/commit/6983e660370aae362292022de028f0be2959ee02) Fix preprocessor condition ### 📊 Changes **9 files changed** (+20 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `src/SharpCompress/Algorithms/Alder32.cs` (+5 -5) 📝 `src/SharpCompress/Common/ArchiveEncoding.cs` (+1 -1) 📝 `src/SharpCompress/Compressors/BZip2/BZip2Stream.cs` (+2 -2) 📝 `src/SharpCompress/Compressors/LZMA/LZipStream.cs` (+1 -1) 📝 `src/SharpCompress/Crypto/Crc32Stream.cs` (+1 -1) 📝 `src/SharpCompress/IO/NonDisposingStream.cs` (+2 -2) 📝 `src/SharpCompress/Polyfills/StreamExtensions.cs` (+1 -1) 📝 `src/SharpCompress/Polyfills/StringExtensions.cs` (+1 -1) 📝 `src/SharpCompress/SharpCompress.csproj` (+6 -4) </details> ### 📄 Description ### Reason for change .NET has a few known issues for libraries that depend on `System.*` and only ship a `netstandard2.0` target 1. .NET has different assembly versions for `netstandard2.0` versus `net461` (see #591). Unless assembly binding redirects are carefully applied, there will be runtime errors. 2. The build output will have tons of "façade" assemblies (see the blogpost in reference 2) Given the two issues above official guidance is (see reference 1) > ✔️ 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. So this PR takes the above guidance to make it easier for those of us still stuck on .NET Framework < 4.7.2 :-) ### Example from my recent experience Due to the recent CVE, I upgraded `SharpCompress` to version `0.29`. Our code is mostly `.NETFramework`, so we unfortunately have `PackageReferences` to `System.Memory` and `System.Buffers`. Everything appeared to be fine, however at runtime things were failing left and right because most of our projects/nuget dependencies require the latest `System.Memory` and `System.Buffers` while `SharpCompress` requires older versions. This is all avoid requiring a `netstardard2.0` assembly that has an assembly version of `4.0.3.0` (see #591 ) . After making my change, I found that `.NETFramework` projects work flawlessly without any tricky assembly binding redirects. ### References 1. https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/cross-platform-targeting 2. https://weblog.west-wind.com/posts/2019/Feb/19/Using-NET-Standard-with-Full-Framework-NET --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 22:19:08 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1132