Share via


Visual Studio Tip: Editing Project Files

Earlier I mentioned tweaking project files -- something that a lot of people do just by opening the project file up in Notepad and tweaking it.  Although it's a bit hard to discover, you can actually do this right within Visual Studio 2005, saving you from switching between applications, and more importantly buying you color coding and intellisense on the project file.

To enable this, first right click on the project in Solution Explorer and choose "Unload Project". 

Unload a project in Visual Studio

This will cause the project node to grey out and be marked unavailable.  You can now right click on it and choose "Edit <project file name>", which opens the project file up in the Visual Studio XML editor and loads the MSBuild schema up for you.

Edit a project in Visual Studio

Once you've made your changes, save the file, right click the project again and chose Reload Project.

Reload a project in Visual Studio

Visual Studio will prompt you to close the project document, and assuming there are no errors in the file, the project will reload and your changes will take effect.  If there was an error, Visual Studio will give you a dialog indicating which line and column the error was in and a brief description of what went wrong.

In addition to using this for accessing features not available via the UI (as I mentioned in the strong name key post), I also tweak project files to invoke some custom MSBuild tasks that I use in personal projects.

Comments

  • Anonymous
    April 26, 2006
    Fantastic tip. This is going to save me a heap of time when I need to change all my project level error / warning settings using Find and Replace in the IDE.

  • Anonymous
    April 27, 2006
    What version of Visual Studio does this tip work for?

  • Anonymous
    April 27, 2006
    This is in Visual Studio 2005.

    -Shawn

  • Anonymous
    April 28, 2006
    Shawn Farkas nous livre une astuce pour &#233;diter les fichiers csproj directement&#160;sous VS au lieu de d&#233;gainer...

  • Anonymous
    May 22, 2006
    PingBack from http://www.rosscode.com/blog/index.php?title=editing_project_files_the_easy_way&amp;more=1&amp;c=1&amp;tb=1&amp;pb=1

  • Anonymous
    February 20, 2007
    We all know that the CLR provides many types of evidence to assemblies and AppDomains by default, but

  • Anonymous
    February 20, 2007
    Hello, I was attempting to use these steps on a C# project in VS 2005. I am getting a different behavior than expected. I am not seeing the Unload project in my right click context menu. Any ideas?

  • Anonymous
    May 22, 2007
    @Glen Martin: I have the German and English version of VS 2005 installed. The menu entry only shows up, when I switch to the English version of VS.

  • Anonymous
    April 23, 2009
    Wow, what a nice post. Second, I want to answer Mr. Glen Martin that you can see the Unload Project option when you have more than one projects added in your Solution Explorer. You can add another project by following these steps.

  1. Goto File -> Add.
  2. Select New Project / Existing Project. After adding another project if you try again then you will see the Unload Project option.