Skip to content

Commit 085882e

Browse files
authored
Enable proper tooling for localization (#1393)
1 parent 8bd530d commit 085882e

15 files changed

+31
-105
lines changed

Directory.Build.props

+9
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,13 @@
1616
<AnalysisLevel>preview</AnalysisLevel>
1717
</PropertyGroup>
1818

19+
<PropertyGroup>
20+
<!-- Disable Xlf localization by default. Project containing .resx file have to opt-in -->
21+
<EnableXlfLocalization>false</EnableXlfLocalization>
22+
</PropertyGroup>
23+
24+
<ItemGroup Condition=" '$(EnableXlfLocalization)' == 'true' ">
25+
<PackageReference Include="Microsoft.DotNet.XliffTasks" Version="$(XliffTasksVersion)" PrivateAssets="all" />
26+
</ItemGroup>
27+
1928
</Project>

azure-pipelines.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
displayName: 'Restore, Build and Package'
4040
inputs:
4141
filename: build.cmd
42-
arguments: '-configuration $(BuildConfiguration)'
42+
arguments: '-configuration $(BuildConfiguration) -CI'
4343
modifyEnvironment: false
4444

4545
- task: BatchScript@1

eng/Versions.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
<MicrosoftSourceLinkGitHubVersion>1.1.0-beta-21228-01</MicrosoftSourceLinkGitHubVersion>
125125
<MicrosoftSourceLinkAzureReposGitVersion>1.1.0-beta-21228-01</MicrosoftSourceLinkAzureReposGitVersion>
126126
<MicrosoftDotNetSwaggerGeneratorMSBuildVersion>8.0.0-beta.22554.2</MicrosoftDotNetSwaggerGeneratorMSBuildVersion>
127-
<XliffTasksVersion>1.0.0-beta.21265.1</XliffTasksVersion>
127+
<XliffTasksVersion>1.0.0-beta.22513.1</XliffTasksVersion>
128128
<MicrosoftDotNetMaestroTasksVersion>1.1.0-beta.21228.1</MicrosoftDotNetMaestroTasksVersion>
129129
<MicrosoftDotNetXHarnessCLIVersion>1.0.0-prerelease.21264.3</MicrosoftDotNetXHarnessCLIVersion>
130130
<MicrosoftSymbolUploaderBuildTaskVersion>1.1.156402</MicrosoftSymbolUploaderBuildTaskVersion>

scripts/Build.ps1

+7-12
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ Param(
3939
[Alias("cache")]
4040
[Switch] $ClearPackageCache,
4141

42-
[Alias("uxlf")]
43-
[Switch] $UpdateXlf,
44-
45-
[Alias("loc")]
46-
[Switch] $IsLocalizedBuild,
47-
4842
[Alias("tpv")]
4943
[string] $TestPlatformVersion = $null,
5044

@@ -54,6 +48,8 @@ Param(
5448
[Alias("f")]
5549
[Switch] $Force,
5650

51+
[switch] $CI,
52+
5753
[Alias("s")]
5854
[ValidateSet("InstallDotnet", "UpdateTPVersion", "Restore", "Build", "Pack")]
5955
[String[]] $Steps = @("InstallDotnet", "UpdateTPVersion", "Restore", "Build", "Pack")
@@ -76,8 +72,7 @@ $TFB_VersionSuffix = $VersionSuffix
7672
$TFB_BuildVersion = $BuildVersionPrefix + "." + $BuildVersionSuffix
7773
$TFB_Clean = $Clean
7874
$TFB_ClearPackageCache = $ClearPackageCache
79-
$TFB_UpdateXlf = $UpdateXlf
80-
$TFB_IsLocalizedBuild = $IsLocalizedBuild
75+
$TFB_CI = $CI;
8176
$TFB_BRANCH = "LOCALBRANCH"
8277
$TFB_COMMIT = "LOCALBUILD"
8378
try {
@@ -120,8 +115,6 @@ function Write-Help {
120115
Write-Host -object " Clean (-cl) - [switch] - Indicates that this should be a clean build."
121116
Write-Host -object " SkipRestore (-sr) - [switch] - Indicates nuget package restoration should be skipped."
122117
Write-Host -object " ClearPackageCache (-cache) - [switch] - Indicates local package cache should be cleared before restore."
123-
Write-Host -object " Updatexlf (-uxlf) - [switch] - Indicates that there are resource changes and that these need to be copied to other languages as well."
124-
Write-Host -object " IsLocalizedBuild (-loc) - [switch] - Indicates that the build needs to generate resource assemblies as well."
125118
Write-Host -object " DisallowPrereleaseMSBuild (-np) - [switch] - Uses an RTM version of MSBuild to build the projects"
126119
Write-Host -object ""
127120
Write-Host -object " Configuration (-c) - [string] - Specifies the build configuration. Defaults to 'Debug'."
@@ -205,8 +198,6 @@ function Invoke-MSBuild([string]$solution, $buildTarget = $Target, $hasVsixExten
205198
$argument = @("-t:$buildTarget",
206199
"-p:Configuration=$configuration",
207200
"-v:m",
208-
"-p:IsLocalizedBuild=$TFB_IsLocalizedBuild",
209-
"-p:UpdateXlf=$TFB_UpdateXlf",
210201
"-p:BuildVersion=$TFB_BuildVersion",
211202
"-p:BranchName=`"$TFB_BRANCH`"",
212203
"-p:CommitHash=$TFB_COMMIT",
@@ -217,6 +208,10 @@ function Invoke-MSBuild([string]$solution, $buildTarget = $Target, $hasVsixExten
217208
"-bl:`"$binLog`"",
218209
"-m")
219210

211+
if (-not $TFB_CI) {
212+
$argument += "-p:UpdateXlfOnBuild=true"
213+
}
214+
220215
Write-Log " $buildTarget`: $solution..."
221216
& {
222217
& "$msbuild" $argument;

scripts/build/TestFx.Loc.props

-75
This file was deleted.

scripts/build/TestFx.Sign.props

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)key.snk</AssemblyOriginatorKeyFile>
1313
<SignAssembly>true</SignAssembly>
1414
<SignType Condition=" '$(SignType)' == '' ">Test</SignType>
15-
<PublicSign Condition=" '$(IsLocalizedBuild)' == '' or '$(IsLocalizedBuild)' != 'true'">true</PublicSign>
16-
1715
<!-- Temporarily turning on Delay signing for Localized builds because publickey = true is not passed on to the assembler to create resource assmblies.-->
18-
<DelaySign Condition=" '$(IsLocalizedBuild)' == 'true' ">true</DelaySign>
16+
<DelaySign>true</DelaySign>
1917
<OutputPath Condition=" '$(OutputPath)' == '' ">$(RepoRoot)artifacts\$(Configuration)\$(MSBuildProjectName)\</OutputPath>
2018
</PropertyGroup>
2119
</Project>

scripts/build/TestFx.Sign.targets

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</SignFilesDependsOn>
2525
</ItemGroup>
2626

27-
<Target Name="GatherLocalizedOutputsForSigning" DependsOnTargets="TestFxLocalization" Condition=" '$(IsTest)' == 'false' and '$(IsLocalizationEnabled)' == 'true' ">
27+
<Target Name="GatherLocalizedOutputsForSigning" DependsOnTargets="TestFxLocalization" Condition=" '$(IsTest)' == 'false' ">
2828
<ItemGroup>
2929
<FilesToSign Include="$(OutDir)\**\$(AssemblyName).resources.dll">
3030
<Authenticode>Microsoft400</Authenticode>

scripts/build/TestFx.props

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<RepoRoot Condition=" '$(RepoRoot)' == '' ">$([MSBuild]::NormalizeDirectory('$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'LICENSE'))'))</RepoRoot>
55
<ArtifactsBinDir Condition=" '$(ArtifactsBinDir)' == '' ">$(RepoRoot)artifacts\$(Configuration)\</ArtifactsBinDir>
6-
<IsLocalizationEnabled Condition=" '$(UpdateXlf)' == 'true' or '$(IsLocalizedBuild)' == 'true' ">true</IsLocalizationEnabled>
76
<IsTest Condition="$(MSBuildProjectDirectory.Contains('\test\'))">true</IsTest>
87
<IsTest Condition=" '$(IsTest)' == '' ">false</IsTest>
98
</PropertyGroup>

scripts/build/TestFx.targets

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<!-- Import localization specific Targets if enabled. -->
4-
<Import Project="$(MSBuildThisFileDirectory)TestFx.Loc.props" Condition=" '$(IsTest)' == 'false' and '$(IsLocalizationEnabled)' == 'true' "/>
54
<Import Project="$(RepoRoot)scripts\build\TestFx.Sign.targets" Condition=" '$(TestFxSigningTargetsImported)' != 'true' " />
65

76
<!-- StyleCop settings. -->

src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ErrorReport>prompt</ErrorReport>
1313
<WarningLevel>4</WarningLevel>
1414
<Nullable>enable</Nullable>
15+
<EnableXlfLocalization>true</EnableXlfLocalization>
1516
</PropertyGroup>
1617

1718
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

src/Adapter/MSTestAdapter.PlatformServices/MSTestAdapter.PlatformServices.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<ErrorReport>prompt</ErrorReport>
1212
<WarningLevel>4</WarningLevel>
1313
<Nullable>enable</Nullable>
14+
<EnableXlfLocalization>true</EnableXlfLocalization>
1415
</PropertyGroup>
1516

1617
<!-- Properties specific to UWP -->

src/Package/MSTest.TestAdapter.nuspec

+2-3
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,8 @@
8282
<file src="MSTest.TestAdapter\net462\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll" target="build\net462\" />
8383

8484
<!-- Localization -->
85-
<file src="MSTest.TestAdapter\**\*.resources.dll" target="\build\_common\" />
86-
<file src="MSTestAdapter.PlatformServices\net462\**\*.resources.dll" target="\build\_common\" />
87-
<file src="TestFramework\**\*.resources.dll" target="build\_common\" />
85+
<!-- All TFMs share the same resx + TestAdapter depends on PlatformServices + TestFramework so all resources are available -->
86+
<file src="MSTest.TestAdapter\net462\**\*.resources.dll" target="\build\_common\" />
8887

8988
<!-- Icon -->
9089
<file src="Icon.png" target="" />

src/Package/MSTest.TestAdapter.symbols.nuspec

+2-3
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@
9191
<file src="MSTestAdapter.PlatformServices\net462\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.pdb" target="build\net462\" />
9292

9393
<!-- Localization -->
94-
<file src="MSTest.TestAdapter\**\*.resources.dll" target="\build\_common\" />
95-
<file src="MSTestAdapter.PlatformServices\net462\**\*.resources.dll" target="\build\_common\" />
96-
<file src="TestFramework\**\*.resources.dll" target="build\_common\" />
94+
<!-- All TFMs share the same resx + TestAdapter depends on PlatformServices + TestFramework so all resources are available -->
95+
<file src="MSTest.TestAdapter\net462\**\*.resources.dll" target="\build\_common\" />
9796

9897
<!-- Source code -->
9998
<file src="$srcroot$\**\*.cs" target="src" />

src/TestFramework/TestFramework/TestFramework.csproj

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ErrorReport>prompt</ErrorReport>
1313
<WarningLevel>4</WarningLevel>
1414
<Nullable>enable</Nullable>
15+
<EnableXlfLocalization>true</EnableXlfLocalization>
1516
</PropertyGroup>
1617

1718
<PropertyGroup>
@@ -29,13 +30,13 @@
2930
<DebugType>pdbonly</DebugType>
3031
<Optimize>true</Optimize>
3132
</PropertyGroup>
32-
33+
3334
<ItemGroup>
3435
<PackageReference Include="MicroBuild.Core" Version="$(MicroBuildCoreVersion)" PrivateAssets="all">
3536
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3637
</PackageReference>
3738
</ItemGroup>
38-
39+
3940
<ItemGroup>
4041
<AdditionalFiles Include="PublicAPI\PublicAPI.Shipped.txt" />
4142
<AdditionalFiles Include="PublicAPI\PublicAPI.Unshipped.txt" />
@@ -54,4 +55,4 @@
5455
<SubType>Designer</SubType>
5556
</EmbeddedResource>
5657
</ItemGroup>
57-
</Project>
58+
</Project>

test/E2ETests/TestAssets/Directory.Build.targets

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88

99
<ItemGroup>
1010
<ProjectCapability Remove="TestContainer" />
11-
</ItemGroup>
11+
</ItemGroup>
1212
</Project>

0 commit comments

Comments
 (0)