Code Monkey home page Code Monkey logo

dotnet-assembly-alias's Introduction

Alias

Build status NuGet Status NuGet Status

Rename assemblies and fixes references. Designed as an alternative to Costura, ILMerge, and ILRepack.

See Milestones for release notes.

Designed to mitigate scenarios where an assembly is run in a plugin scenario. For example Unity extensions, MSBuild tasks, or SharePoint extensions. In these scenarios an assembly, and all its references, are loaded into a shared AppDomain. So dependencies operate as "first on wins". So, for example, if two addins assemblies use different versions of Newtonsoft, the first addin that is loaded defines what version of Newtonsoft is used by all subsequent addins assemblies.

This project works around this problem by renaming references and preventing name conflicts.

dotnet tool

https://www.nuget.org/packages/Alias/

.net 6 or higher is required to run this tool.

For a given directory and a subset of assemblies:

  • Changes the assembly name of each "alias" assembly.
  • Renames "alias" assemblies on disk.
  • For all assemblies, fixes the references to point to the new alias assemblies.

Installation

Ensure dotnet CLI is installed.

Install Alias

dotnet tool install --global Alias

Usage

assemblyalias --target-directory "C:/Code/TargetDirectory"
              --suffix _Alias
              --assemblies-to-alias "Microsoft*;System*;EmptyFiles"

Arguments

Target Directory

-t or --target-directory

Optional. If no directory is passed the current directory will be used.

Internalize

-i or --internalize

Optional. To internalize all types in the aliased assemblies. Defaults to false.

Prefix/Suffix

Either a prefix or suffix must be defined.

Prefix

-p or --prefix

The prefix to use when renaming assemblies.

Suffix

-s or --suffix

The suffix to use when renaming assemblies.

Assemblies to alias

-a or --assemblies-to-alias

Required. A semi-colon separated list of assembly names to alias. Names ending in * are treated as wildcards.

Assemblies to exclude

-e or --assemblies-to-exclude

Optional. A semi-colon separated list of assembly names to exclude.

Key

-k or --key

Path to an snk file.

Optional. If no key is passed, strong naming will be removed from all assemblies.

References

-r or --references

Optional. A semi-colon separated list of paths to reference files.

Reference File

--reference-file

Optional. A path to a file containing references file paths. One file path per line.

Default Reference File

By default the target directory will be scanned for a reference file named alias-references.txt

It can be helpful to extract reference during a build using msbuild and write them to a file accessible to Alias:

<Target Name="WriteReferenceForAlias" AfterTargets="AfterCompile">
  <ItemGroup>
    <ReferenceForAlias Include="@(ReferencePath)" Condition="'%(FileName)' == 'CommandLine'" />
  </ItemGroup>
  <WriteLinesToFile File="$(TargetDir)/alias-references.txt" Lines="%(ReferenceForAlias.FullPath)" Overwrite="true" />
</Target>

snippet source | anchor

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.