C
C#3w ago
! skyxjs

Build single executable

How do I build my executable without having all of those other files/folders? Just a single .exe nothing else
No description
17 Replies
ero
ero3w ago
$publishsinglefile
MODiX
MODiX3w ago
=> $singlefile
ero
ero3w ago
$singlefile
MODiX
MODiX3w 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, but be aware of drawbacks and consider using an installer framework instead of that property with PublishSingleFile. 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
! skyxjs
! skyxjsOP3w ago
will try that, thank you 🙏
! skyxjs
! skyxjsOP3w ago
Why do they have so much publishing options?
No description
! skyxjs
! skyxjsOP3w ago
i only get this
No description
Pobiega
Pobiega3w ago
its highly recommended to not use the publishing wizard and just learn to use the CLI instead
! skyxjs
! skyxjsOP3w ago
but no matter what i try i cant get the single exe working always with those extra files
Pobiega
Pobiega3w ago
what exactly have you tried? what command did you use, what does your csproj look like?
! skyxjs
! skyxjsOP3w ago
Create a single file for application deployment - .NET
Learn what single file application is and why you should consider using this application deployment model.
No description
! skyxjs
! skyxjsOP3w ago
this is my csproj
Pobiega
Pobiega3w ago
uh thats... a .NET framework project not modern .NET .net framework is legacy and should not be used unless you have an extremely good reason to
felsokning
felsokning3w ago
<RuntimeIdentifier>RID</RuntimeIdentifier> -- Needs to be the actual RID value. ...but as @Pobiega said, .NET framework won't work well and/or publish as a single file on any platform, I think.
ero
ero3w ago
that's correct, netfx can't produce a single file executable
! skyxjs
! skyxjsOP3w ago
Thank you I changed it to a modern .NET version and now everything works appreciate all of your help
Pobiega
Pobiega3w ago
Nice,!
Want results from more Discord servers?
Add your server