Tutorial :Visual Studio builds my project with several unused files and libraries



Question:

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 ?

Also pdb files for some (but not all) of my projects and vshost files keep being transferred to the bin directoreies even when I build with the Release target. I haven't messed around wiht 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.


Solution:1

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 labelled "Debug Info", set this to none to disable the pdb creation.

As for the references, that doesn't sound like correct behaviour, but bare in mind the 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 nomatter 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.


Solution:2

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).


Solution:3

Simply removing the files from the directories won't stop them from appearing in future builds. Check the pre and post build steps in the project properties. If you don't want symbols in release builds, disable the debug symbol link options in the project properties (but I would recommend keeping them unless you write perfect code).


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »