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

Adjust embeddedresource culture warning #11298

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion src/BuildCheck.UnitTests/EndToEndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private EmbedResourceTestOutput RunEmbeddedResourceTest(string resourceXmlToAdd,

_env.SetCurrentDirectory(Path.Combine(workFolder.Path, entryProjectName));

string output = RunnerUtilities.ExecBootstrapedMSBuild("-check -restore /p:RespectCulture=" + (respectCulture ? "True" : "\"\""), out bool success);
string output = RunnerUtilities.ExecBootstrapedMSBuild("-check -restore /p:WarnOnCultureOverwritten=True /p:RespectCulture=" + (respectCulture ? "True" : "\"\""), out bool success);
_env.Output.WriteLine(output);
_env.Output.WriteLine("=========================");
success.ShouldBeTrue();
Expand Down
7 changes: 6 additions & 1 deletion src/Tasks/AssignCulture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public class AssignCulture : TaskExtension
/// </summary>
public bool RespectAlreadyAssignedItemCulture { get; set; } = false;

/// <summary>
/// If the flag set to 'true' the task will log a warning when the culture metadata is overwritten by the task.
/// </summary>
public bool WarnOnCultureOverwritten { get; set; } = false;

/// <summary>
/// This outgoing list of files is exactly the same as the incoming Files
/// list except that an attribute name "Culture" will have been added if
Expand Down Expand Up @@ -160,7 +165,7 @@ public override bool Execute()
ConversionUtilities.ValidBooleanFalse(AssignedFiles[i].GetMetadata(ItemMetadataNames.withCulture)));

// The culture was explicitly specified, but not opted in via 'RespectAlreadyAssignedItemCulture' and different will be used
if (ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_14) &&
if (WarnOnCultureOverwritten &&
!string.IsNullOrEmpty(existingCulture) &&
!MSBuildNameIgnoreCaseComparer.Default.Equals(existingCulture, info.culture))
{
Expand Down
3 changes: 2 additions & 1 deletion src/Tasks/Microsoft.Common.CurrentVersion.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3287,6 +3287,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.

<PropertyGroup>
<RespectAlreadyAssignedItemCulture Condition="'$(RespectAlreadyAssignedItemCulture)' == ''">false</RespectAlreadyAssignedItemCulture>
<WarnOnCultureOverwritten Condition="'$(WarnOnCultureOverwritten)' == ''">false</WarnOnCultureOverwritten>
</PropertyGroup>

<MSBuildInternalMessage Condition="'@(ResxWithNoCulture)'!=''" ResourceName="CommonSdk.SplitResourcesByCultureEmbeddedResourceMessage" Severity="Warning" FormatArguments="MSB9000;ResxWithNoCulture" />
Expand All @@ -3306,7 +3307,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
</EmbeddedResource>
</ItemGroup>

<AssignCulture Files="@(EmbeddedResource)" Condition="'%(Extension)'!='.licx'" RespectAlreadyAssignedItemCulture="$(RespectAlreadyAssignedItemCulture)">
<AssignCulture Files="@(EmbeddedResource)" Condition="'%(Extension)'!='.licx'" RespectAlreadyAssignedItemCulture="$(RespectAlreadyAssignedItemCulture)" WarnOnCultureOverwritten="$(WarnOnCultureOverwritten)">
<!-- Create the list of culture resx and embedded resource files -->
<Output TaskParameter="AssignedFilesWithCulture" ItemName="_MixedResourceWithCulture"/>
<!-- Create the list of non-culture resx and embedded resource files -->
Expand Down