@@ -24,6 +24,15 @@ Copyright (c) .NET Foundation. All rights reserved.
24
24
<UsingTask TaskName =" Microsoft.NET.Build.Tasks.RemoveTargetFromList"
25
25
AssemblyFile =" $(MicrosoftNETBuildTasksAssembly)" />
26
26
27
+ <PropertyGroup >
28
+ <!-- tools are specially-formatted packages, so we tell nuget Pack to not even try to include build output -->
29
+ <IncludeBuildOutput >false</IncludeBuildOutput >
30
+ <!-- the publish* properties _can_ be set, but only for the 'inner' RID-specific builds. We need to make sure that for the outer, agnostic build they are unset -->
31
+ <PublishSelfContained Condition =" '$(RuntimeIdentifier)' == ''" >false</PublishSelfContained >
32
+ <PublishTrimmed Condition =" '$(RuntimeIdentifier)' == ''" >false</PublishTrimmed >
33
+ <PublishReadyToRun Condition =" '$(RuntimeIdentifier)' == ''" >false</PublishReadyToRun >
34
+ <PublishAot Condition =" '$(RuntimeIdentifier)' == ''" >false</PublishAot >
35
+ </PropertyGroup >
27
36
<!--
28
37
29
38
TODO:
@@ -32,40 +41,15 @@ Copyright (c) .NET Foundation. All rights reserved.
32
41
- Consider a way of declaring what RID a RID-specific package is for, besides just the convention in the package ID
33
42
-->
34
43
35
-
36
44
<!--
37
45
Mark all dependency as private assets. But keep them as Publish. So dependency DLLs will be included in NuGet package, while
38
46
there is no dependency in nuspec. And add Microsoft.NETCore.Platforms, which is used to select correct RID assets.
39
47
-->
40
48
<PropertyGroup >
41
49
<_ToolsSettingsFilePath >$(IntermediateOutputPath)DotnetToolSettings.xml</_ToolsSettingsFilePath >
42
50
<SuppressDependenciesWhenPacking Condition =" '$(PackAsTool)' == 'true' " >true</SuppressDependenciesWhenPacking >
43
-
44
51
</PropertyGroup >
45
52
46
- <Target Name =" PackAsToolSwitchToNoBuild"
47
- BeforeTargets =" _IntermediatePack"
48
- Condition =" '$(PackAsTool)' == 'true' And
49
- '@(ToolPackageRuntimeIdentifier)' != '' And
50
- '$(RuntimeIdentifier)' == ''" >
51
-
52
- <!-- If we are building the primary package for a tool with RID-specific packages, we don't include any of the build output in the package, so we don't need to run Build.
53
- We might not be able to build without a RuntimeIdentifier if PublishAOT or SelfContained is set to true, so we skip the build so it doesn't fail.
54
-
55
- We use a task to remove the Build target from GenerateNuspecDependsOn. This is effectively what happens if NoBuild is set, but we can't use the same logic because
56
- we need to look at items (ToolPackageRuntimeIdentifier) to determine if we are building the primary package for a tool with RID-specific packages. So we have to fix
57
- up the dependency list afterwards.
58
-
59
- We also can't use MSBuild property functions for string replacement to remove Build from the list, because MSBuild will escape the semicolons as %3B, and there
60
- doesn't seem to be a way of avoiding that without using a task.
61
- -->
62
- <RemoveTargetFromList TargetList =" $(GenerateNuspecDependsOn)"
63
- TargetToRemove =" Build" >
64
- <Output TaskParameter =" UpdatedTargetList" PropertyName =" GenerateNuspecDependsOn" />
65
- </RemoveTargetFromList >
66
-
67
- </Target >
68
-
69
53
<!--
70
54
PackageId must be set before:
71
55
- _GenerateRestoreProjectSpec -> _GetRestoreSettings
@@ -75,18 +59,9 @@ Copyright (c) .NET Foundation. All rights reserved.
75
59
-->
76
60
<Target Name =" SetPackToolProperties"
77
61
BeforeTargets =" _GenerateRestoreProjectSpec;_GenerateToolsSettingsFileInputCache;_GenerateShimInputCache;_GetOutputItemsFromPack" >
78
-
79
- <!-- Tool implementation files are not included in the primary package when the tool has RID-specific packages. So only pack the tool implementation
80
- (and only depend on publish) if there are no RID-specific packages, or if the RuntimeIdentifier is set. -->
81
- <PropertyGroup Condition =" '$(_ToolPackageShouldIncludeImplementation)' == ''" >
82
- <_ToolPackageShouldIncludeImplementation Condition =" '$(PackAsTool)' == 'true' And
83
- ('@(ToolPackageRuntimeIdentifier)' == '' Or '$(RuntimeIdentifier)' != '')" >true</_ToolPackageShouldIncludeImplementation >
84
- <_ToolPackageShouldIncludeImplementation Condition =" '$(_ToolPackageShouldIncludeImplementation)' == ''" >false</_ToolPackageShouldIncludeImplementation >
85
- </PropertyGroup >
86
-
87
- <PropertyGroup Condition =" '$(_ToolPackageShouldIncludeImplementation)' == 'true'" >
88
- <_PackToolPublishDependency Condition =" ('$(GeneratePackageOnBuild)' != 'true' and '$(NoBuild)' != 'true') and $(IsPublishable) == 'true' " >_PublishBuildAlternative</_PackToolPublishDependency >
89
- <_PackToolPublishDependency Condition =" ('$(GeneratePackageOnBuild)' == 'true' or '$(NoBuild)' == 'true') and $(IsPublishable) == 'true' " >$(_PublishNoBuildAlternativeDependsOn)</_PackToolPublishDependency >
62
+ <PropertyGroup >
63
+ <GenerateNuspecDependsOn Condition =" ('$(GeneratePackageOnBuild)' != 'true' and '$(NoBuild)' != 'true') and $(IsPublishable) == 'true' " >$(GenerateNuspecDependsOn);_PublishBuildAlternative</GenerateNuspecDependsOn >
64
+ <GenerateNuspecDependsOn Condition =" ('$(GeneratePackageOnBuild)' == 'true' or '$(NoBuild)' == 'true') and $(IsPublishable) == 'true' " >$(GenerateNuspecDependsOn);$(_PublishNoBuildAlternativeDependsOn)</GenerateNuspecDependsOn >
90
65
</PropertyGroup >
91
66
92
67
<!-- Needs to be in a target so we don't need to worry about evaluation order with NativeBinary property -->
@@ -102,19 +77,19 @@ Copyright (c) .NET Foundation. All rights reserved.
102
77
103
78
</Target >
104
79
105
- <Target Name =" PackToolImplementation" Condition = " '$(_ToolPackageShouldIncludeImplementation)' == 'true' " >
80
+ <Target Name =" PackToolImplementation" >
106
81
107
82
<ItemGroup >
108
83
<_GeneratedFiles Include =" $(PublishDepsFilePath)" Condition =" '$(GenerateDependencyFile)' != 'true' or '$(_UseBuildDependencyFile)' == 'true'" />
109
84
<_GeneratedFiles Include =" $(PublishRuntimeConfigFilePath)" />
110
85
</ItemGroup >
111
-
86
+
112
87
</Target >
113
88
114
89
<!-- This indirection target essentially allows one target dependency (SetPackToolProperties) of PackTool modify the dependencies of PackTool. -->
115
90
<Target Name =" PackToPublishDependencyIndirection"
116
91
DependsOnTargets =" $(_PackToolPublishDependency)" />
117
-
92
+
118
93
<Target Name =" PackTool" DependsOnTargets =" SetPackToolProperties;GenerateToolsSettingsFileFromBuildProperty;PackToPublishDependencyIndirection;_PackToolValidation;PackToolImplementation" Condition =" '$(PackAsTool)' == 'true' " >
119
94
<ItemGroup >
120
95
<_GeneratedFiles Include =" $(_ToolsSettingsFilePath)" />
0 commit comments