Can anybody help me. I'm trying to publish my .net core console app into single file.
I'm using this command:
dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true
I'm expecting that it will create a single file. But still there's dll files:
clrcompression.dll
clrjit.dll
coreclr.dll
mscordaccore.dll
How I can fix it? I already search but that's the same result
Publishing your app as self-contained produces a platform-specific executable. The output publishing folder contains all components of the app, including the . NET libraries and target runtime. The app is isolated from other . NET apps and doesn't use a locally installed shared runtime.
The PublishSingleFile Flag. All that intro and it literally comes down to a single command flag : dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true. All this does is runs our publish command but tells it to package it within a single file. You’ll notice that we no longer specify the self-contained flag.
To include the dotnet runtime dlls into your executable, you need to also use the --self-contained flag. So you can run dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true --self-contained true. Show activity on this post.
So you can run dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true --self-contained true. Show activity on this post. If using visual studio, go Build-> Publish [yourprojectname], edit the profile and check Produce single file.
Use the following command dotnet publish -r win-x64 /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true this will embed the .dlls in the binary therefore in the publish folder will remain only a .pdb file which isn't necessary during runtime. Thanks for contributing an answer to Stack Overflow!
To bundle native libraries you need to specify the IncludeNativeLibrariesForSelfExtract
flag.
So try running this dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true /p:IncludeNativeLibrariesForSelfExtract=true
See https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file#other-considerations
To include the dotnet runtime dlls into your executable, you need to also use the --self-contained
flag. So you can run dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true --self-contained true
.
See https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With