Skip to content
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
6 changes: 5 additions & 1 deletion src/Tasks/Common/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,8 @@
<data name="UsingPreviewSdkWarning" xml:space="preserve">
<value>You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452</value>
</data>
</root>
<data name="InvalidItemSpecToUse" xml:space="preserve">
<value>Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</value>
<comment>The following are names of parameters or literal values and should not be translated: ItemSpecToUse, Left, Right</comment>
</data>
</root>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@
<target state="new">You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452</target>
<note />
</trans-unit>
<trans-unit id="InvalidItemSpecToUse">
<source>Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</source>
<target state="new">Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</target>
<note>The following are names of parameters or literal values and should not be translated: ItemSpecToUse, Left, Right</note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@
<target state="new">You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452</target>
<note />
</trans-unit>
<trans-unit id="InvalidItemSpecToUse">
<source>Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</source>
<target state="new">Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</target>
<note>The following are names of parameters or literal values and should not be translated: ItemSpecToUse, Left, Right</note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@
<target state="new">You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452</target>
<note />
</trans-unit>
<trans-unit id="InvalidItemSpecToUse">
<source>Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</source>
<target state="new">Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</target>
<note>The following are names of parameters or literal values and should not be translated: ItemSpecToUse, Left, Right</note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@
<target state="new">You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452</target>
<note />
</trans-unit>
<trans-unit id="InvalidItemSpecToUse">
<source>Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</source>
<target state="new">Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</target>
<note>The following are names of parameters or literal values and should not be translated: ItemSpecToUse, Left, Right</note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@
<target state="new">You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452</target>
<note />
</trans-unit>
<trans-unit id="InvalidItemSpecToUse">
<source>Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</source>
<target state="new">Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</target>
<note>The following are names of parameters or literal values and should not be translated: ItemSpecToUse, Left, Right</note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@
<target state="new">You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452</target>
<note />
</trans-unit>
<trans-unit id="InvalidItemSpecToUse">
<source>Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</source>
<target state="new">Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</target>
<note>The following are names of parameters or literal values and should not be translated: ItemSpecToUse, Left, Right</note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@
<target state="new">You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452</target>
<note />
</trans-unit>
<trans-unit id="InvalidItemSpecToUse">
<source>Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</source>
<target state="new">Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</target>
<note>The following are names of parameters or literal values and should not be translated: ItemSpecToUse, Left, Right</note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@
<target state="new">You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452</target>
<note />
</trans-unit>
<trans-unit id="InvalidItemSpecToUse">
<source>Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</source>
<target state="new">Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</target>
<note>The following are names of parameters or literal values and should not be translated: ItemSpecToUse, Left, Right</note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@
<target state="new">You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452</target>
<note />
</trans-unit>
<trans-unit id="InvalidItemSpecToUse">
<source>Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</source>
<target state="new">Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</target>
<note>The following are names of parameters or literal values and should not be translated: ItemSpecToUse, Left, Right</note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@
<target state="new">You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452</target>
<note />
</trans-unit>
<trans-unit id="InvalidItemSpecToUse">
<source>Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</source>
<target state="new">Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</target>
<note>The following are names of parameters or literal values and should not be translated: ItemSpecToUse, Left, Right</note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@
<target state="new">You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452</target>
<note />
</trans-unit>
<trans-unit id="InvalidItemSpecToUse">
<source>Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</source>
<target state="new">Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</target>
<note>The following are names of parameters or literal values and should not be translated: ItemSpecToUse, Left, Right</note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@
<target state="new">You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452</target>
<note />
</trans-unit>
<trans-unit id="InvalidItemSpecToUse">
<source>Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</source>
<target state="new">Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</target>
<note>The following are names of parameters or literal values and should not be translated: ItemSpecToUse, Left, Right</note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@
<target state="new">You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452</target>
<note />
</trans-unit>
<trans-unit id="InvalidItemSpecToUse">
<source>Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</source>
<target state="new">Invalid value for ItemSpecToUse parameter: '{0}'. This property must be blank or set to 'Left' or 'Right'</target>
<note>The following are names of parameters or literal values and should not be translated: ItemSpecToUse, Left, Right</note>
</trans-unit>
</body>
</file>
</xliff>
38 changes: 35 additions & 3 deletions src/Tasks/Microsoft.NET.Build.Tasks/JoinItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class JoinItems : TaskBase

public string RightKey { get; set; }

// Set to "Left" or "Right" to use that itemspec in results. Leave blank to set itemspec based on the joined key value
public string ItemSpecToUse { get; set; }


// LeftMetadata and RightMetadata: The metadata names to include in the result. Specify "*" to include all metadata
public string[] LeftMetadata { get; set; }
Expand All @@ -36,6 +39,21 @@ public ITaskItem[] JoinResult

protected override void ExecuteCore()
{
bool useLeftItemSpec = false;
bool useRightItemSpec = false;
if (string.Equals(ItemSpecToUse, "Left", StringComparison.OrdinalIgnoreCase))
{
useLeftItemSpec = true;
}
else if (string.Equals(ItemSpecToUse, "Right", StringComparison.OrdinalIgnoreCase))
{
useRightItemSpec = true;
}
else if (!string.IsNullOrEmpty(ItemSpecToUse))
{
throw new BuildErrorException(Strings.InvalidItemSpecToUse, ItemSpecToUse);
}

bool useAllLeftMetadata = LeftMetadata != null && LeftMetadata.Length == 1 && LeftMetadata[0] == "*";
bool useAllRightMetadata = RightMetadata != null && RightMetadata.Length == 1 && RightMetadata[0] == "*";

Expand All @@ -46,21 +64,35 @@ protected override void ExecuteCore()
{
// If including all metadata from left items and none from right items, just return left items directly
if (useAllLeftMetadata &&
string.IsNullOrEmpty(LeftKey) &&
(string.IsNullOrEmpty(LeftKey) || useLeftItemSpec) &&
(RightMetadata == null || RightMetadata.Length == 0))
{
return left;
}

// If including all metadata from right items and none from left items, just return the right items directly
if (useAllRightMetadata &&
string.IsNullOrEmpty(RightKey) &&
(string.IsNullOrEmpty(RightKey) || useRightItemSpec) &&
(LeftMetadata == null || LeftMetadata.Length == 0))
{
return right;
}

var ret = new TaskItem(GetKeyValue(LeftKey, left));
string resultItemSpec;
if (useLeftItemSpec)
{
resultItemSpec = left.ItemSpec;
}
else if (useRightItemSpec)
{
resultItemSpec = right.ItemSpec;
}
else
{
resultItemSpec = GetKeyValue(LeftKey, left);
}

var ret = new TaskItem(resultItemSpec);

// Weird ordering here is to prefer left metadata in all cases, as CopyToMetadata doesn't overwrite any existing metadata
if (useAllLeftMetadata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ protected override void ExecuteCore()
item.SetMetadata("AssetType", resolvedAssembly.Asset.ToString().ToLower());
item.SetMetadata(MetadataKeys.PackageName, resolvedAssembly.Package.Id.ToString());
item.SetMetadata(MetadataKeys.PackageVersion, resolvedAssembly.Package.Version.ToString().ToLower());

if (resolvedAssembly.Asset == AssetType.Resources)
{
// For resources, the DestinationSubDirectory is set to the locale. Set the Culture
// metadata on the generated item to this value so that the satellite assemblies can
// be filtered by culture.
item.SetMetadata(MetadataKeys.Culture, resolvedAssembly.DestinationSubDirectory);
}

_assembliesToPublish.Add(item);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,26 @@ Copyright (c) .NET Foundation. All rights reserved.
<Output TaskParameter="AssembliesToPublish" ItemName="ResolvedAssembliesToPublish" />
</ResolvePublishAssemblies>
</Target>

<Target Name="FilterPublishSatelliteResources" AfterTargets="RunResolvePublishAssemblies"
Condition="'$(SatelliteResourceLanguages)' != ''">

<ItemGroup>
<PublishSatelliteResources Include="@(ResolvedAssembliesToPublish)"
Condition="'%(ResolvedAssembliesToPublish.AssetType)' == 'resources'" />
</ItemGroup>

<JoinItems Left="@(PublishSatelliteResources)" LeftKey="Culture" LeftMetadata="*"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one remaining JoinItems still shows up as relatively slow. We probably want to see about speeding it up. Given that this only kicks in with SatelliteResourceLanguages set, it is probably OK.

Right="$(SatelliteResourceLanguages)" RightKey="" RightMetadata=""
ItemSpecToUse="Left">
<Output TaskParameter="JoinResult" ItemName="FilteredPublishSatelliteResources" />
</JoinItems>

<ItemGroup Condition="'@(PublishSatelliteResources)' != ''">
<ResolvedAssembliesToPublish Remove="@(PublishSatelliteResources)" />
<ResolvedAssembliesToPublish Include="@(FilteredPublishSatelliteResources)" />
</ItemGroup>
</Target>

<!--
============================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,22 @@ Copyright (c) .NET Foundation. All rights reserved.
<Output TaskParameter="TransitiveProjectReferences" ItemName="_TransitiveProjectReferences" />
</ResolvePackageAssets>


</Target>

<Target Name="FilterSatelliteResources" AfterTargets="ResolvePackageAssets"
Condition="'$(SatelliteResourceLanguages)' != ''">

<JoinItems Left="@(ResourceCopyLocalItems)" LeftKey="Culture" LeftMetadata="*"
Right="$(SatelliteResourceLanguages)" RightKey="" RightMetadata=""
ItemSpecToUse="Left">
<Output TaskParameter="JoinResult" ItemName="FilteredResourceCopyLocalItems" />
</JoinItems>

<ItemGroup>
<ResourceCopyLocalItems Remove="@(ResourceCopyLocalItems)" />
<ResourceCopyLocalItems Include="@(FilteredResourceCopyLocalItems)" />
</ItemGroup>
</Target>

<!--
Expand Down
Loading