An Archived Managed World

This blog has moved to http://www.managed-world.com/blog

  Home  |   Contact  |   Syndication    |   Login
  473 Posts | 0 Stories | 429 Comments | 1288 Trackbacks

News

Twitter












Tag Cloud


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.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
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.

# Bean Katie 11/30/2009 7:18 PM Fitted Bathrooms
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.

# calgary photographers 11/30/2009 10:11 PM jtimages
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.

# smith406 12/18/2009 11:29 PM Order deli food online
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

# Ravidalingerie 12/21/2009 7:28 PM Designer Lingerie
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.

# John Smith 12/22/2009 10:51 PM Dental Practice Acquisitions
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

# re: Visual Studio is now my servant 3/2/2010 12:40 PM lee county short sale

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

# Stop Foreclosure Florida 3/2/2010 12:42 PM lee county short sale

property,Lee County,Cape Coral,Fort Myers,Home,short sale Foreclosure,Help

# Tastemystyle fashion photographer 3/2/2010 12:43 PM lee county short sale
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

# re: Visual Studio is now my servant 3/16/2010 4:35 AM Offshore merchant account proces
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.

# re: Visual Studio is now my servant 3/16/2010 4:39 AM Website Solution
Freelance Web Design and SEO Expert

# Jaipur Hotels 5/4/2010 10:57 PM Jennifer Lopez
Jaipurhotelsgroup.com a leading online hotel network for online reservation & instant booking of hotels in Jaipur and Rajasthan.

# re: Visual Studio is now my servant 5/5/2010 1:16 AM Delhi Hotel Group
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/


# Chelsea Clinton 5/6/2010 5:29 PM India Travel
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.

# Jennifer Lopez 5/10/2010 9:08 PM Hotels in Goa
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.

# re: Visual Studio is now my servant 5/10/2010 11:12 PM Kerelahotelgroup
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.


# re: Visual Studio is now my servant 5/24/2010 3:57 AM Ben 10 Games
Fantastic read, thanks for providing this interesting article. Thank you.

# City of Colored Gemstones and Jewellery 6/15/2010 8:04 PM Hand Maded Gold Jewelry
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.

# re: Visual Studio is now my servant 9/10/2010 6:08 AM Antal Dominik
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

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

# re: Visual Studio is now my servant 11/30/2010 11:57 AM ensuite
Fantastic read, thanks for providing this interesting article. Thank you.

# re: Visual Studio is now my servant 12/21/2010 3:14 PM Turkey Economy News
Thanks for article..

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