It’s a small thing, this one – but not a lot of people seem to know about it, so I thought I’d add it in here.
It’s not uncommon that I find myself wanting to hack at a .csproj or .vbproj file directly (for example, to set a dependency between a XAML file and its code behind file, or simply to rename the code-behind file). As you probably know, in Visual Studio 2005 we revamped the build system with the introduction of a new technology called MSBuild. Project files are now XML descriptions of the various files, dependencies and property settings that make up an application, along with a means to describe how an individual file type gets built. (More details in this month’s MSDN Magazine.)
Unfortunately, you can’t just right-click on the project file in Visual Studio and choose “edit”, which means that quite a lot of the advanced customization capabilities are opaque from the developer environment. In our customer labs, I therefore frequently see people who have opened Notepad to edit the project file, but of course Notepad is hardly the pinnacle of developer editors.
So here’s how to edit a project file within Visual Studio 2005:
- Open the solution that you’re working with
- Right-click the specific project that you want to edit
- Choose Unload Project
- Right-click the project again
- Choose Edit <project name>
- Ooh and aah at the MSBuild Intellisense and tooltip help
- Save the project
- Right-click the project file and choose Reload Project
Simple when you know how, isn’t it?