0

I have created a c#-project in Visual Studio 2022 which is using the nuget-package "Microsoft.Data.SqlClient". This package brings along about 60(!) dll, so that my \bin\release folder is now really full.

To get more clarity in this folder, I was wondering if these dll could be placed in a subdirectory of \bin\release, for example \bin\release\dll.

I'm also wondering why there are *.xml and *.pdb files genereated for every *.dll file in \bin\release. Could this be suppressed?

Thanks for any suggestions! Tobias

Tobias G.
  • 63
  • 7
  • Short answer is no, long answer is yes, but AFAIK that would involve lots of effort. Including a [custom build target](https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-your-build) that moves these DLLs into a subdirectory and [hooking into the assembly resolver](https://learn.microsoft.com/en-us/dotnet/standard/assembly/resolve-loads#the-correct-way-to-handle-assemblyresolve) in order to load those DLLs. – Good Night Nerd Pride Dec 12 '22 at 14:30
  • PDB file generation can be disabled in the project properties Build > General > Debug symbols. XML file generation can be disabled also there at Build > Output > Documentation file. – Good Night Nerd Pride Dec 12 '22 at 14:33
  • 2
    Why do you care about the number of DLL-s? Your code is using those features so the DLL-s need to be there. Typical users won't look into your release folder but will use a shortcut to start your program. – xxbbcc Dec 12 '22 at 14:41
  • What is your project template? Is it .net 6, .net 7 or .net framework? – Jingmiao Xu-MSFT Dec 13 '22 at 03:21
  • the pdb file generation seems to work only for the main program, but not für nuget packages. They are still generated – Tobias G. Dec 13 '22 at 08:58
  • 1
    This is not a "normal" programm for typical users mit shortcuts. It will be some kind of portable app, so you do have to look in the release folder to start the exe. – Tobias G. Dec 13 '22 at 08:59
  • I am using .net framework – Tobias G. Dec 13 '22 at 09:00

3 Answers3

2

As you said, you are using .net framework, you can refer to the following steps to achieve your requirement:

First, you can add post build event in property of the project to move the DLLs into lib folder: enter image description here

You can refer to this command line in post build event:

ROBOCOPY "$(TargetDir) " "$(TargetDir)lib\ " /XF *.exe *.config *.manifest  /XD lib logs data /E /IS /MOVE if %errorlevel% leq 4 exit 0 else exit %errorlevel%

Then add this code in your App.config file:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <probing privatePath="lib" />
    </assemblyBinding>
</runtime>

It looks like this: enter image description here

Finally build the project it will be clean in the folder and the .exe file works fine. enter image description here

Jingmiao Xu-MSFT
  • 2,076
  • 1
  • 3
  • 10
0

You hardly will be able to run your executable without the dependencies. Regarding the .pdb debug info files, a great answer is provided here: Release generating .pdb files, why? Good luck!

Angel Dinev
  • 399
  • 4
  • 13
0

I think you can use the Probing element

Something like this

<configuration>  
   <runtime>  
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
         <probing privatePath="bin;bin2\subbin;bin3"/>  
      </assemblyBinding>  
   </runtime>  
</configuration>  
  • Thanks for your answer, but I do know how this can help me? – Tobias G. Dec 13 '22 at 09:01
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 15 '22 at 14:47