Embedding DLLs in a compiled executable

前端 未结 16 2679
情深已故
情深已故 2020-11-21 07:07

Is it possible to embed a pre-existing DLL into a compiled C# executable (so that you only have one file to distribute)? If it is possible, how would one go about doing it?<

16条回答
  •  感动是毒
    2020-11-21 07:28

    To expand on @Bobby's asnwer above. You can edit your .csproj to use IL-Repack to automatically package all files into a single assembly when you build.

    1. Install the nuget ILRepack.MSBuild.Task package with Install-Package ILRepack.MSBuild.Task
    2. Edit the AfterBuild section of your .csproj

    Here is a simple sample that merges ExampleAssemblyToMerge.dll into your project output.

    
    
    
       
        
        
       
    
       
    
    

提交回复
热议问题