Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

A Metalama weaver that embeds dependent assemblies as managed resources. A fork of Costura.Fody.

License

Notifications You must be signed in to change notification settings

postsharp/Metalama.Open.Costura

Repository files navigation

Metalama.Open.Costura

Embeds dependencies as resources so that you can have a standalone executable.

This source transformer only works under .NET Framework. In .NET Core, we recommend upgrading to .NET Core 3 or later and using the single file executable feature instead.

This is a Metalama aspect. It modifies your code during compilation by using source weaving.

CI badge

Example

Assume that MyProject has dependencies on the Newtonsoft.Json and Soothsilver.Random packages. Normally, MyProject.exe would require the files Newtonsoft.Json.dll and Soothsilver.Random.dll to work.

If you use this aspect, instead those two DLLs will be embedded into MyProject.exe as resources and loaded from there. The only file you need is MyProject.exe.

Installation

  1. Install the NuGet package: dotnet add package Metalama.Open.Costura.

  2. Add the following code somewhere in your code:

    using Metalama.Framework.Fabrics;
    using Metalama.Open.Costura;
    
    internal class Fabric : ProjectFabric
    {
        public override void AmendProject(IProjectAmender amender)
        {
            amender.UseCostura();
        }
    }

You can then distribute just the main output assembly file. It will be enough.

There are documented configuration options in the Costura attribute. Set them in your source code to change them from their defaults.

About

A Metalama weaver that embeds dependent assemblies as managed resources. A fork of Costura.Fody.

Topics

Resources

License

Stars

Watchers

Forks