2010/04/17

如何手動設定 Visual Studio 2010 的 VC++ Directories

主選單 -> Tools -> Options -> Projects and Solutions -> VC++ Directories,被告知此處不能編輯 VC++ Directories。不像 Visual Studio 2008 可以直接設定。
Visual_Studio_2010_VC++_Directories

我發現 VC++ Directories 的 path 預設值都儲存在一個檔案中,只要修改這個檔案將自己的 path 寫入,讓自己的 path 成為預設值的一部分。如此一來,開啟 projects 之後,你手動加入的 path 也會像預設 path 那樣被載入。

這個神祕的檔案共兩個,對於編譯 x86 和 x64 的程式各有一個對應的檔案。
x86:Microsoft.Cpp.Win32.v100.props

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\PlatformToolsets\v100\


x64:Microsoft.Cpp.x64.v100.props

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\PlatformToolsets\v100\


以 x86 為例。用記事本開啟 Microsoft.Cpp.Win32.v100.props,搜尋 </PropertyGroup>(只能找到一個),找到之後向上看。這些 path 就是 VC++ Directories 中預設的 path。

    <FrameworkVersion Condition="'$(UseEnv)' != 'true'">v4.0</FrameworkVersion>
    <Framework35Version Condition="'$(UseEnv)' != 'true'">v3.5</Framework35Version>

    <ExecutablePath Condition="'$(ExecutablePath)' == ''">$(VCInstallDir)bin;
    <IncludePath Condition="'$(IncludePath)' == ''">$(VCInstallDir)include;
    <ReferencePath Condition="'$(ReferencePath)' == ''">$(VCInstallDir)atlmfc\lib;
    <LibraryPath Condition="'$(LibraryPath)' == ''">$(VCInstallDir)lib;
    <SourcePath Condition="'$(SourcePath)' == ''">$(VCInstallDir)atlmfc\src\mfc;
    <ExcludePath Condition="'$(ExcludePath)' == ''">$(VCInstallDir)include;
    <NativeExecutablePath Condition="'$(NativeExecutablePath)' == ''">$(ExecutablePath)
  </PropertyGroup>


將你原本想要在 VC++ Directories 中加入的 path 加進去,優先使用左邊的 path,path 之間以分號隔開。範例,我只用過 IncludePath 和 LibraryPath,現在給它們加入偶自己的 path。

    <FrameworkVersion Condition="'$(UseEnv)' != 'true'">v4.0</FrameworkVersion>
    <Framework35Version Condition="'$(UseEnv)' != 'true'">v3.5</Framework35Version>

    <ExecutablePath Condition="'$(ExecutablePath)' == ''">$(VCInstallDir)bin;
    <IncludePath Condition="'$(IncludePath)' == ''">PATH1;PATH2;$(VCInstallDir)include;
    <ReferencePath Condition="'$(ReferencePath)' == ''">$(VCInstallDir)atlmfc\lib;
    <LibraryPath Condition="'$(LibraryPath)' == ''">PATH1;PATH2;$(VCInstallDir)lib;
    <SourcePath Condition="'$(SourcePath)' == ''">$(VCInstallDir)atlmfc\src\mfc;
    <ExcludePath Condition="'$(ExcludePath)' == ''">$(VCInstallDir)include;
    <NativeExecutablePath Condition="'$(NativeExecutablePath)' == ''">$(ExecutablePath)
  </PropertyGroup>

沒有留言 :

張貼留言