Skip to main content
.NETStandard2.0

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

Published
Aug 29, 2024
2y ago
Total Downloads
47.8K
47,833

Install

dotnet add package Metalama.Community.Costura --version 2024.2.22
ProductVersions
.NET Standard
netstandard2.0

README

Metalama.Community.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.Community.Costura.

  2. Add the following code somewhere in your code:

    using Metalama.Framework.Fabrics;
    using Metalama.Community.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.

Changes from Previous Version

No structural changes between v2024.2.21 and v2024.2.22.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

No SPDX license expression is published. Review the license text and your organisation's policy before redistribution.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.