✅ build one file
Hello, i want build my project on 1 executable but idk who to do it
5 Replies
i look on youtube, but tutos are 1 or 2 years old
$singlefile
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: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.
Single file publishing | Runtime Identifier (RID) catalog | dotnet publish
Btw does the one who open exe file like this need to have .net installed?
that depends on
--self-contained
if its NOT self contained, yes
if it is self-contained, no
note that a self-contained exe is much much larger than a non-selfcontained one
there is also ahead of time (AOT) compilation, which removes the need for a runtime all-together, but has restrictions on what kind of code you can write (example, reflection is very limited in AOT)