Geeks With Blogs

News

Series

Add to Technorati Favorites


An Archived Managed World This blog has moved to http://www.managed-world.com/blog

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 | Back to top


Comments on this post: Visual Studio is now my servant

# re: Visual Studio is now my servant
Requesting Gravatar...
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
Left by ming.liu@brooks.com on Mar 24, 2004 11:48 AM

# re: Visual Studio is now my servant
Requesting Gravatar...
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 :(.
Left by Jason Olson on Mar 24, 2004 11:53 AM

# re: Visual Studio is now my servant
Requesting Gravatar...
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#?
Left by Christopher Kilmer on Oct 18, 2004 7:44 PM

# re: Visual Studio is now my servant
Requesting Gravatar...
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 :(.
Left by Jason Olson on Oct 18, 2004 8:30 PM

# re: Visual Studio is now my servant
Requesting Gravatar...
How to insert music file in Visual studio?
Left by NuLLCoDe on Jul 15, 2005 8:30 AM

# re: Visual Studio is now my servant
Requesting Gravatar...
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.
Left by Day Dreamer on Mar 07, 2006 2:57 AM

# re: Visual Studio is now my servant
Requesting Gravatar...
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>
Left by Day Dreamer on Mar 07, 2006 2:59 AM

# re: Visual Studio is now my servant
Requesting Gravatar...
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 :).
Left by Jason Olson on Mar 07, 2006 8:06 AM

# re: Visual Studio is now my servant
Requesting Gravatar...
brilliant....nice lead!!

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

<IntermediateOutputPath>C:\DevUnit2\dev_out\out\</IntermediateOutputPath>
Left by Argatxa on Jun 21, 2006 2:23 AM

# re: Visual Studio is now my servant
Requesting Gravatar...
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.
Left by daniel williams on Jun 23, 2006 4:54 AM

# re: Visual Studio is now my servant
Requesting Gravatar...
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
Left by Dipty on Mar 08, 2007 8:27 AM

# re: Visual Studio is now my servant
Requesting Gravatar...
How to insert video file in Visual studio?
Left by DS on Apr 16, 2007 8:13 AM

# re: Visual Studio is now my servant
Requesting Gravatar...
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!
Left by Drew on Jan 25, 2008 5:11 PM

# re: Visual Studio is now my servant
Requesting Gravatar...
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.
Left by M. on Mar 17, 2008 2:08 AM

# Send gifts to Pakistan
Requesting Gravatar...
Visual studio is taking priority over java so i am using it.
Left by Aslam on Oct 24, 2009 5:03 AM

# Sayal
Requesting Gravatar...
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.
Left by Designer christmas cards on Oct 30, 2009 9:14 PM

# Stop Foreclosure Florida
Requesting Gravatar...
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.
Left by floridashort on Nov 02, 2009 7:44 PM

# floridashort
Requesting Gravatar...
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.
Left by Stop Foreclosure Florida on Nov 02, 2009 7:45 PM

# anewcompany
Requesting Gravatar...
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.
Left by Register Limited Company on Nov 03, 2009 11:34 PM

# villagekids
Requesting Gravatar...
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.
Left by Girls Designer Clothes on Nov 04, 2009 11:51 PM

# Bean Katie
Requesting Gravatar...
DCS Services is a full service general construction manager. Our resources and capabilities make us a single source of construction services for a wide variety of clients.landscaping & builders in Essex, fitted kitchens, bedrooms & bathrooms are just a few available services.
Left by Fitted Bathrooms on Nov 30, 2009 7:18 PM

# calgary photographers
Requesting Gravatar...
If you are looking for stunning, award winning wedding photography that uses a fusion of photojournalism, candid, posed and artistic photography styles using dramatic lighting, we at JT images Wedding Photography are here to serve you.
Left by jtimages on Nov 30, 2009 10:11 PM

# smith406
Requesting Gravatar...
Get New York Delis - NY Deli foods, Ny deli corned beef, Buy NY deli gift boxes, passover platters NY, Rosh hashannah platters delivered, Chanukah platters delivered, Yom kippur platters delivered and passover platters delivered - ChutzpahDeli, NY
Left by Order deli food online on Dec 18, 2009 11:29 PM

# Ravidalingerie
Requesting Gravatar...
Ravida luxury and designer lingerie including bra sets, bridal nightwear, women’s nightwear, wedding underwear, designer corsets, baby dolls and chemises, luxury nightclothes for women and lingerie accessories by Ravida Lingerie.
Left by Designer Lingerie on Dec 21, 2009 7:28 PM

# John Smith
Requesting Gravatar...
Offers dental equipment supplies &amp; repair services in Nj including Detal office design, dental equipment financing, office construction, dental handpiece repair, autoclave repair, dental statim repairs, dental practice acquisitions and dental practice transitions in Nj, Pa, De - Parkwaydental.com
Left by Dental Practice Acquisitions on Dec 22, 2009 10:51 PM

# re: Visual Studio is now my servant
Requesting Gravatar...

At Gulfcoast Home Buyer Services we work to preserve the dream of home ownership for those who are looking to buy a house or experiencing the financial and emotional duress associated with an unwanted or financially unstable property.Lee County Cape Coral Fort Myers Home short sale Help
Left by lee county short sale on Mar 02, 2010 12:40 PM

# Stop Foreclosure Florida
Requesting Gravatar...

property,Lee County,Cape Coral,Fort Myers,Home,short sale Foreclosure,Help
Left by lee county short sale on Mar 02, 2010 12:42 PM

# Tastemystyle fashion photographer
Requesting Gravatar...
I'm Photographer Work a lot in Florida and love to use great furniture
Willing to travel/ Love to Travel meet new and Interesting people.
I'm Open to any Ideas, and projects..
Feel Free to Go to my site to see more work
Left by lee county short sale on Mar 02, 2010 12:43 PM

# re: Visual Studio is now my servant
Requesting Gravatar...
Assure Processing providing Offshore merchant account processing, Offshore credit card processing, Offshore virtual terminal processing and Offshore debit card processing to those businesses that the mainstream usa based companies won't process.
Left by Offshore merchant account proces on Mar 16, 2010 4:35 AM

# re: Visual Studio is now my servant
Requesting Gravatar...
Freelance Web Design and SEO Expert
Left by Website Solution on Mar 16, 2010 4:39 AM

# Jaipur Hotels
Requesting Gravatar...
Jaipurhotelsgroup.com a leading online hotel network for online reservation & instant booking of hotels in Jaipur and Rajasthan.
Left by Jennifer Lopez on May 04, 2010 10:57 PM

# re: Visual Studio is now my servant
Requesting Gravatar...
Delhihotelsgroups.com offering cheap hotel Delhi, Delhi hotels reservations,online hotel booking in Delhi, luxury hotel Delhi, discount hotels in Delhi and accommodation in Delhi. Enjoy the luxury, healthy and comfort hospitality of the best known hotels of Delhi with us.Get more information here : http://www.delhihotelsgroup.com/
Left by Delhi Hotel Group on May 05, 2010 1:16 AM

# Chelsea Clinton
Requesting Gravatar...
Online travel agents and India tour operator provides services for Indian holidays,custom & luxury tour packages India and India travel guide including Hotels bookings & Holiday Packages,Royal weddings in India.
Left by India Travel on May 06, 2010 5:29 PM

# Jennifer Lopez
Requesting Gravatar...
To know more about hotels in goa, Goa Hotels, Hotels in Goa, Goa Hotel Deals, Budget Hotels Goa, Goa Beach Resorts Luxury Hotels to standard budget hotels and their respective locations.
Left by Hotels in Goa on May 10, 2010 9:08 PM

# re: Visual Studio is now my servant
Requesting Gravatar...
Kerela-hotels.com offering cheap hotel Kerala, Kerala hotels reservations, hotel booking in Kerala, luxury hotel Kerala, discount hotels in Kerala and accommodation in Kerala. Enjoy the luxury, healthy and comfort hospitality of the best known hotels of Kerala with us.
Left by Kerelahotelgroup on May 10, 2010 11:12 PM

# re: Visual Studio is now my servant
Requesting Gravatar...
Fantastic read, thanks for providing this interesting article. Thank you.
Left by Ben 10 Games on May 24, 2010 3:57 AM

# City of Colored Gemstones and Jewellery
Requesting Gravatar...
Jaipur is India’s second important gems and jewellery exporting centre and the first for sales to foreign tourists. With a history dating back to more than two and a half centuries, the famed Indian Gems City of Jaipur is still a hotspot in Gems 'n' Jewellery.
Left by Hand Maded Gold Jewelry on Jun 15, 2010 8:04 PM

# re: Visual Studio is now my servant
Requesting Gravatar...
This will remove obj folder:
put it to post-build scripts

REM This removes the unused annoying obj folder after build.
rd "$(ProjectDir)obj" /S /Q
Left by Antal Dominik on Sep 10, 2010 6:08 AM

# re: Visual Studio is now my servant
Requesting Gravatar...
Designer Lingerie. Ravida luxury and designer lingerie [url=http://www.magiceve.com]wholesale Lingerie[/url] online lingerie shop .including bra sets, bridal nightwear.
Left by Magiceve on Nov 23, 2010 9:39 PM

# re: Visual Studio is now my servant
Requesting Gravatar...
Fantastic read, thanks for providing this interesting article. Thank you.
Left by ensuite on Nov 30, 2010 11:57 AM

# re: Visual Studio is now my servant
Requesting Gravatar...
Thanks for article..
Left by Turkey Economy News on Dec 21, 2010 3:14 PM

# re: Visual Studio is now my servant
Requesting Gravatar...
helpful information about visual Studio to use the directory structure
Left by Keylogger on Jun 06, 2012 1:08 AM

Your comment:
 (will show your gravatar)


Copyright © Jason Olson | Powered by: GeeksWithBlogs.net