Managed World

An Odyssey Through The Land Of Geekdom With jolson88

  Home  |   Contact  |   Syndication    |   Login
  472 Posts | 0 Stories | 334 Comments | 1295 Trackbacks

News

Twitter












Archives

Post Categories

Blog Roll

You might remember my earlier post when I was complaining about the structure of files in Visual Studio. After a little research, I have discovered how to “convince” Visual Studio to use the directory structure I would like it to. The goal of this is to turn a directory structure like this (Visual Studio's default):

  • Solution/
    • Project/
      • Bin/
        • Debug/
        • Release/

to this:

  • Solution/
    • Project/
      • bin/   ** compiler output for release builds **
      • src/
      • test/  ** compiler output for debug builds **

The purpose of this is to prevent the compiler output from residing in a subdirectory of the source files. In the future, this should make the source files easier to maintain (i.e. branch, merge, tag, etc.). The inspiration of the directory comes from a lot of linux projects that I have seen lately. I find it a much easier directory structure to deal with, especially in regard to source control.

It was surprisingly easy to make Visual Studio do it this way. It wasn't exactly intuitive, hence the reason for this post. I set out from the get-go to try to make Visual Studio do it this way because I already knew how to do it from the command line and in project settings. However, it is a pain-in-the-rear to add a project to a solution and then use Windows Explorer or the command line to change the directory the source files reside in and then change the solution file to point to the new directory. Not only that, but the last thing I want to do is to be forced to change the project properties everytime I add a new project to point to the new debug and release directories.

Now, for the directions. The first step is to get Visual Studio to put the project file and source files into a directory called “src” instead of a directory with the project name. The first step is to open the common.js file located in “C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\VC#Wizards\1033” (I am assuming you have Visual Studio 2003 and installed it in the default directory). ** disclaimer: backup these files before altering them. I will not be responsible for anyone hosing their Visual Studio install ** Go to line 439 in the file, it should read “// Make sure user sees ui.” and should be in the function called CreateCSharpProject. Insert the following lines of code before this line and in the try block:

// Only put in src directory if this isn't a web project
if(strProjectPath.search("http://") != 0)
   strProjectPath = strProjectPath + "
\\src";

Save that file and close your editor. The next step is to change the default build directories for debug and release builds in the various CSharp project templates. In order to that, change the OutputPath for the debug build from ".\Bin\Debug" to "..\test". And change the OutputPath for the release build from ".\Bin\Release" to "..\bin". The OutputPath is changed in the following files (located in the "C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\VC#Wizards” folder):

  • default.csproj
  • DefaultDll.csproj
  • DefaultWinExe.csproj

I should probably say that this is probably not supported by Microsoft as I am changing the directory structure pretty significantly. In closing, I think it is pretty cool that Visual Studio is extensible enough for this to be done. I was getting kind of disappointed, thinking that I was going to have to give up and play the way Microsoft wants me to play. So, three cheers for Microsoft for all the hard work put into this product. I look forward to seeing where Orcas goes when it is released.

posted on Thursday, November 20, 2003 6:53 PM

Feedback

# re: Visual Studio is now my servant 3/24/2004 11:48 AM ming.liu@brooks.com
I was looking for a way to change the temporary output files in obj subfolder to a folder outside the project folder, and found your article.

Your approach changes the source code and bin directory only, but not the obj directory. The obj directory is now automatically moved to src directory. I looked at the common.js file and couldn't see anything related to the obj folder. Do you have better idea? I can't find any place in VS to change the obj folder.

Thank you very much and regards,
Ming

# re: Visual Studio is now my servant 3/24/2004 11:53 AM Jason Olson
Unfortunately, I don't believe this is possible in C# or VB.NET. I was also unable to find away to move the obj folder in these languages. This is possible in C++ projects though. Too bad. I find it a bit annoying to have the obj folder in my source tree. If I find anything in the future, I will for sure update the post. Sorry I don't have better news for you :(.

# re: Visual Studio is now my servant 10/18/2004 7:44 PM Christopher Kilmer
You're last post on this subject was from quite awhile ago. I'm wondering if you ever found a way to change the obj folder to a new path in C#?

# re: Visual Studio is now my servant 10/18/2004 8:30 PM Jason Olson
Hey Christopher, I didn't look into it again for a while until recently. I got the urge to see if I could find away now and it appears that still with Visual Studio 2003 there is no way to change the obj path. I have just let if and the build directories the way Visual Studio likes and have just informed Source Control to ignore these directories. I don't like doing that, but it appears to be what I have to settle for. It's a bummer too. You can do it in C++, just not C# or VB. Bummer. Sorry for the bad news :(.

# re: Visual Studio is now my servant 7/15/2005 8:30 AM NuLLCoDe
How to insert music file in Visual studio?

# re: Visual Studio is now my servant 3/7/2006 2:57 AM Day Dreamer
In VS 2005, you can update the "OutDir" property in .csproj files to specify the path where you want the "obj" directory and its contents to get created.

# re: Visual Studio is now my servant 3/7/2006 2:59 AM Day Dreamer
An example for the previous comment:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
.......
<OutDir>C:\DevUnit2\dev_out\out\</OutDir>
<UseHostCompilerIfAvailable>false</UseHostCompilerIfAvailable>
<BaseIntermediateOutputPath>C:\DevUnit2\dev_out\out\</BaseIntermediateOutputPath>
</PropertyGroup>

# re: Visual Studio is now my servant 3/7/2006 8:06 AM Jason Olson
Ah, that's good to know Day Dreamer. (Just to clarify, the post was originally talking about VS.NET 2002/2003 :)). I'll have to make that change in my MSBuild scripts now :).

# re: Visual Studio is now my servant 6/21/2006 2:23 AM Argatxa
brilliant....nice lead!!

following it I discovered that you will need to set IntermediateOutputPath too...

<IntermediateOutputPath>C:\DevUnit2\dev_out\out\</IntermediateOutputPath>

# re: Visual Studio is now my servant 6/23/2006 4:54 AM daniel williams
Does anyone know how to get the Project Template to add certain refernces when generating the new project? I have a common set of references that are always used in my projects, and would like to not have to add them by hand every time.

# re: Visual Studio is now my servant 3/8/2007 8:27 AM Dipty
Hi
I tried using the <IntermediateOutputPath> tag. It creates the obj in the folder specified here but it creates a copy in default location too ...any suggestions please.
Thanks

# re: Visual Studio is now my servant 4/16/2007 8:13 AM DS
How to insert video file in Visual studio?

# re: Visual Studio is now my servant 1/25/2008 5:11 PM Drew
Great stuff.

I did this with my project (I had to create the tags in my case) but I have a single rogue file being created at obj\projectName.csproj.FileList.txt

Any clues on this file and out to get it to follow its sisters?

Thanks!

# re: Visual Studio is now my servant 3/17/2008 2:08 AM M.
This doesn't seem to work for me in VS2008. Do you know if this still works?

Perhaps ("I wish") there is actually a rational way to do this within the IDE, but I haven't found it.

# printing photos to canvas 11/10/2008 3:34 AM http://www.momentz.com.au
The canvas print we provide is printed only quality ink and this will last 75+ years with more durable and indefinitely lasting product at no extra cost with 30 day money-back guarantee.

# Leading Jewish Organization 8/26/2009 6:47 PM http://bbyo.org/
BBYO is a leading Jewish organization providing exceptional identity enrichment and leadership development experiences for hundreds of thousands of Jewish teens.

# Send gifts to Pakistan 10/24/2009 5:03 AM Aslam
Visual studio is taking priority over java so i am using it.

# Sayal 10/30/2009 9:14 PM Designer christmas cards
Offer the largest range of cards which includes designer christmas cards, company christmas cards, corporate christmas cards, charity company xmas cads and christmas card printers at the very best prices from Printed-Charity-Christmas-Cards.co.uk.

# Stop Foreclosure Florida 11/2/2009 7:44 PM floridashort
Florida Short Sale Help to stop foreclosure and save your credit. Work with us to avoid foreclosure and keep your home & prevent foreclosure With Florida short sale specialist. Floridashortsaleshelp.com - help you with your short sale locally in Florida. We have experience in the short sale process and along with a local attorney can provide the best chance of getting you out of your home as easily as possible. When you are looking for a company to help you with your home or condo you want trustworthy and ethical people helping.

# floridashort 11/2/2009 7:45 PM Stop Foreclosure Florida
Florida Short Sale Help to stop foreclosure and save your credit. Work with us to avoid foreclosure and keep your home & prevent foreclosure With Florida short sale specialist. Floridashortsaleshelp.com - help you with your short sale locally in Florida. We have experience in the short sale process and along with a local attorney can provide the best chance of getting you out of your home as easily as possible. When you are looking for a company to help you with your home.

# anewcompany 11/3/2009 11:34 PM Register Limited Company
New Company Group are one of the UK's leading online company formation agents offering new company formation, company VAT registration, company registration, company secretary, domain name registration, company searches and company information services in UK.

# villagekids 11/4/2009 11:51 PM Girls Designer Clothes
Village Kids is a shop with a friendly atmosphere and was established in 1992. It is situated in Bexley Village on the south east borders of London. Although the village is not rural it still retains a good village feel. There is ample car parking around the village and our shop is within 100 meters from Bexley Station which is a 40 minute ride from Charing Cross.

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: