@@ -38,6 +38,9 @@ NOTE: This file is imported from the following contexts, so be aware when writin
3838 AssemblyFile =" $(MicrosoftNETBuildTasksAssembly)" />
3939
4040 <PropertyGroup >
41+ <!-- tools are specially-formatted packages, so we tell nuget Pack to not even try to include build output -->
42+ <IncludeBuildOutput >false</IncludeBuildOutput >
43+
4144 <!-- Determine information about all of the potential tool packages to build -->
4245 <!-- If shims are included, we need to make sure we restore for those RIDs so the apphost shims are available during restore/publish.
4346 This means that we need to set RuntimeIdentifiers. However we need to track certain information about the _users_ decisions around RIDs
@@ -48,15 +51,28 @@ NOTE: This file is imported from the following contexts, so be aware when writin
4851 <_UserSpecifiedToolPackageRids Condition =" '$(_UserSpecifiedToolPackageRids)' == ''" >$(RuntimeIdentifiers)</_UserSpecifiedToolPackageRids >
4952 <_HasRIDSpecificTools Condition =" '$(_UserSpecifiedToolPackageRids)' != '' " >true</_HasRIDSpecificTools >
5053 <_HasRIDSpecificTools Condition =" '$(_HasRIDSpecificTools)' == ''" >false</_HasRIDSpecificTools >
51- <!-- unlike all of the other computed properties here, we _do_ want to mutate RuntimeIdentifiers here so that we ensure that the shims are included in restores -->
5254 <RuntimeIdentifiers Condition =" '$(PackAsToolShimRuntimeIdentifiers)' != ''" >$(_UserSpecifiedToolPackageRids);$(PackAsToolShimRuntimeIdentifiers)</RuntimeIdentifiers >
5355
5456 <_IsRidSpecific >false</_IsRidSpecific >
5557 <_IsRidSpecific Condition =" '$(RuntimeIdentifier)' != '' and '$(RuntimeIdentifier)' != 'any'" >true</_IsRidSpecific >
58+
59+ <!-- Not determine information about this specific build of a single (or more!) tool packages -->
60+ <!-- 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 -->
61+ <!-- RID information is also stripped during Restore, so we need to make sure user
62+ decisions are preserved when Restoring, so that publishing-related packages are implicitly included. -->
63+ <PublishSelfContained Condition =" !$(_IsRidSpecific) and '$(MSBuildIsRestoring)' != 'true'" >false</PublishSelfContained >
64+ <!-- Have to set SelfContained similarly because PackTool targets are imported _after_ RuntimeIdentifierInference targets, where the Publish* properties are
65+ forwarded to the 'base' properties. -->
66+ <SelfContained Condition =" !$(_IsRidSpecific) and '$(MSBuildIsRestoring)' != 'true'" >false</SelfContained >
67+ <PublishTrimmed Condition =" !$(_IsRidSpecific) and '$(MSBuildIsRestoring)' != 'true'" >false</PublishTrimmed >
68+ <PublishReadyToRun Condition =" !$(_IsRidSpecific) and '$(MSBuildIsRestoring)' != 'true'" >false</PublishReadyToRun >
69+ <PublishSingleFile Condition =" !$(_IsRidSpecific) and '$(MSBuildIsRestoring)' != 'true'" >false</PublishSingleFile >
70+
5671 <!-- We need to know if the inner builds are _intended_ to be AOT even if we then explicitly disable AOT for the outer builds.
5772 Knowing this lets us correctly decide to create the RID-specific inner tools or not when packaging the outer tool. -->
5873 <_InnerToolsPublishAot >false</_InnerToolsPublishAot >
5974 <_InnerToolsPublishAot Condition =" $(_HasRIDSpecificTools) and '$(PublishAot)' == 'true'" >true</_InnerToolsPublishAot >
75+ <PublishAot Condition =" !$(_IsRidSpecific) and '$(MSBuildIsRestoring)' != 'true'" >false</PublishAot >
6076
6177 <!-- Tool implementation files are not included in the primary package when the tool has RID-specific packages. So only pack the tool implementation
6278 (and only depend on publish) if there are no RID-specific packages, or if the RuntimeIdentifier is set. -->
@@ -92,6 +108,15 @@ NOTE: This file is imported from the following contexts, so be aware when writin
92108 - Consider a way of declaring what RID a RID-specific package is for, besides just the convention in the package ID
93109 -->
94110
111+ <!--
112+ Mark all dependency as private assets. But keep them as Publish. So dependency DLLs will be included in NuGet package, while
113+ there is no dependency in nuspec. And add Microsoft.NETCore.Platforms, which is used to select correct RID assets.
114+ -->
115+ <PropertyGroup >
116+ <_ToolsSettingsFilePath >$(IntermediateOutputPath)DotnetToolSettings.xml</_ToolsSettingsFilePath >
117+ <SuppressDependenciesWhenPacking Condition =" '$(PackAsTool)' == 'true' " >true</SuppressDependenciesWhenPacking >
118+ </PropertyGroup >
119+
95120 <!--
96121 PackageId must be set before:
97122 - _GenerateRestoreProjectSpec -> _GetRestoreSettings
@@ -108,12 +133,6 @@ NOTE: This file is imported from the following contexts, so be aware when writin
108133 property for 'you should expect a native binary here' -->
109134 <_ToolUsesPlatformSpecificExecutable Condition =" $(_IsRidSpecific) and ('$(UseAppHost)' == 'true' or '$(PublishAot)' == 'true')" >true</_ToolUsesPlatformSpecificExecutable >
110135 <_ToolUsesPlatformSpecificExecutable Condition =" '$(_ToolUsesPlatformSpecificExecutable)' == ''" >false</_ToolUsesPlatformSpecificExecutable >
111-
112- <!-- Tool packages do not participate at all in NuGet package dependency tracking, so suppress that behavior. -->
113- <SuppressDependenciesWhenPacking >true</SuppressDependenciesWhenPacking >
114-
115- <!-- tools are specially-formatted packages, so we tell nuget Pack to not even try to include build output -->
116- <IncludeBuildOutput >false</IncludeBuildOutput >
117136 </PropertyGroup >
118137
119138 <PropertyGroup Condition =" '$(ToolCommandRunner)' == ''" >
@@ -146,34 +165,8 @@ NOTE: This file is imported from the following contexts, so be aware when writin
146165 <Target Name =" PackToPublishDependencyIndirection"
147166 DependsOnTargets =" $(_PackToolPublishDependency)" />
148167
149- <PropertyGroup >
150- <_PackToolDependsOn >
151- EnsureCorrectPublishingProperties;
152- SetPackToolProperties;
153- GenerateToolsSettingsFileFromBuildProperty;
154- PackToPublishDependencyIndirection;
155- _PackToolValidation;
156- PackToolImplementation
157- </_PackToolDependsOn >
158- </PropertyGroup >
159-
160- <Target Name =" EnsureCorrectPublishingProperties" Condition =" !$(_IsRidSpecific)" >
161- <PropertyGroup >
162- <!-- The publish* properties _can_ be set, but only for the 'inner' RID-specific builds.
163- We need to make sure that for the outer, agnostic build they are unset -->
164- <PublishSelfContained >false</PublishSelfContained >
165- <!-- Have to set SelfContained similarly because PackTool targets are imported _after_ RuntimeIdentifierInference targets,
166- where the Publish* properties are forwarded to the 'base' properties. -->
167- <SelfContained >false</SelfContained >
168- <PublishTrimmed >false</PublishTrimmed >
169- <PublishReadyToRun >false</PublishReadyToRun >
170- <PublishSingleFile >false</PublishSingleFile >
171- <PublishAot >false</PublishAot >
172- </PropertyGroup >
173- </Target >
174-
175- <Target Name =" PackTool"
176- DependsOnTargets =" $(_PackToolDependsOn)"
168+ <Target Name =" PackTool" DependsOnTargets =" SetPackToolProperties;GenerateToolsSettingsFileFromBuildProperty;PackToPublishDependencyIndirection;_PackToolValidation;PackToolImplementation"
169+ Condition =" '$(PackAsTool)' == 'true' "
177170 Returns =" @(TfmSpecificPackageFile)" >
178171 <ItemGroup >
179172 <_GeneratedFiles Include =" $(_ToolsSettingsFilePath)" />
@@ -210,15 +203,14 @@ NOTE: This file is imported from the following contexts, so be aware when writin
210203 </ItemGroup >
211204 </Target >
212205
213- <Target Name =" _GenerateToolsSettingsFileInputCache" >
214- <PropertyGroup >
215- <_ToolsSettingsFilePath >$(IntermediateOutputPath)DotnetToolSettings.xml</_ToolsSettingsFilePath >
216- <ToolCommandName Condition =" '$(ToolCommandName)' == '' " >$(TargetName)</ToolCommandName >
217- <ToolRuntimeIdentifier Condition =" '$(ToolRuntimeIdentifier)' == ''" >$(RuntimeIdentifier)</ToolRuntimeIdentifier >
218- <_GenerateToolsSettingsFileCacheFile Condition =" '$(_GenerateToolsSettingsFileCacheFile)' == ''" >$(IntermediateOutputPath)$(MSBuildProjectName).toolssettingsinput.cache</_GenerateToolsSettingsFileCacheFile >
219- <_GenerateToolsSettingsFileCacheFile >$([MSBuild]::NormalizePath($(MSBuildProjectDirectory), $(_GenerateToolsSettingsFileCacheFile)))</_GenerateToolsSettingsFileCacheFile >
220- </PropertyGroup >
206+ <PropertyGroup >
207+ <ToolCommandName Condition =" '$(ToolCommandName)' == '' " >$(TargetName)</ToolCommandName >
208+ <ToolRuntimeIdentifier Condition =" '$(ToolRuntimeIdentifier)' == ''" >$(RuntimeIdentifier)</ToolRuntimeIdentifier >
209+ <_GenerateToolsSettingsFileCacheFile Condition =" '$(_GenerateToolsSettingsFileCacheFile)' == ''" >$(IntermediateOutputPath)$(MSBuildProjectName).toolssettingsinput.cache</_GenerateToolsSettingsFileCacheFile >
210+ <_GenerateToolsSettingsFileCacheFile >$([MSBuild]::NormalizePath($(MSBuildProjectDirectory), $(_GenerateToolsSettingsFileCacheFile)))</_GenerateToolsSettingsFileCacheFile >
211+ </PropertyGroup >
221212
213+ <Target Name =" _GenerateToolsSettingsFileInputCache" >
222214 <ItemGroup >
223215 <_ToolPackageRuntimeIdentifier Include =" $(_UserSpecifiedToolPackageRids)" />
224216 <_GenerateToolsSettingsFileInputCacheToHash Include =" $(ToolEntryPoint)" />
@@ -294,15 +286,13 @@ NOTE: This file is imported from the following contexts, so be aware when writin
294286 ============================================================
295287 -->
296288
297- <Target Name =" _ComputeShimProperties" >
298- <PropertyGroup >
299- <_ShimInputCacheFile Condition =" '$(_ShimInputCacheFile)' == ''" >$(IntermediateOutputPath)$(MSBuildProjectName).shiminput.cache</_ShimInputCacheFile >
300- <_ShimInputCacheFile >$([MSBuild]::NormalizePath($(MSBuildProjectDirectory), $(_ShimInputCacheFile)))</_ShimInputCacheFile >
301- <_ShimCreatedSentinelFile Condition =" '$(_ShimCreatedSentinelFile)' == ''" >$(IntermediateOutputPath)$(MSBuildProjectName).shimcreated.sentinel</_ShimCreatedSentinelFile >
302- <_ShimCreatedSentinelFile >$([MSBuild]::NormalizePath($(MSBuildProjectDirectory), $(_ShimCreatedSentinelFile)))</_ShimCreatedSentinelFile >
303- <PackagedShimOutputRootDirectory Condition =" '$(PackagedShimOutputRootDirectory)' == '' " >$(OutDir)</PackagedShimOutputRootDirectory >
304- </PropertyGroup >
305- </Target >
289+ <PropertyGroup >
290+ <_ShimInputCacheFile Condition =" '$(_ShimInputCacheFile)' == ''" >$(IntermediateOutputPath)$(MSBuildProjectName).shiminput.cache</_ShimInputCacheFile >
291+ <_ShimInputCacheFile >$([MSBuild]::NormalizePath($(MSBuildProjectDirectory), $(_ShimInputCacheFile)))</_ShimInputCacheFile >
292+ <_ShimCreatedSentinelFile Condition =" '$(_ShimCreatedSentinelFile)' == ''" >$(IntermediateOutputPath)$(MSBuildProjectName).shimcreated.sentinel</_ShimCreatedSentinelFile >
293+ <_ShimCreatedSentinelFile >$([MSBuild]::NormalizePath($(MSBuildProjectDirectory), $(_ShimCreatedSentinelFile)))</_ShimCreatedSentinelFile >
294+ <PackagedShimOutputRootDirectory Condition =" '$(PackagedShimOutputRootDirectory)' == '' " >$(OutDir)</PackagedShimOutputRootDirectory >
295+ </PropertyGroup >
306296
307297 <Target Name =" GenerateShimsAssets"
308298 BeforeTargets =" CopyFilesToOutputDirectory"
@@ -342,7 +332,7 @@ NOTE: This file is imported from the following contexts, so be aware when writin
342332 </ItemGroup >
343333 </Target >
344334
345- <Target Name =" _ComputeExpectedEmbeddedApphostPaths" DependsOnTargets = " _ComputeShimProperties " >
335+ <Target Name =" _ComputeExpectedEmbeddedApphostPaths" >
346336 <GetEmbeddedApphostPaths
347337 PackagedShimOutputDirectory =" $([MSBuild]::NormalizeDirectory($(PackagedShimOutputRootDirectory), 'shims', $(_ToolPackShortTargetFrameworkName)))"
348338 ShimRuntimeIdentifiers =" @(_PackAsToolShimRuntimeIdentifiers)"
@@ -354,7 +344,7 @@ NOTE: This file is imported from the following contexts, so be aware when writin
354344
355345 <!-- To achieve incremental build with property change. When any property changes, WriteOnlyWhenDifferent will be triggered to write cache file.
356346 And the cache file's timestamp will be later, and it then triggers the incremental build.-->
357- <Target Name =" _GenerateShimInputCache" DependsOnTargets =" ResolveAssemblyReferences;_ComputeShimProperties " >
347+ <Target Name =" _GenerateShimInputCache" DependsOnTargets =" ResolveAssemblyReferences" >
358348 <ItemGroup >
359349 <_GenerateShimsAssetsInput Include =" $(_ShimInputCacheFile)" />
360350 <_GenerateShimsAssetsInput Include =" @(_ApphostsForShimRuntimeIdentifiers)" />
0 commit comments