C
C#ā€¢14mo ago
proot

āœ… Compilation to standalone exe

How can I use dotnet in command line to compile a project to a single .exe I can run anywhere instead of it creating a .dll with my code in it and an .exe to run it?
5 Replies
Trinitek
Trinitekā€¢14mo ago
$singlefile
MODiX
MODiXā€¢14mo ago
dotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true Use of -p:PublishSingleFile=true implies --self-contained true. Add --self-contained false to publish as runtime-dependent. -r RID and -p:PublishSingleFile=true can be moved to .csproj as the following properties:
<RuntimeIdentifier>RID</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>RID</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
but to target multiple RIDs, you have to use dotnet publish with the -r option for each RID. You can also add -p:IncludeNativeLibrariesForSelfExtract=true to include native libraries (like Common Language Runtime dlls) in the output executable. You might want to instead publish your application compiled Ahead Of Time to native code, see $nativeaot for examples. https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file https://docs.microsoft.com/en-us/dotnet/core/rid-catalog https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish
Create a single file for application deployment - .NET
Learn what single file application is and why you should consider using this application deployment model.
.NET Runtime Identifier (RID) catalog - .NET
Learn about the runtime identifier (RID) and how RIDs are used in .NET.
proot
prootOPā€¢14mo ago
/solved how do I mark smth as solved again šŸ˜…
SinFluxx
SinFluxxā€¢14mo ago
$close
MODiX
MODiXā€¢14mo ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server