A dotnet tool to generate reference assemblies.
Reference assemblies are assemblies which only contain metadata but no executable IL code.
Sometimes you do not want to ship executable code but only metadata for developers to interact with your dll. This can be especially useful if other developers are developing addons/plugins/integrations to your proprietary product. You can then just provide your reference assembly to them. They will not need access to your product.
dotnet tool install ReferenceAssemblyGenerator.CLI <-g|--global>
dotnet generatereference -- [--keep-non-public] [--force] [--use-ret] [--output <outputfile>] <assemblyPath>
First install the CLI tool globally: dotnet tool install ReferenceAssemblyGenerator.CLI --global
.
After that install ReferenceAssemblyGenerator.BuildTargets
to your project and set <GenerateReference>
to true in your .csproj.
You can also set <ReferenceKeepNonPublic>
, <ReferenceUseRet>
and <ReferenceOutputPath>
.
By default, <ReferenceOutputPath>
will be equal to the output file.
The C# and Visual Basic .NET compiler (Rosyln) contains the similar options /refout and /refonly.
- Unlike Rosyln, ReferenceAssemblyGenerator removes non-public types and members too. It also removes all non-public attributes.
- Rosyln only supports
throw null
as dummy instructions while ReferenceAssemblyGenerator also supports justret
instead. - Rosyln can only generate reference assemblies if you have the full source code. ReferenceAssemblyGenerator does not need source code, only the .dll or .exe.