Skip to content

Commit e9f8347

Browse files
committed
Ensure that RID-specific packages set the right package type
1 parent 55e5c4d commit e9f8347

File tree

2 files changed

+34
-35
lines changed

2 files changed

+34
-35
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,40 @@ Copyright (c) .NET Foundation. All rights reserved.
319319
</ItemGroup>
320320
</Target>
321321

322+
<UsingTask TaskName="AddPackageType" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
323+
324+
<Target Name="SetDotnetToolPackageType"
325+
Condition=" '$(PackAsTool)' == 'true' "
326+
BeforeTargets="GenerateNuspec">
327+
328+
<PropertyGroup>
329+
<_ToolPackageType Condition="'$(RuntimeIdentifier)' != '' And '$(_HasRIDSpecificTools)' != ''">DotnetToolRidPackage</_ToolPackageType>
330+
<_ToolPackageType Condition="'$(_ToolPackageType)' == ''">DotnetTool</_ToolPackageType>
331+
</PropertyGroup>
332+
333+
<!--
334+
PackageType is semicolon-delimited, case-insensitive, with an optional version.
335+
336+
DotnetTool should be added to the set of package types if the PackAsTool property is set to true.
337+
338+
Examples:
339+
PackageType = '' -> 'DotnetTool'
340+
PackageType = 'MyCustomType' -> 'DotnetTool;MyCustomType'
341+
PackageType = 'MyCustomType, 1.0' -> 'DotnetTool;MyCustomType, 1.0'
342+
PackageType = 'dotnettool' -> 'dotnettool'
343+
PackageType = 'DotnetTool, 1.0.0.0' -> 'DotnetTool, 1.0.0.0'
344+
PackageType = 'DotnetTool , 1.0.0.0' -> 'DotnetTool , 1.0.0.0'
345+
PackageType = 'MyDotnetTool' -> 'DotnetTool;MyDotnetTool'
346+
347+
_PaddedPackageType is used to ensure that the PackageType is semicolon delimited and can be easily checked for an existing DotnetTool package type.
348+
-->
349+
350+
<AddPackageType CurrentPackageType="$(PackageType)" PackageTypeToAdd="$(_ToolPackageType)">
351+
<Output TaskParameter="UpdatedPackageType" PropertyName="PackageType" />
352+
</AddPackageType>
353+
354+
</Target>
355+
322356
<!-- orchestrator for making the N RID-specific tool packages -->
323357
<Target Name="_CreateRIDSpecificToolPackages" Condition="'$(RuntimeIdentifier)' == '' and $(_HasRIDSpecificTools) and '$(PublishAot)' != 'true'">
324358
<PropertyGroup>

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Common.targets

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -42,41 +42,6 @@ Copyright (c) .NET Foundation. All rights reserved.
4242
<DotnetCliToolTargetFramework>netcoreapp2.2</DotnetCliToolTargetFramework>
4343
</PropertyGroup>
4444

45-
<UsingTask TaskName="AddPackageType" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
46-
47-
<Target Name="SetDotnetToolPackageType"
48-
Condition=" '$(PackAsTool)' == 'true' "
49-
BeforeTargets="GenerateNuspec">
50-
51-
<PropertyGroup>
52-
<_ToolPackageType Condition="'$(RuntimeIdentifier)' != '' And '$(ToolPackageRuntimeIdentifiers)' != ''">DotnetToolRidPackage</_ToolPackageType>
53-
<_ToolPackageType Condition="'$(_ToolPackageType)' == ''">DotnetTool</_ToolPackageType>
54-
</PropertyGroup>
55-
56-
57-
<!--
58-
PackageType is semicolon-delimited, case-insensitive, with an optional version.
59-
60-
DotnetTool should be added to the set of package types if the PackAsTool property is set to true.
61-
62-
Examples:
63-
PackageType = '' -> 'DotnetTool'
64-
PackageType = 'MyCustomType' -> 'DotnetTool;MyCustomType'
65-
PackageType = 'MyCustomType, 1.0' -> 'DotnetTool;MyCustomType, 1.0'
66-
PackageType = 'dotnettool' -> 'dotnettool'
67-
PackageType = 'DotnetTool, 1.0.0.0' -> 'DotnetTool, 1.0.0.0'
68-
PackageType = 'DotnetTool , 1.0.0.0' -> 'DotnetTool , 1.0.0.0'
69-
PackageType = 'MyDotnetTool' -> 'DotnetTool;MyDotnetTool'
70-
71-
_PaddedPackageType is used to ensure that the PackageType is semicolon delimited and can be easily checked for an existing DotnetTool package type.
72-
-->
73-
74-
<AddPackageType CurrentPackageType="$(PackageType)" PackageTypeToAdd="$(_ToolPackageType)">
75-
<Output TaskParameter="UpdatedPackageType" PropertyName="PackageType" />
76-
</AddPackageType>
77-
78-
</Target>
79-
8045
<PropertyGroup Condition="'$(EnablePreviewFeatures)' == 'true' And '$(IsNetCoreAppTargetingLatestTFM)' == 'true'">
8146
<LangVersion>Preview</LangVersion>
8247
</PropertyGroup>

0 commit comments

Comments
 (0)