C
C#2mo 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
ero2mo ago
$publishsinglefile
MODiX
MODiX2mo ago
=> $singlefile
ero
ero2mo ago
$singlefile
MODiX
MODiX2mo 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
! skyxjsOP2mo ago
will try that, thank you 🙏
! skyxjs
! skyxjsOP2mo ago
Why do they have so much publishing options?
No description
! skyxjs
! skyxjsOP2mo ago
i only get this
No description
Pobiega
Pobiega2mo ago
its highly recommended to not use the publishing wizard and just learn to use the CLI instead
! skyxjs
! skyxjsOP2mo ago
but no matter what i try i cant get the single exe working always with those extra files
Pobiega
Pobiega2mo ago
what exactly have you tried? what command did you use, what does your csproj look like?
! skyxjs
! skyxjsOP2mo 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
! skyxjsOP2mo ago
this is my csproj
Pobiega
Pobiega2mo 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
felsokning2mo 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
ero2mo ago
that's correct, netfx can't produce a single file executable
! skyxjs
! skyxjsOP2mo ago
Thank you I changed it to a modern .NET version and now everything works appreciate all of your help
Pobiega
Pobiega2mo ago
Nice,!
Want results from more Discord servers?
Add your server