views:

671

answers:

0

I'd like to override the directories used by Visual Studio (devenv.exe) for the compiler and library paths. I know how to do this interactively via Tools->Options->VC++ Directories, but I'd like to automate this.

http://msdn.microsoft.com/en-us/library/t9az1d21(VS.80).aspx has a tantalizing note on this: "If you want to set up directory search paths (for your projects) that can be shared by other users or that can be applied across multiple computers, Visual C++ provides an alternative to using this dialog, through project property sheets. For more information, see Property Sheets (C++)."

If you follow the link to Property Sheets documentation, there's a bunch of information on the mechanism but none on the actual properties you need to set.

I found the information populated by the VC++ Directories dialog, in %LocalAppData%\Microsoft\VisualStudio\8.0\VCComponents.dat (for VS 2005, and 9.0 for VS 2008); it seems to set various properties under VC\VC_OBJECTS_PLATFORM_INFO\win32\Directories and ...\x64\Directories.

Has anyone done this before and know what the mapping is from the property names used in VCComponents.dat to the names to use in a .vsprops file?

I'd like this to work in VS2005, VS2008 and VS2010, ideally.

In VS2010, Microsoft has completely done away with the VC++ Directories dialog under View Options, made it per project, and so now you get an interactive UI for editing these directories in Project Properties instead of View Options; this also means that there's a UI for it in the properties manager; then if you want to make changes per-machine instead of per-project like it used to be, you just set a property sheet up the way you want, and make all your projects inherit from it. This sounds like a big improvement over the old way. And a direct way to do what I want to do. But only in VS2010.

VS2005 and VS2008 don't have the UI to do set these properties in a project or property sheet, though; I'm happy to do it by hand but I don't know what it's supposed to look like!

Here's an empty VS 2005 .vsprops file:

<?xml version="1.0"?>
<VisualStudioPropertySheet
    ProjectType="Visual C++"
    Version="8.00"
    Name="pathSettings"
    >
</VisualStudioPropertySheet>

I installed VS 2010 and used its neat new GUI to make changes in the search directories; it looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup>
    <ExecutablePath>C:\Test;$(PATH)</ExecutablePath>
  </PropertyGroup>
</Project>

However, that doesn't work verbatim in VS2005 -- VS2005 refuses to load it (complaining no DTD/schema declaration was found).

I plunked that into the container, in response to which VS2005 tells me "Element 'PropertyGroup' is unexpected according to content model of parent element 'VisualStudioPropertySheet'. Expecting: Tool, UserMacro." Tool and UserMacro are the only things shown in the example in the MSDN page [drat - StackOverflow won't let me as a new user put a hyperlink here -- first Google search result for 'property sheets tool usermacro'] -- maybe those are the only things legal in a VS2005 property sheet?