Skip to content

Commit

Permalink
Allow overrides for Restore properties
Browse files Browse the repository at this point in the history
- Allow overrides for properties such as
  1. `ManagePackageVersionsCentrally`
  2. `RestoreEnableGlobalPackageReference`
  3. `DisableCheckingDuplicatePackage(Download|Reference|Version)s`
  • Loading branch information
Nirmal4G committed Dec 11, 2021
1 parent e1ec300 commit 8f08ac3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions Sources/NuGet.Build.Sdk/Core/NuGet.Restore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
<!-- Design-Time builds should not produce a build error. So, we need to ensure that we continue on error -->
<PropertyGroup>
<CollectPackageReferencesContinueOnError>$([MSBuild]::ValueOrDefault($(ContinueOnError), 'false'))</CollectPackageReferencesContinueOnError>
<DisableCheckingDuplicatePackageReferences>$([MSBuild]::ValueOrDefault($(DisableCheckingDuplicateNuGetItems), $(DisableCheckingDuplicatePackageReferences)))</DisableCheckingDuplicatePackageReferences>
</PropertyGroup>

<CheckForDuplicateNuGetItemsTask
Expand All @@ -195,7 +196,7 @@
TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
MSBuildProjectFullPath="$(MSBuildProjectFullPath)"
ContinueOnError="$(CollectPackageReferencesContinueOnError)"
Condition="'$(DisableCheckingDuplicateNuGetItems)' != 'true'">
Condition="'$(DisableCheckingDuplicatePackageReferences)' != 'true'">
<Output TaskParameter="DeduplicatedItems" ItemName="DeduplicatedPackageReference"/>
</CheckForDuplicateNuGetItemsTask>

Expand All @@ -220,6 +221,7 @@
<!-- Design-Time builds should not produce a build error. So, we need to ensure that we continue on error -->
<PropertyGroup>
<CollectCentralPackageVersionsContinueOnError>$([MSBuild]::ValueOrDefault($(ContinueOnError), 'false'))</CollectCentralPackageVersionsContinueOnError>
<DisableCheckingDuplicatePackageVersions>$([MSBuild]::ValueOrDefault($(DisableCheckingDuplicateNuGetItems), $(DisableCheckingDuplicatePackageVersions)))</DisableCheckingDuplicatePackageVersions>
</PropertyGroup>

<CheckForDuplicateNuGetItemsTask
Expand All @@ -231,7 +233,7 @@
TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
MSBuildProjectFullPath="$(MSBuildProjectFullPath)"
ContinueOnError="$(CollectCentralPackageVersionsContinueOnError)"
Condition="'$(DisableCheckingDuplicateNuGetItems)' != 'true'">
Condition="'$(DisableCheckingDuplicatePackageVersions)' != 'true'">
<Output TaskParameter="DeduplicatedItems" ItemName="DeduplicatedPackageVersion"/>
</CheckForDuplicateNuGetItemsTask>

Expand All @@ -256,6 +258,7 @@
<!-- Design-Time builds should not produce a build error. So, we need to ensure that we continue on error -->
<PropertyGroup>
<CollectPackageDownloadsContinueOnError>$([MSBuild]::ValueOrDefault($(ContinueOnError), 'false'))</CollectPackageDownloadsContinueOnError>
<DisableCheckingDuplicatePackageDownloads>$([MSBuild]::ValueOrDefault($(DisableCheckingDuplicateNuGetItems), $(DisableCheckingDuplicatePackageDownloads)))</DisableCheckingDuplicatePackageDownloads>
</PropertyGroup>

<CheckForDuplicateNuGetItemsTask
Expand All @@ -267,7 +270,7 @@
TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
MSBuildProjectFullPath="$(MSBuildProjectFullPath)"
ContinueOnError="$(CollectPackageDownloadsContinueOnError)"
Condition="'$(DisableCheckingDuplicateNuGetItems)' != 'true'">
Condition="'$(DisableCheckingDuplicatePackageDownloads)' != 'true'">
<Output TaskParameter="DeduplicatedItems" ItemName="DeduplicatedPackageDownload"/>
</CheckForDuplicateNuGetItemsTask>

Expand Down
4 changes: 2 additions & 2 deletions Sources/NuGet.Build.Sdk/Extensions/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
<Import Project="$(DirectoryPackagesProps)" Condition="Exists('$(DirectoryPackagesProps)')"/>

<PropertyGroup Condition="Exists('$(DirectoryPackagesProps)')">
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageVersionsFileImported>true</CentralPackageVersionsFileImported>
<RestoreEnableGlobalPackageReference>true</RestoreEnableGlobalPackageReference>
<ManagePackageVersionsCentrally Condition="'$(ManagePackageVersionsCentrally)' == ''">true</ManagePackageVersionsCentrally>
<RestoreEnableGlobalPackageReference Condition="'$(RestoreEnableGlobalPackageReference)' == ''">true</RestoreEnableGlobalPackageReference>
</PropertyGroup>

</Project>

0 comments on commit 8f08ac3

Please sign in to comment.