Skip to content

Commit 3e76c58

Browse files
committed
Update Restore and Pack targets
- Format and Cleanup Restore and Pack targets. - Match to Upstream version except our patches.
1 parent 7e41d8b commit 3e76c58

5 files changed

Lines changed: 35 additions & 32 deletions

File tree

Directory.Solution.props

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<Project>
22

3-
<PropertyGroup Label="Build">
4-
<NoWarn>NU1507</NoWarn>
5-
<ManagePackageVersionsCentrally>True</ManagePackageVersionsCentrally>
6-
<RestoreUseStaticGraphEvaluation>True</RestoreUseStaticGraphEvaluation>
7-
</PropertyGroup>
8-
93
<!-- Integrate with the Solution SDK for Legacy Solution files -->
104
<Import Sdk="MSBuild.Solution.Sdk" Project="Sdk.Legacy.props"/>
115

6+
<PropertyGroup Label="Build">
7+
<NoWarn Condition="'$(ManagePackageVersionsCentrally)' == 'true'">NU1507</NoWarn>
8+
</PropertyGroup>
9+
1210
</Project>

Directory.Solution.targets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<Project>
22

3+
<PropertyGroup Label="Build">
4+
<RestoreUseStaticGraphEvaluation>True</RestoreUseStaticGraphEvaluation>
5+
</PropertyGroup>
6+
37
<!-- Integrate with the Solution SDK for Legacy Solution files -->
48
<Import Sdk="MSBuild.Solution.Sdk" Project="Sdk.Legacy.targets"/>
59

Sources/NuGet.Build.Sdk/Core/NuGet.Pack.targets

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
<SymbolPackageFormat Condition="'$(SymbolPackageFormat)' == ''">symbols.nupkg</SymbolPackageFormat>
1919
<AddPriFileDependsOn Condition="'$(MicrosoftPortableCurrentVersionPropsHasBeenImported)' == 'true'">DeterminePortableBuildCapabilities</AddPriFileDependsOn>
2020
<WarnOnPackingNonPackableProject Condition="'$(WarnOnPackingNonPackableProject)' == ''">false</WarnOnPackingNonPackableProject>
21+
<ImportNuGetBuildTasksPackTargetsFromSdk Condition="'$(ImportNuGetBuildTasksPackTargetsFromSdk)' == ''">false</ImportNuGetBuildTasksPackTargetsFromSdk>
2122
<DefaultAllowedOutputExtensionsInPackageBuildOutputFolder Condition="'$(DefaultAllowedOutputExtensionsInPackageBuildOutputFolder)' == ''">.dll;.exe;.winmd;.json;.pri;.xml</DefaultAllowedOutputExtensionsInPackageBuildOutputFolder>
2223
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(DefaultAllowedOutputExtensionsInPackageBuildOutputFolder);$(AllowedOutputExtensionsInPackageBuildOutputFolder)</AllowedOutputExtensionsInPackageBuildOutputFolder>
23-
<AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder>.pdb;.mdb;$(AllowedOutputExtensionsInPackageBuildOutputFolder);$(AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder)</AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder>
24+
<AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder Condition="'$(SymbolPackageFormat)' != 'snupkg'">.pdb;.mdb;$(AllowedOutputExtensionsInPackageBuildOutputFolder);$(AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder)</AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder>
2425
<AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder Condition="'$(SymbolPackageFormat)' == 'snupkg'">.pdb</AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder>
2526
<SuppressDependenciesWhenPacking Condition="'$(SuppressDependenciesWhenPacking)' == ''">false</SuppressDependenciesWhenPacking>
2627
</PropertyGroup>
@@ -261,7 +262,7 @@
261262
DependsOnTargets="InitializeSourceControlInformation"
262263
Condition="'$(SourceControlInformationFeatureSupported)' == 'true'">
263264
<PropertyGroup>
264-
<!-- The project must specify PublishRepositoryUrl=true in order to publish the URL, in order to prevent inadvertent leak of internal URL. -->
265+
<!-- The project must specify PublishRepositoryUrl=true in order to publish the URL, in order to prevent inadvertent leak of internal URL -->
265266
<RepositoryUrl Condition="'$(RepositoryUrl)' == '' and '$(PublishRepositoryUrl)' == 'true'">$(PrivateRepositoryUrl)</RepositoryUrl>
266267
<RepositoryCommit Condition="'$(RepositoryCommit)' == ''">$(SourceRevisionId)</RepositoryCommit>
267268
</PropertyGroup>

Sources/NuGet.Build.Sdk/Core/NuGet.Restore.targets

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<Project>
2626

2727
<PropertyGroup>
28-
<!-- Mark that this target file has been loaded. -->
28+
<!-- Mark that this target file has been loaded -->
2929
<IsRestoreTargetsFileLoaded>true</IsRestoreTargetsFileLoaded>
3030
<!-- Do not hide errors and warnings by default -->
3131
<HideWarningsAndErrors Condition="'$(HideWarningsAndErrors)' == ''">false</HideWarningsAndErrors>
@@ -41,9 +41,9 @@
4141
<RestoreBuildInParallel Condition="'$(RestoreBuildInParallel)' == ''">true</RestoreBuildInParallel>
4242
<!-- Check if the restore target was executed on a sln file -->
4343
<_RestoreSolutionFileUsed Condition="'$(_RestoreSolutionFileUsed)' == '' AND '$(SolutionDir)' != '' AND '$(MSBuildProjectExtension)' == '.metaproj'">true</_RestoreSolutionFileUsed>
44-
<!-- We default to MSBuildInteractive. -->
44+
<!-- We default to MSBuildInteractive -->
4545
<NuGetInteractive Condition="'$(NuGetInteractive)' == ''">$(MSBuildInteractive)</NuGetInteractive>
46-
<!-- Mark that this targets file supports package download. -->
46+
<!-- Mark that this targets file supports package download -->
4747
<PackageDownloadSupported>true</PackageDownloadSupported>
4848
<!-- Mark that this targets file GetReferenceNearestTargetFrameworkTask task supports the TargetPlatformMoniker -->
4949
<GetReferenceNearestTargetFrameworkTaskSupportsTargetPlatformParameter>true</GetReferenceNearestTargetFrameworkTaskSupportsTargetPlatformParameter>
@@ -52,7 +52,7 @@
5252
</PropertyGroup>
5353

5454
<PropertyGroup>
55-
<!-- Exclude packages from changing restore inputs. -->
55+
<!-- Exclude packages from changing restore inputs -->
5656
<_GenerateRestoreGraphProjectEntryInputProperties>ExcludeRestorePackageImports=true</_GenerateRestoreGraphProjectEntryInputProperties>
5757

5858
<!--
@@ -70,7 +70,7 @@
7070
CustomAfterMicrosoftCommonCrossTargetingTargets=$(MSBuildThisFileFullPath);
7171
</_GenerateRestoreGraphProjectEntryInputProperties>
7272

73-
<!-- Include SolutionDir and SolutionName for solution restores and persist these properties during the walk. -->
73+
<!-- Include SolutionDir and SolutionName for solution restores and persist these properties during the walk -->
7474
<_GenerateRestoreGraphProjectEntryInputProperties Condition="'$(_RestoreSolutionFileUsed)' == 'true'">
7575
$(_GenerateRestoreGraphProjectEntryInputProperties);
7676
_RestoreSolutionFileUsed=true;
@@ -119,7 +119,7 @@
119119
============================================================
120120
-->
121121
<Target Name="GenerateRestoreGraphFile" DependsOnTargets="_GenerateRestoreGraph">
122-
<!-- Validate -->
122+
<!-- Validate -->
123123
<Error Condition="$(RestoreGraphOutputPath) == ''" Text="Please specify where to write the restore graph output files with the 'RestoreGraphOutputPath' property!"/>
124124

125125
<!-- Drop any duplicate items -->
@@ -267,7 +267,7 @@
267267
<_FilteredRestoreGraphProjectInputItems/>
268268
</ItemGroup>
269269

270-
<!-- Remove projects that do not support restore. -->
270+
<!-- Remove projects that do not support restore -->
271271
<!-- With SkipNonExistentTargets support -->
272272
<MSBuild Condition=" '$(RestoreUseSkipNonExistentTargets)' == 'true' "
273273
BuildInParallel="$(RestoreBuildInParallel)"
@@ -293,7 +293,7 @@
293293
ItemName="FilteredRestoreGraphProjectInputItems"/>
294294
</MSBuild>
295295

296-
<!-- Warn for projects that do not support restore. -->
296+
<!-- Warn for projects that do not support restore -->
297297
<WarnForInvalidProjectsTask
298298
Condition="'$(DisableWarnForInvalidRestoreProjects)' != 'true' AND '$(HideWarningsAndErrors)' != 'true'"
299299
AllProjects="@(FilteredRestoreGraphProjectInputItemsWithoutDuplicates)"
@@ -309,16 +309,16 @@
309309
<Target Name="_GenerateRestoreGraph"
310310
DependsOnTargets="_FilterRestoreGraphProjectInputItems;_GetAllRestoreProjectPathItems"
311311
Returns="@(_RestoreGraphEntry)">
312-
<Message Text="Generating dg file" Importance="low"/>
312+
<Message Text="Generating directed graph spec file" Importance="low"/>
313313
<Message Text="%(_RestoreProjectPathItems.Identity)" Importance="low"/>
314314

315-
<!-- Use all projects if RestoreRecursive is true. Otherwise use only the top level projects. -->
315+
<!-- Use all projects if RestoreRecursive is true. Otherwise use only the top level projects -->
316316
<ItemGroup>
317317
<_GenerateRestoreGraphProjectEntryInput Include="@(FilteredRestoreGraphProjectInputItems)" Condition="'$(RestoreRecursive)' != 'true'"/>
318318
<_GenerateRestoreGraphProjectEntryInput Include="@(_RestoreProjectPathItems)" Condition="'$(RestoreRecursive)' == 'true'"/>
319319
</ItemGroup>
320320

321-
<!-- Add top level entries to the direct restore list. These projects will also restore tools. -->
321+
<!-- Add top level entries to the direct restore list. These projects will also restore tools -->
322322
<MSBuild
323323
BuildInParallel="$(RestoreBuildInParallel)"
324324
Projects="@(_GenerateRestoreGraphProjectEntryInput)"
@@ -330,7 +330,7 @@
330330
ItemName="_RestoreGraphEntry"/>
331331
</MSBuild>
332332

333-
<!-- Generate a spec for every project including dependencies. -->
333+
<!-- Generate a spec for every project including dependencies -->
334334
<MSBuild
335335
BuildInParallel="$(RestoreBuildInParallel)"
336336
Projects="@(_RestoreProjectPathItems)"
@@ -416,7 +416,7 @@
416416
<Target Name="_GetProjectJsonPath"
417417
Returns="$(_CurrentProjectJsonPath)">
418418
<!-- Get project.json path -->
419-
<!-- Skip this if the project style is already set. -->
419+
<!-- Skip this if the project style is already set -->
420420
<GetRestoreProjectJsonPathTask
421421
ProjectPath="$(MSBuildProjectFullPath)"
422422
Condition="'$(RestoreProjectStyle)' == 'ProjectJson' OR '$(RestoreProjectStyle)' == ''">
@@ -433,7 +433,7 @@
433433
<Target Name="_GetRestoreProjectStyle"
434434
DependsOnTargets="_GetProjectJsonPath;CollectPackageReferences"
435435
Returns="$(RestoreProjectStyle);$(PackageReferenceCompatibleProjectStyle)">
436-
<!-- This may be overridden by setting RestoreProjectStyle in the project. -->
436+
<!-- This may be overridden by setting RestoreProjectStyle in the project -->
437437
<PropertyGroup>
438438
<_HasPackageReferenceItems Condition="@(PackageReference->Count()) > 0">true</_HasPackageReferenceItems>
439439
</PropertyGroup>
@@ -487,7 +487,7 @@
487487
<_RestoreProjectFramework/>
488488
</PropertyGroup>
489489

490-
<!-- For project.json projects target frameworks will be read from project.json. -->
490+
<!-- For project.json projects target frameworks will be read from project.json -->
491491
<GetProjectTargetFrameworksTask
492492
Condition="'$(RestoreProjectStyle)' != 'ProjectJson'"
493493
ProjectPath="$(MSBuildProjectFullPath)"
@@ -586,15 +586,15 @@
586586
<!--
587587
============================================================
588588
_GetRestoreSettingsAllFrameworks
589-
Generate items for a single framework.
589+
Generate items for all frameworks.
590590
============================================================
591591
-->
592592
<Target Name="_GetRestoreSettingsAllFrameworks"
593593
Condition="'$(TargetFrameworks)' != '' AND '$(PackageReferenceCompatibleProjectStyle)' == 'true'"
594594
DependsOnTargets="_GetRestoreTargetFrameworksAsItems;_GetRestoreProjectStyle"
595595
Returns="@(_RestoreSettingsPerFramework)">
596596

597-
<!-- Read additional sources and fallback folders for each framework -->
597+
<!-- Read additional sources and fallback folders for each framework -->
598598
<MSBuild
599599
BuildInParallel="$(RestoreBuildInParallel)"
600600
Projects="$(MSBuildProjectFullPath)"
@@ -708,7 +708,7 @@
708708
<RestorePackagesWithLockFile>$(RestorePackagesWithLockFile)</RestorePackagesWithLockFile>
709709
<NuGetLockFilePath>$(NuGetLockFilePath)</NuGetLockFilePath>
710710
<RestoreLockedMode>$(RestoreLockedMode)</RestoreLockedMode>
711-
<CentralPackageVersionsEnabled>$(_CentralPackageVersionsEnabled)</CentralPackageVersionsEnabled>
711+
<_CentralPackageVersionsEnabled>$(_CentralPackageVersionsEnabled)</_CentralPackageVersionsEnabled>
712712
</_RestoreGraphEntry>
713713
</ItemGroup>
714714

@@ -802,7 +802,7 @@
802802
DependsOnTargets="_GetRestoreTargetFrameworksAsItems"
803803
Returns="@(_RestoreGraphEntry)">
804804

805-
<!-- Get project and package references -->
805+
<!-- Get project and package references -->
806806
<!-- Evaluate for each framework -->
807807
<MSBuild
808808
BuildInParallel="$(RestoreBuildInParallel)"
@@ -981,7 +981,7 @@
981981
DependsOnTargets="_GetRestoreTargetFrameworksAsItems"
982982
Returns="@(_RestoreProjectPathItems)">
983983

984-
<!-- Get all project references for the current project -->
984+
<!-- Get all project references for the current project -->
985985
<!-- With SkipNonExistentTargets support -->
986986
<MSBuild
987987
Condition="'$(RestoreUseSkipNonExistentTargets)' == 'true'"
@@ -1023,7 +1023,7 @@
10231023
DependsOnTargets="_GenerateRestoreProjectPathItems"
10241024
Returns="@(_RestoreProjectPathItems)">
10251025

1026-
<!-- Walk project references -->
1026+
<!-- Walk project references -->
10271027
<!-- With SkipNonExistentTargets -->
10281028
<MSBuild
10291029
Condition="'$(RestoreUseSkipNonExistentTargets)' == 'true'"
@@ -1078,7 +1078,7 @@
10781078
DependsOnTargets="_FilterRestoreGraphProjectInputItems"
10791079
Returns="@(_RestoreProjectPathItems)">
10801080

1081-
<NuGetMessageTask Name="DeterminingProjectsToRestore" Importance="High" />
1081+
<NuGetMessageTask Name="DeterminingProjectsToRestore" Importance="High"/>
10821082

10831083
<!-- Walk projects -->
10841084
<!-- With SkipNonExistentTargets -->
@@ -1117,7 +1117,7 @@
11171117
ItemName="_RestoreProjectPathItemsWithoutDupes"/>
11181118
</RemoveDuplicates>
11191119

1120-
<!-- Remove projects that do not support restore. -->
1120+
<!-- Remove projects that do not support restore -->
11211121
<!-- With SkipNonExistentTargets -->
11221122
<MSBuild
11231123
Condition="'$(RestoreUseSkipNonExistentTargets)' == 'true'"

Sources/NuGet.Build.Sdk/Core/NuGet.Restore.tasks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<!-- NuGet's Common Tasks -->
1111
<UsingTask AssemblyFile="$(NuGetRestoreTasksAssembly)" TaskName="NuGet.Build.Tasks.NuGetMessageTask"/>
1212
<UsingTask AssemblyFile="$(NuGetRestoreTasksAssembly)" TaskName="NuGet.Build.Tasks.WarnForInvalidProjectsTask"/>
13-
<UsingTask AssemblyFile="$(NuGetRestoreTasksAssembly)" TaskName="NuGet.Build.Tasks.GetProjectTargetFrameworksTask"/>
1413
<UsingTask AssemblyFile="$(NuGetRestoreTasksAssembly)" TaskName="NuGet.Build.Tasks.GetCentralPackageVersionsTask"/>
14+
<UsingTask AssemblyFile="$(NuGetRestoreTasksAssembly)" TaskName="NuGet.Build.Tasks.GetProjectTargetFrameworksTask"/>
1515
<UsingTask AssemblyFile="$(NuGetRestoreTasksAssembly)" TaskName="NuGet.Build.Tasks.GetReferenceNearestTargetFrameworkTask"/>
1616

1717
<!-- NuGet's Restore specific Tasks -->

0 commit comments

Comments
 (0)