Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio builds my project with several unused files and libraries

For a while now I have had visual studio producing builds that have all sorts of extra files in them. I have checked everything that I know of for where these could be coming from and I am out of ideas.

For example, I was previously using MbUnit but now I use NUnit. None of my projects even reference MbUnit but it is still appearing in my bin\Debug and bin\Release folders when I build. In addition, my bootstrapper project doesn't even reference any libraries that use a test framework so why is it appearing in BootStrapper\bin\Relase folder?

Also, pdb files for some (but not all) of my projects and vshost files keep being transferred to the bin directories even when I build with the Release target. I haven't messed around with the definition of the configuration target at all!

Does anyone have any idea where these could be coming from? I must be missing some bit of knowledge.

like image 362
George Mauer Avatar asked Feb 28 '23 16:02

George Mauer


2 Answers

By default, release builds do create the pdb files, so it isn't unusual to see them in there. I'd assume the same is true of the vshost file. If you want to build without them bring up the projects settings (from the project's context menu in the solution explorer) go to the "build" tab, at the top ensure that you are looking at the release configuration and then click the "advanced" button at the bottom. In the new window that pops up, there is a dropdown labeled "Debug Info", set this to none to disable the pdb creation.

As for the references, that doesn't sound like correct behavior, but bear in mind they are recursive so if a projectA references projectB and projectB references mbunit then the mbunit dlls will be copied into any build folder for projectA. So it may be that you have missed one reference somewhere and this is propagating throughout your entire solution...?

Also, ensure that you are rebuilding the solution rather than building - a build will not get rid of any files that already exist in the folder. Even better manually delete the bin and obj folder before you build to ensure you have a clean slate.


Just done a quick test in Visual Studio and it looks like a vshost file is created for whichever project is set as your StartUp project in both debug and release no matter what the debug info setting is. To stop this you need to uncheck the "Enable the Visual Studio hosting process" under the Debug tab of the project's settings.

like image 168
Martin Harris Avatar answered Mar 22 '23 22:03

Martin Harris


You can safely remove the .pdb files and the .vshost files, the former is for debugging information (yes, even release builds can be debugged to some degree) and the later is for visual studio only, it makes running with vs as an attached debugger faster (again, release or not).

like image 37
Blindy Avatar answered Mar 22 '23 22:03

Blindy