dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.6k stars 1.03k forks source link

Optimization - DotNet6 Self Contained Trimmed Publish build still contains many files- and looks not required #34569

Open subhash4git opened 11 months ago

subhash4git commented 11 months ago

Hi DotNet-Team,

I am using Self Contained - trimmed build to reduce the overall package size in Modern DotNet App uses .NET6. But found that after publish still there are many files are copied to output directory.

So could you please clarify and answer following questions.

Q1 - Do I need to package all those files in publish directory in the final package? Q2 - Is there any way to optimize and remove some of the files which the app is not using. Please share if you have any document list the required files to copy in final delpoyment package.

Following screen shot shows some file names looks not required - debug, etc (Marked in SelfContained_MSFT_QA_GIT) Files -> dbgshim.dll, Micosoft.DiaSymReader.Native.amd64.dll

dotnet-issue-labeler[bot] commented 11 months ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

agocke commented 11 months ago

Potential duplicate of https://github.com/dotnet/sdk/issues/12616

vitek-karas commented 11 months ago

Trimming doesn't have the ability to remove native library dependencies right now. I'm really bad at github search - I'm sure there's an existing issue for this, just can't find it. It's possible that they are needed or not - hard to tell really. You would need to know which managed assembly has a dependency on these and check if that assembly is still present - if not, remove the native library as well.

subhash4git commented 11 months ago

Hi DotNet-Team,

Thanks for your reply . Just listed some of the assemblies in self trimmed publish build took more size on disk. Would you please clarify - How can I determine following assemblies are really required or not for the app ? Please share if you have any document list the required files to copy in final deployment package

mscordaccore.dll -> 1291 KB mscordbi.dll -> 1240 KB ucrtbase.dll -> 1097 KB hostpolicy.dll -> 384 KB hostfxr.dll -> 367 KB clretwrc.dll -> 298 KB

vitek-karas commented 11 months ago

We currently don't have any tooling to determine which native dependencies could be removed. I would advise to not remove anything. It also depends on what kind of functionality you require on the deployed application. For example, the first two files are there to enable debugging.