❔ ✅ ✅ Why does $singlefile make the .exe file so large
Hey I didnt want loads of files so I used $singlefile method and now the exe is 64 megabytes for just a console.writeline hello world program does anyone have any idea of how to lower it
18 Replies
dotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true
Use of -r
|--runtime
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.
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-publishCreate 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
Learn about the runtime identifier (RID) and how RIDs are used in .NET.
Because the runtime is contained within the executable.
And the runtime is big
Hello world is not 64 mb
It's less than 2
how do i get rid of it
using this
dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true
Just read $singlefile...?
dotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true
Use of -r
|--runtime
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.
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-publishCreate 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
Learn about the runtime identifier (RID) and how RIDs are used in .NET.
dotnet publish -c --self-contained=true Release -r win-x64 -p:PublishSingleFile=true
Required argument missing for option: -c
where would I put self contained
Required argument missing for option: -c
???
Sorry @Jb9 your message contained blocked content and has been removed!
sorry im actually a huge idiot
thank you
dotnet publish -c Release --self-contained=false -r win-x64 -p:PublishSingleFile=true
for other peopleyou can trim too
what is that
$trim
Since .NET 6, publishing with
-p:PublishTrimmed=true
or
added to the .csproj
file will publish a binary trimmed of all the unused framework code.
https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-containedTrim self-contained applications - .NET
Learn how to trim self-contained apps to reduce their size. .NET Core bundles the runtime with an app that is published self-contained and generally includes more of the runtime then is necessary.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.
Was this issue resolved? If so, run /close
- otherwise I will mark this as stale and this post will be archived until there is new activity.