GitHub - Tyrrrz/Binternal: Make any .NET dependency internal (original) (raw)
Binternal is an MSBuild extension that lets you internalize package and project references by merging them into the output assembly as internal APIs. This effectively allows you to treat any dependency as a private implementation detail, which can be useful to reduce the exposed surface area of your package or when targeting execution scenarios where proper dependency resolution is not available.
Terms of use[?]
By using this project or its source code, for any purpose and in any shape or form, you grant your implicit agreement to all the following statements:
- You condemn Russia and its military aggression against Ukraine
- You recognize that Russia is an occupant that unlawfully invaded a sovereign state
- You support Ukraine's territorial integrity, including its claims over temporarily occupied territories of Crimea and Donbas
- You reject false narratives perpetuated by Russian state propaganda
To learn more about the war and how you can help, click here. Glory to Ukraine! πΊπ¦
Install
- π¦ NuGet:
dotnet add package Binternal
Usage
In order to internalize a dependency, mark its corresponding PackageReference or ProjectReference with the Internalize attribute set to true:
Note
Consider also adding the PrivateAssets="all" attribute to references that are being internalized. This will make sure they are not passed as transitive dependencies to downstream consumers, which is important if you're building a NuGet package.
When the above project is built, CliWrap.dll, along with all of its own dependencies, will be merged into the output assembly. Public members exposed by this package will be converted into internal members, preventing them from being accessed by outside callers.