MSTest.TestAdapter.targets 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  3. <PropertyGroup>
  4. <EnableMSTestV2CopyResources Condition=" '$(EnableMSTestV2CopyResources)' == '' ">true</EnableMSTestV2CopyResources>
  5. </PropertyGroup>
  6. <Target Name="GetMSTestV2CultureHierarchy">
  7. <!-- Only traversing 5 levels in the culture hierarchy. This is the maximum lenght for all cultures and should be sufficient to get to a culture name that maps to a resource folder we package.
  8. The root culture name for all cultures is invariant whose name is ''(empty) and the parent for invariant culture is invariant itself.(https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.parent(v=vs.110).aspx.)
  9. So the below code should not break build in any case. -->
  10. <ItemGroup>
  11. <CurrentUICultureHierarchy Include="$([System.Globalization.CultureInfo]::CurrentUICulture.Name)" />
  12. <CurrentUICultureHierarchy Include="$([System.Globalization.CultureInfo]::CurrentUICulture.Parent.Name)" Condition=" '$([System.Globalization.CultureInfo]::CurrentUICulture.Parent.Name)' != '' "/>
  13. <CurrentUICultureHierarchy Include="$([System.Globalization.CultureInfo]::CurrentUICulture.Parent.Parent.Name)" Condition=" '$([System.Globalization.CultureInfo]::CurrentUICulture.Parent.Parent.Name)' != '' "/>
  14. <CurrentUICultureHierarchy Include="$([System.Globalization.CultureInfo]::CurrentUICulture.Parent.Parent.Parent.Name)" Condition=" '$([System.Globalization.CultureInfo]::CurrentUICulture.Parent.Parent.Parent.Name)' != '' "/>
  15. <CurrentUICultureHierarchy Include="$([System.Globalization.CultureInfo]::CurrentUICulture.Parent.Parent.Parent.Parent.Name)" Condition=" '$([System.Globalization.CultureInfo]::CurrentUICulture.Parent.Parent.Parent.Parent.Name)' != '' "/>
  16. </ItemGroup>
  17. </Target>
  18. <!-- Copy resources over to $(TargetDir) if this is a localized build. -->
  19. <Target Name="CopyMSTestV2Resources" BeforeTargets="PrepareForBuild" Condition=" '$(EnableMSTestV2CopyResources)' == 'true' " DependsOnTargets="GetMSTestV2CultureHierarchy">
  20. <PropertyGroup>
  21. <CurrentUICultureHierarchy>%(CurrentUICultureHierarchy.Identity)</CurrentUICultureHierarchy>
  22. </PropertyGroup>
  23. <ItemGroup>
  24. <MSTestV2Files Include="$(MSBuildThisFileDirectory)..\_common\*.dll" />
  25. </ItemGroup>
  26. <ItemGroup>
  27. <Content Include="@(MSTestV2Files->'%(RootDir)%(Directory)$(CurrentUICultureHierarchy)\%(FileName).resources.dll')"
  28. Condition="Exists('%(RootDir)%(Directory)$(CurrentUICultureHierarchy)\%(FileName).resources.dll')">
  29. <Link>$(CurrentUICultureHierarchy)\%(FileName).resources.dll</Link>
  30. <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  31. <BaseAssemblyFullPath>%(FullPath)</BaseAssemblyFullPath>
  32. <Visible>False</Visible>
  33. </Content>
  34. </ItemGroup>
  35. </Target>
  36. </Project>