How to Organize Multiple .sln Files Under the Same Directory

In this post, let’s take a glimpse of how to organize multiple Visual Studio .sln files under the same directory.

Problem about Visual Studio .sln Files

For some occassions,  you may want to organize the file hierarchy of your Visual Studio projects as belove:

multi sln files

  • All the .sln files are sorted under the same directory, while all the .csproj files under another.
  • The dll file referenced by VS2005 and VS2008 is compiled from framework2.0, while the dll file referenced by VS2010, VS2012 and VS2013 is compiled from framework4.0.

If you organized your project file layer as above, you may get the expection as shown in the image below, when you:

  • Run the .sln file in VS2005 or VS2008 first, then try VS2010,VS2012 or VS2013.
  • Run the .sln file in VS2010,VS2012 or VS2013 first, then try VS2005 or VS2008.

Visual Studio exception

Solution for Multiple .sln Files

To fix the issue above, you need to make several modifications.

Modify  the relative path of .sln and .csproj file in asp.net as below:

modify path

Open .sln file and modify the info marked in red. If you want to put .sln and .csproj files in the same folder, just change “BarcodeGenerator\BarcodeGenerator_VS2010.csproj” –> “ BarcodeGenerator_VS2010.csproj “.

Modify the bin folder: Open .csproj file, modify the value of < OutputPath > under all , and make sure the OutputPath for every project is different. As such, they will not interfere with each other.

modify bin Modify the Obj folder: The Obj folder can only be modified manually. Open .csproj file, add the code below under every :

obj\obj_VS2010\ false

modify obj

  • If you only change the bin folder without changing obj folder, it will cause problems.

The bin folder is used to hold the results of the build outputs, and the obj folder is used to keep the temporary files created during compilation. These temporary files are preserved for an incremental build, during which the compiler can skip individual source files if they haven’t changed. Instead, using the temporary files is much faster.

  • Run VS2005 or VS2008 after the obj folder is modified, there will be a security warning as below:

load project

Just click ok button. The obj folder will change after compilation.