embed or hide package dlls
How can I embed or hide the package dlls into the exe or place them into a sub folder where the exe is at? There are over 200 dlls in the output build and its just ridiculous.
38 Replies
$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 ...
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.
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.
you can also add
-p:IncludeAllContentForSelfExtract=true
I have this and it doesnt seem to do it idk why
@primetime43 you're publishing right? not just building
whats that stuff about an installer
im going to upgrade the target version rn to .NET 6
should have more flexibility then. Right now its targeting .net 5.0
well I was just going to build the exe then place it in the release on my github
single file and friends only apply to publishes, not regular builds
that is,
dotnet publish
, or the publish option in Visual Studiooohhh
which is what you want
builds dont include all the dependencies
like nuget packages
but bump to .net 6 first
as 5 is out of support anyhow
wow it worked
I got it to publish haha
ty both so much!
okay ya I will
went up to .net 6 and now I get this issue when trying to run it in vs
its a 2016 sln file I believe, so maybe I need to some how update that to 2022?
wow, getting rid of this fixed it. Super weird
<PublishSingleFile>true</PublishSingleFile>
but now when I publish it doesnt do with single file, so not a good fix. hmm
pass publishsinglefile only when building, could do it from commandline manually by doing
/p:PublishSingleFile=true
it also should be possible to make it happen automatically using some MSBuild-fu but I don't have the knowledge :phmm shouldnt be like that I dont think...
I do remember running into similar situation with debugger failing to attach when I have some publish related properties defined in csproj
GitHub
Support Single File Diagnostics · Issue #45382 · dotnet/runtime
This issue is tracking the work necessary to support single-file diagnostics. Our goal is to deliver parity with debugging and profiling with framework dependent applications where applicable. Redu...
yeahhhhhh so it is how it is due to how visual studio grabs stuffs from publish output apparently
<PublishSingleFile Condition="'$(Configuration)' == 'Release'">true</PublishSingleFile>
oh damn so its a bug that still hasnt been fixed after like 2 years
thats the only work around rn
welllll I assume it's more of a VS issue or something
well it worked in .net 5 but not 6, so it seems to be a .net issue
the sdk is probably doing nothing wrong, it's told to publish and publish single file but vs is trying to grab nonexistent file or something
thats weird that such a large feature like this was overlooked
same tbh
its not like PublishSingleFile isnt something a lot of ppl dont use ya know
yep using this fixed it for debug, but not release mode
@Chiyoko_S even with this code ^ it allows me to run in debug mode with no issue, but release gives that error and publish doesnt pack it into a single file
1. debugging in release is always kinda wonky as a lot of the info necessary are missing & there's optimisations that goes in making debugging harder
2. did you specify
-c Release
when dotnet publish
ingI mean I tried both, publishing in either doesnt pack it
um
I didnt do it from the command line, I did it from in VS, but ill try it through cl
hm
perhaps you need to clear out the output folder
I don't know it's totally a guess but
ya I did that also
hm
hmm if I figure it out, ill let you know
@Chiyoko_S fixed it
had to add this to the .csproj file
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
ah