Skip to content

Commit 3dcd541

Browse files
committed
simplify cross-arch packaging
1 parent 5406dc1 commit 3dcd541

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/ResolveToolPackagePaths.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public sealed class ResolveToolPackagePaths : TaskBase
2323
[Required]
2424
public string PublishDir { get; set; }
2525

26+
public string RuntimeIdentifier { get; set; }
27+
2628
[Required]
2729
public string ToolPackShortTargetFrameworkName { get; set; }
2830

@@ -51,7 +53,7 @@ protected override void ExecuteCore()
5153

5254
var shortFrameworkName = ToolPackShortTargetFrameworkName;
5355

54-
i.SetMetadata("PackagePath", $"tools/{shortFrameworkName}/any/{GetDirectoryPathInRelativePath(relativePath)}");
56+
i.SetMetadata("PackagePath", $"tools/{shortFrameworkName}/{RuntimeIdentifier ?? "any"}/{GetDirectoryPathInRelativePath(relativePath)}");
5557
result.Add(i);
5658
}
5759

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackTool.targets

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ Copyright (c) .NET Foundation. All rights reserved.
3434
<PublishAot Condition="'$(RuntimeIdentifier)' == ''">false</PublishAot>
3535

3636
<!-- set up generation dependencies -->
37-
<GenerateNuspecDependsOn Condition=" ('$(GeneratePackageOnBuild)' != 'true' and '$(NoBuild)' != 'true') and $(IsPublishable) == 'true' ">$(GenerateNuspecDependsOn);_PublishBuildAlternative</GenerateNuspecDependsOn>
38-
<GenerateNuspecDependsOn Condition=" ('$(GeneratePackageOnBuild)' == 'true' or '$(NoBuild)' == 'true') and $(IsPublishable) == 'true' ">$(GenerateNuspecDependsOn);$(_PublishNoBuildAlternativeDependsOn)</GenerateNuspecDependsOn>
39-
<GenerateNuspecDependsOn Condition=" '$(ToolPackageRuntimeIdentifiers)' != '' and '$(RuntimeIdentifier)' == '' ">$(GenerateNuspecDependsOn);_CreateRIDSpecificToolPackages</GenerateNuspecDependsOn>
37+
<!-- inner builds need publish content-->
38+
<_PackToolPublishDependency Condition=" '$(RuntimeIdentifier)' != '' and '$(GeneratePackageOnBuild)' != 'true' and $(IsPublishable) == 'true' ">Publish</_PackToolPublishDependency>
39+
<!-- outer build needs to generate RID-specific tool packages, but only if we're not AOT-ing (because we can't do xplat AOT). -->
40+
<GenerateNuspecDependsOn Condition=" '$(ToolPackageRuntimeIdentifiers)' != '' and '$(RuntimeIdentifier)' == '' and '$(PublishAot)' != 'true' ">$(GenerateNuspecDependsOn);_CreateRIDSpecificToolPackages</GenerateNuspecDependsOn>
4041
</PropertyGroup>
4142
<!--
4243
@@ -94,16 +95,12 @@ Copyright (c) .NET Foundation. All rights reserved.
9495
<Target Name="PackTool" DependsOnTargets="SetPackToolProperties;GenerateToolsSettingsFileFromBuildProperty;PackToPublishDependencyIndirection;_PackToolValidation;PackToolImplementation" Condition=" '$(PackAsTool)' == 'true' ">
9596
<ItemGroup>
9697
<_GeneratedFiles Include="$(_ToolsSettingsFilePath)"/>
98+
<_PublishFilesRaw Condition="'$(RuntimeIdentifier)' != ''" Include="$(PublishDir)/**/*" />
99+
<_PublishFiles Condition="'$(RuntimeIdentifier)' != ''" Include="@(_PublishFilesRaw)">
100+
<RelativePath>$([System.IO.Path]::GetRelativePath($(PublishDir), %(Identity)))</RelativePath>
101+
</_PublishFiles>
97102
</ItemGroup>
98103

99-
<ResolveToolPackagePaths
100-
AppHostIntermediatePath="$(AppHostIntermediatePath)"
101-
ResolvedFileToPublish="@(ResolvedFileToPublish)"
102-
PublishDir="$(PublishDir)"
103-
ToolPackShortTargetFrameworkName="$(_ToolPackShortTargetFrameworkName)">
104-
<Output TaskParameter="ResolvedFileToPublishWithPackagePath" ItemName="_ResolvedFileToPublishWithPackagePath" />
105-
</ResolveToolPackagePaths>
106-
107104
<PropertyGroup>
108105
<_ToolRidPath Condition="'$(RuntimeIdentifier)' == ''">any</_ToolRidPath>
109106
<_ToolRidPath Condition="'$(RuntimeIdentifier)' != ''">$(RuntimeIdentifier)</_ToolRidPath>
@@ -113,8 +110,8 @@ Copyright (c) .NET Foundation. All rights reserved.
113110
<PackagePath>tools/$(_ToolPackShortTargetFrameworkName)/$(_ToolRidPath)/%(_GeneratedFiles.RecursiveDir)%(_GeneratedFiles.Filename)%(_GeneratedFiles.Extension)</PackagePath>
114111
</TfmSpecificPackageFile>
115112

116-
<TfmSpecificPackageFile Include="@(_ResolvedFileToPublishWithPackagePath)">
117-
<PackagePath>%(_ResolvedFileToPublishWithPackagePath.PackagePath)</PackagePath>
113+
<TfmSpecificPackageFile Include="@(_PublishFiles)">
114+
<PackagePath>tools/$(_ToolPackShortTargetFrameworkName)/$(_ToolRidPath)/%(_PublishFiles.RelativePath)</PackagePath>
118115
</TfmSpecificPackageFile>
119116
</ItemGroup>
120117
</Target>

0 commit comments

Comments
 (0)