0

In order to debug Web API projects in Visual Studio 2013, I had to set output path for the Debug configuration to bin\ (meaning files end up in {ProjectName}\bin relative to the solution root folder) as can be seen from some of the answers here.

But now I face the issue that we have used the path bin\{ConfigurationName} in several places in our build server setup. I would very much like to unify the setup for Debug and the other Visual Studio configurations.

Therefore my question is: do you know of any problematic consequences of unifying the output folder for all configurations to be bin\, leading to folder structure {ProjectName}\bin?

If you do, is there any way to debug a Web API project without changing the output folder from bin\Debug\ ?

Community
  • 1
  • 1
Søren Boisen
  • 1,669
  • 22
  • 41
  • 1
    As long as you make sure your name spaces dont conflict then I can't see an issue. The issue I've had in the past is when you have a Customer controller in both your MVC and API projects, for example. – nik0lai May 12 '15 at 13:56
  • 1
    One potential issue could be caused by VS only compiling files that have changed. It is possible that you will not be able to debug if compilation symbols have not been compiled into unchanged assemblies. – BDH Jun 02 '15 at 11:04
  • @BDH This is a great point! Important to remember when switching configurations. – Søren Boisen Jun 02 '15 at 13:47

1 Answers1

5

No Consequences:

By default, Project builds are stored in Project directories like:

{Solution}/{Project}/obj/Debug/{Project}.dll    
{Solution}/{Project}/obj/Release/{Project}.dll

A folder for each build type in each Project folder


If all your binaries were output to the same directory, they would

  • link the same way at run-time in your development environment
  • resolve dependencies the same way
  • deploy the same way

The result would be directory structure of

{Output Directory}/Debug/{Project}.dll    
{Output Directory}/Release/{Project}.dll    

The IDE is customizable:

There is no requirement to keep Project builds in Project directories. Project build Folders are a configuration default. The IDE was designed to allow you to work around your comfort zone. If you prefer to group all assemblies, or find that it resolves an issue, you are free to change this build configuration.


Problems De-bugging Web-API?

You should not have to change the output path to Debug Web API. Attach your Web-API to a worker process.

1) click on your Web API Project in VS Explorer

2) click debug in Visual Studio Menu

3) click Attach to Process...

4) click / select all processes named w3wp.exe

Dave Alperovich
  • 32,320
  • 8
  • 79
  • 101
  • I have clarified the question, since there was a slight misunderstanding. I expect the answer to be much the same though :-) – Søren Boisen Jun 02 '15 at 11:03
  • @SørenBoisen, before respond, I want to be certain I understand properly. You want to combine all Configurations into same directory within `bin\` rather than having a distinct `bin\Config` folder for your build Config files? – Dave Alperovich Jun 02 '15 at 17:07
  • Yes, but still per project, as I tried to clarify in the question :-) So - output for each project goes to that projects bin folder no matter the Configuration. Clearer? – Søren Boisen Jun 02 '15 at 17:26
  • @SørenBoisen, There is no issue with using `bin/` for all output paths. Since you are never interested in building debug AND release simultaneously (if that was even possible), the active build will overwrite some files currently in the bin folder. But that is no problem -- much like performing a Clean/Build. I would NOT expect any issues with Debugging b/c the `.pdb` files manage the debug assembly trace. – Dave Alperovich Jun 02 '15 at 17:45
  • Arh yes, the debug symbols are in separate files, so that won't pose a problem. However using methods on System.Diagnostics.Debug would not work until a change/forced recompilation I suppose. But that would just be a point of confusion and not a real issue. Cool, my worries have been laid to rest! – Søren Boisen Jun 03 '15 at 08:50
  • The first statement of "No Consequences" is not entirely correct, visual studio or your build system may not clean output paths if you switch from debug to release, or x64 to x86. If they all go to the same folder, this may leave unwanted assemblies in the path that only manifest at runtime as "File Not Found" or "Image Format Exceptions" – StingyJack Dec 01 '17 at 20:37