Compile C# console without dll needed

Viewed 3555

When I compile my C# Console it comes with an dll, if I remove the dll the application doesn't work, and I need it to work with only an .exe and no .dll files. https://prnt.sc/t1gu4m

2 Answers
  1. Right Click your Project
  2. Select Publish
  3. Deployment Mode: Self-Contained
  4. Check the Produce single file option

Et voila, you got a single exe with the required dependencies

In addition to Maurice Legoland's answer. If you're using dotnet cli, run:

dotnet publish -p:PublishSingleFile=true --no-self-contained # Other arguments.

Only use the --no-self-contained flag if you want your executable to be dependent on .NET i.e, it cannot run without the user having .NET's CoreCLR. Otherwise simply set PublishSingleFile to true. You can also use a manifest/configuration file. See this for more information.

Related