Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable proper tooling for localization #1393

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,13 @@
<AnalysisLevel>preview</AnalysisLevel>
</PropertyGroup>

<PropertyGroup>
<!-- Disable Xlf localization by default. Project containing .resx file have to opt-in -->
<EnableXlfLocalization>false</EnableXlfLocalization>
</PropertyGroup>

<ItemGroup Condition=" '$(EnableXlfLocalization)' == 'true' ">
<PackageReference Include="Microsoft.DotNet.XliffTasks" Version="$(XliffTasksVersion)" PrivateAssets="all" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
displayName: 'Restore, Build and Package'
inputs:
filename: build.cmd
arguments: '-configuration $(BuildConfiguration)'
arguments: '-configuration $(BuildConfiguration) -CI'
modifyEnvironment: false

- task: BatchScript@1
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
<MicrosoftSourceLinkGitHubVersion>1.1.0-beta-21228-01</MicrosoftSourceLinkGitHubVersion>
<MicrosoftSourceLinkAzureReposGitVersion>1.1.0-beta-21228-01</MicrosoftSourceLinkAzureReposGitVersion>
<MicrosoftDotNetSwaggerGeneratorMSBuildVersion>8.0.0-beta.22554.2</MicrosoftDotNetSwaggerGeneratorMSBuildVersion>
<XliffTasksVersion>1.0.0-beta.21265.1</XliffTasksVersion>
<XliffTasksVersion>1.0.0-beta.22513.1</XliffTasksVersion>
<MicrosoftDotNetMaestroTasksVersion>1.1.0-beta.21228.1</MicrosoftDotNetMaestroTasksVersion>
<MicrosoftDotNetXHarnessCLIVersion>1.0.0-prerelease.21264.3</MicrosoftDotNetXHarnessCLIVersion>
<MicrosoftSymbolUploaderBuildTaskVersion>1.1.156402</MicrosoftSymbolUploaderBuildTaskVersion>
Expand Down
19 changes: 7 additions & 12 deletions scripts/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ Param(
[Alias("cache")]
[Switch] $ClearPackageCache,

[Alias("uxlf")]
[Switch] $UpdateXlf,

[Alias("loc")]
[Switch] $IsLocalizedBuild,

[Alias("tpv")]
[string] $TestPlatformVersion = $null,

Expand All @@ -54,6 +48,8 @@ Param(
[Alias("f")]
[Switch] $Force,

[switch] $CI,

[Alias("s")]
[ValidateSet("InstallDotnet", "UpdateTPVersion", "Restore", "Build", "Pack")]
[String[]] $Steps = @("InstallDotnet", "UpdateTPVersion", "Restore", "Build", "Pack")
Expand All @@ -76,8 +72,7 @@ $TFB_VersionSuffix = $VersionSuffix
$TFB_BuildVersion = $BuildVersionPrefix + "." + $BuildVersionSuffix
$TFB_Clean = $Clean
$TFB_ClearPackageCache = $ClearPackageCache
$TFB_UpdateXlf = $UpdateXlf
$TFB_IsLocalizedBuild = $IsLocalizedBuild
$TFB_CI = $CI;
$TFB_BRANCH = "LOCALBRANCH"
$TFB_COMMIT = "LOCALBUILD"
try {
Expand Down Expand Up @@ -120,8 +115,6 @@ function Write-Help {
Write-Host -object " Clean (-cl) - [switch] - Indicates that this should be a clean build."
Write-Host -object " SkipRestore (-sr) - [switch] - Indicates nuget package restoration should be skipped."
Write-Host -object " ClearPackageCache (-cache) - [switch] - Indicates local package cache should be cleared before restore."
Write-Host -object " Updatexlf (-uxlf) - [switch] - Indicates that there are resource changes and that these need to be copied to other languages as well."
Write-Host -object " IsLocalizedBuild (-loc) - [switch] - Indicates that the build needs to generate resource assemblies as well."
Write-Host -object " DisallowPrereleaseMSBuild (-np) - [switch] - Uses an RTM version of MSBuild to build the projects"
Write-Host -object ""
Write-Host -object " Configuration (-c) - [string] - Specifies the build configuration. Defaults to 'Debug'."
Expand Down Expand Up @@ -205,8 +198,6 @@ function Invoke-MSBuild([string]$solution, $buildTarget = $Target, $hasVsixExten
$argument = @("-t:$buildTarget",
"-p:Configuration=$configuration",
"-v:m",
"-p:IsLocalizedBuild=$TFB_IsLocalizedBuild",
"-p:UpdateXlf=$TFB_UpdateXlf",
"-p:BuildVersion=$TFB_BuildVersion",
"-p:BranchName=`"$TFB_BRANCH`"",
"-p:CommitHash=$TFB_COMMIT",
Expand All @@ -217,6 +208,10 @@ function Invoke-MSBuild([string]$solution, $buildTarget = $Target, $hasVsixExten
"-bl:`"$binLog`"",
"-m")

if (-not $TFB_CI) {
$argument += "-p:UpdateXlfOnBuild=true"
}

Write-Log " $buildTarget`: $solution..."
& {
& "$msbuild" $argument;
Expand Down
75 changes: 0 additions & 75 deletions scripts/build/TestFx.Loc.props

This file was deleted.

4 changes: 1 addition & 3 deletions scripts/build/TestFx.Sign.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)key.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<SignType Condition=" '$(SignType)' == '' ">Test</SignType>
<PublicSign Condition=" '$(IsLocalizedBuild)' == '' or '$(IsLocalizedBuild)' != 'true'">true</PublicSign>

<!-- Temporarily turning on Delay signing for Localized builds because publickey = true is not passed on to the assembler to create resource assmblies.-->
<DelaySign Condition=" '$(IsLocalizedBuild)' == 'true' ">true</DelaySign>
<DelaySign>true</DelaySign>
<OutputPath Condition=" '$(OutputPath)' == '' ">$(RepoRoot)artifacts\$(Configuration)\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion scripts/build/TestFx.Sign.targets
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</SignFilesDependsOn>
</ItemGroup>

<Target Name="GatherLocalizedOutputsForSigning" DependsOnTargets="TestFxLocalization" Condition=" '$(IsTest)' == 'false' and '$(IsLocalizationEnabled)' == 'true' ">
<Target Name="GatherLocalizedOutputsForSigning" DependsOnTargets="TestFxLocalization" Condition=" '$(IsTest)' == 'false' ">
<ItemGroup>
<FilesToSign Include="$(OutDir)\**\$(AssemblyName).resources.dll">
<Authenticode>Microsoft400</Authenticode>
Expand Down
1 change: 0 additions & 1 deletion scripts/build/TestFx.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<RepoRoot Condition=" '$(RepoRoot)' == '' ">$([MSBuild]::NormalizeDirectory('$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'LICENSE'))'))</RepoRoot>
<ArtifactsBinDir Condition=" '$(ArtifactsBinDir)' == '' ">$(RepoRoot)artifacts\$(Configuration)\</ArtifactsBinDir>
<IsLocalizationEnabled Condition=" '$(UpdateXlf)' == 'true' or '$(IsLocalizedBuild)' == 'true' ">true</IsLocalizationEnabled>
<IsTest Condition="$(MSBuildProjectDirectory.Contains('\test\'))">true</IsTest>
<IsTest Condition=" '$(IsTest)' == '' ">false</IsTest>
</PropertyGroup>
Expand Down
1 change: 0 additions & 1 deletion scripts/build/TestFx.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Import localization specific Targets if enabled. -->
<Import Project="$(MSBuildThisFileDirectory)TestFx.Loc.props" Condition=" '$(IsTest)' == 'false' and '$(IsLocalizationEnabled)' == 'true' "/>
<Import Project="$(RepoRoot)scripts\build\TestFx.Sign.targets" Condition=" '$(TestFxSigningTargetsImported)' != 'true' " />

<!-- StyleCop settings. -->
Expand Down
1 change: 1 addition & 0 deletions src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Nullable>enable</Nullable>
<EnableXlfLocalization>true</EnableXlfLocalization>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Nullable>enable</Nullable>
<EnableXlfLocalization>true</EnableXlfLocalization>
</PropertyGroup>

<!-- Properties specific to UWP -->
Expand Down
5 changes: 2 additions & 3 deletions src/Package/MSTest.TestAdapter.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@
<file src="MSTest.TestAdapter\net462\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll" target="build\net462\" />

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

<!-- Icon -->
<file src="Icon.png" target="" />
Expand Down
5 changes: 2 additions & 3 deletions src/Package/MSTest.TestAdapter.symbols.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@
<file src="MSTestAdapter.PlatformServices\net462\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.pdb" target="build\net462\" />

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

<!-- Source code -->
<file src="$srcroot$\**\*.cs" target="src" />
Expand Down
7 changes: 4 additions & 3 deletions src/TestFramework/TestFramework/TestFramework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Nullable>enable</Nullable>
<EnableXlfLocalization>true</EnableXlfLocalization>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -29,13 +30,13 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MicroBuild.Core" Version="$(MicroBuildCoreVersion)" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="PublicAPI\PublicAPI.Shipped.txt" />
<AdditionalFiles Include="PublicAPI\PublicAPI.Unshipped.txt" />
Expand All @@ -54,4 +55,4 @@
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion test/E2ETests/TestAssets/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

<ItemGroup>
<ProjectCapability Remove="TestContainer" />
</ItemGroup>
</ItemGroup>
</Project>