Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

632
Vistas
Can't get costura.fody to embed dll into exe

I try to embed the dll of a class library into my exe. I use visual studio 2019 and .net 5. I created two projects in one solution one is class library (dll), and the second is console application both targeted for .net core 5. I selected the console application as startup project. the class library contain only public static hello function which print out hello. I referenced the project of the class library into the console application then in the console application i only called the ClassNamespace.library.hello function. when I compile it, it workes fine. then I installed costura.fody as described in their readme, i added the to the console project by:

PM> Install-Package Fody
PM> Install-Package Costura.Fody

Then I FodyWeavers.xml into project folder

<Weavers>
  <Costura/>
</Weavers>

After that i rebuilt the project, and it built, and the exe is running, but when I delete the .dll from the output directory the .exe isn't running.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This can be accomplished without any additional package. Since NET 5 you have to set two options.

<PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
    <!-- To publish just a single *.exe file -->
    <PublishSingleFile>true</PublishSingleFile>
    <!-- Specify for which runtime you want to publish -->
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
    <!-- Since NET 5 specify this if you want to also pack all external *.dll to your file -->
    <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
    <!-- Add trimming for a smaller file size if possible--->
    <PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>

With setting IncludeNativeLibrariesForSelfExtract to false

enter image description here

With setting IncludeNativeLibrariesForSelfExtract to true

enter image description here

Documentation for publish single file

Documentation for trimming

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda