2011-10-17 3 views
3

에서 런타임 라이브러리 속성을 액세스 : Using Visual Studio project properties effectively for multiple projects and configurations이 기본적으로 후속 질문 비주얼 스튜디오 2010

우리 도서관의 대상 이름이 형식 현재 :

$(ProjectName)-$(PlatformToolset)-$(PlatformShortName)-$(Configuration) 

우리는 추가 할 프로젝트에서 대상 이름에 사용하는 런타임 라이브러리에 대한 정보, $(RuntimeLibrary)을 추가하려고 시도했지만 설정되지 않은 것 같습니다. 대상 이름이 해석 될 때 런타임 라이브러리를 가져 오는 다른 방법이 있습니까?

감사합니다. John.

답변

0

이 속성 시트를 사용하면이 작업을 수행 할 수 있습니다. 속성 시트에서 가져 오면 다음과 같이 RuntimeLibrary에 액세스 할 수 있습니다. $ (RuntimeLibrary)

예 !!! 이것은 귀하의 부동산 시트에서 사용할 수 있습니다.^~ ~ =

<?xml version="1.0" encoding="utf-8"?> 
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
    <PropertyGroup> 
     <_IsDebug>$([System.Convert]::ToString($([System.Text.RegularExpressions.Regex]::IsMatch($(Configuration),'[Dd]ebug'))))</_IsDebug> 

     <_ItemDefinitionGroupRegex><![CDATA[<ItemDefinitionGroup Condition=".*']]>$(Configuration)\|$(Platform)<![CDATA['">((?:.*\n)*?.*)</ItemDefinitionGroup>]]></_ItemDefinitionGroupRegex> 
     <_RuntimeLibraryRegex><![CDATA[(?:.*\n)*?.*<RuntimeLibrary>(.*)</RuntimeLibrary>(?:.*\n)*?.*]]></_RuntimeLibraryRegex> 

     <_HasRuntimeLibrary>$([System.Text.RegularExpressions.Regex]::IsMatch($([System.Text.RegularExpressions.Regex]::Match($([System.IO.File]::ReadAllText($(ProjectPath))), $(_ItemDefinitionGroupRegex)).Result('$1')), $(_RuntimeLibraryRegex)))</_HasRuntimeLibrary> 

     <!-- 
      Fix incremental build (Different results when running msbuild within Visual Studio or from console). 
      http://connect.microsoft.com/VisualStudio/feedback/details/677499/different-results-when-running-msbuild-within-visual-studio-or-from-console 
     --> 
     <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck> 
    </PropertyGroup> 

    <Choose> 
     <When Condition="$([System.Convert]::ToBoolean($(_HasRuntimeLibrary)))"> 
      <!-- Extract runtime library from project file. --> 
      <PropertyGroup Label="UserMacros"> 
       <_RuntimeLibrary>$([System.Text.RegularExpressions.Regex]::Match($([System.Text.RegularExpressions.Regex]::Match($([System.IO.File]::ReadAllText($(ProjectPath))), $(_ItemDefinitionGroupRegex)).Result('$1')), $(_RuntimeLibraryRegex)).Result('$1'))</_RuntimeLibrary> 
      </PropertyGroup> 
     </When> 
     <Otherwise> 
      <!-- Set default runtime library --> 
      <PropertyGroup Label="UserMacros"> 
       <_RuntimeLibrary Condition=" '$(_IsDebug)' == 'True' ">MultiThreadedDebugDLL</_RuntimeLibrary> 
       <_RuntimeLibrary Condition=" '$(_IsDebug)' == 'False' ">MultiThreadedDLL</_RuntimeLibrary> 
      </PropertyGroup> 
     </Otherwise> 
    </Choose> 

    <PropertyGroup Label="UserMacros"> 
     <IsDebug>$(_IsDebug)</IsDebug> 

     <ConfigType Condition=" '$(IsDebug)' == 'True' ">Debug</ConfigType> 
     <ConfigType Condition=" '$(IsDebug)' == 'False' ">Release</ConfigType> 

     <Architecture Condition=" '$(Platform)' == 'Win32' ">x86</Architecture> 
     <Architecture Condition=" '$(Platform)' == 'x64' ">x64</Architecture> 

     <Toolset Condition=" '$(PlatformToolset)' == 'v110' ">msvc.110</Toolset> 

     <RuntimeLibrary>$(_RuntimeLibrary)</RuntimeLibrary> 
    </PropertyGroup> 

    <ItemGroup> 
     <BuildMacro Include="IsDebug"> 
      <Value>$(IsDebug)</Value> 
     </BuildMacro> 
     <BuildMacro Include="Toolset"> 
      <Value>$(Toolset)</Value> 
     </BuildMacro> 
     <BuildMacro Include="Architecture"> 
      <Value>$(Architecture)</Value> 
     </BuildMacro> 
     <BuildMacro Include="RuntimeLibrary"> 
      <Value>$(RuntimeLibrary)</Value> 
     </BuildMacro> 
     <BuildMacro Include="ConfigType"> 
      <Value>$(ConfigType)</Value> 
     </BuildMacro> 
    </ItemGroup> 
</Project> 
관련 문제