From 3b6b9d0576ee79fc80d91a1d7375b8060ba14f4d Mon Sep 17 00:00:00 2001 From: Nirmal Guru Date: Thu, 4 Nov 2021 08:37:15 +0530 Subject: [PATCH 1/4] Produce reference assembly in new `ref` output folder Previously, we were producing the reference assembly in the `OutputPath` directory. But we also want to produce the reference assembly in a folder `ref` beside `bin` folder. With that, introduce `ProduceReferenceAssemblyInOutputPath` to control output directory preference; the `BaseReferenceOutputPath` and `ReferenceOutputPath` as the goto destination for reference assemblies! --- .../Microsoft.Common.CurrentVersion.targets | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Sources/MSBuild.NET.Legacy.Sdk/Sdk/Microsoft.Common.CurrentVersion.targets b/Sources/MSBuild.NET.Legacy.Sdk/Sdk/Microsoft.Common.CurrentVersion.targets index 08d2e23..8fb6549 100644 --- a/Sources/MSBuild.NET.Legacy.Sdk/Sdk/Microsoft.Common.CurrentVersion.targets +++ b/Sources/MSBuild.NET.Legacy.Sdk/Sdk/Microsoft.Common.CurrentVersion.targets @@ -165,6 +165,23 @@ false + + + false + + + + + $(BuildDir)ref\ + $(BaseReferenceOutputPath)\ + $(BaseReferenceOutputPath)$(Configuration)\ + $(BaseReferenceOutputPath)$(Platform)\$(Configuration)\ + $(ReferenceOutputPath)\ + + $(TargetDir)$(TargetFileName) + + + - $([MSBuild]::NormalizePath('$(TargetDir)', 'ref', '$(TargetFileName)')) + $([MSBuild]::NormalizePath('$(TargetDir)', 'ref', '$(TargetFileName)')) + + $([MSBuild]::NormalizePath('$(ReferenceOutputPath)', '$(TargetFileName)')) @@ -361,7 +383,8 @@ - + + From e1ec30060d819d674154d8cc902dd150f0fd9c54 Mon Sep 17 00:00:00 2001 From: Nirmal Guru Date: Wed, 8 Dec 2021 09:02:34 +0530 Subject: [PATCH 2/4] Check and De-Duplicate NuGet Items - Check, Warn and De-Duplicate NuGet Items This applies to `PackageReference`, `PackageVersion` and `PackageDownload` item types. --- .../Core/NuGet.Restore.targets | 91 +++++++++++++++++-- .../NuGet.Build.Sdk/Tasks/NuGet.Restore.tasks | 1 + 2 files changed, 84 insertions(+), 8 deletions(-) diff --git a/Sources/NuGet.Build.Sdk/Core/NuGet.Restore.targets b/Sources/NuGet.Build.Sdk/Core/NuGet.Restore.targets index 70d1a24..2ce4df2 100644 --- a/Sources/NuGet.Build.Sdk/Core/NuGet.Restore.targets +++ b/Sources/NuGet.Build.Sdk/Core/NuGet.Restore.targets @@ -174,33 +174,108 @@ CollectPackageReferences Gathers all PackageReference items from the project. - This target may be used as an extension point to modify - package references before NuGet reads them. + This target may be used as a pivot point for 'BeforeTargets' + extension point (do not use 'AfterTargets') to modify + package downloads before NuGet reads them. ============================================================ --> - + + + + + $([MSBuild]::ValueOrDefault($(ContinueOnError), 'false')) + + + + + + + + + + + - + + + + + $([MSBuild]::ValueOrDefault($(ContinueOnError), 'false')) + + + + + + + + + + + - + + + + + $([MSBuild]::ValueOrDefault($(ContinueOnError), 'false')) + + + + + + + + + + + + From 8f08ac329ba95a81d20823faefabceb3b25ccbcd Mon Sep 17 00:00:00 2001 From: Nirmal Guru Date: Wed, 8 Dec 2021 09:05:27 +0530 Subject: [PATCH 3/4] Allow overrides for Restore properties - Allow overrides for properties such as 1. `ManagePackageVersionsCentrally` 2. `RestoreEnableGlobalPackageReference` 3. `DisableCheckingDuplicatePackage(Download|Reference|Version)s` --- Sources/NuGet.Build.Sdk/Core/NuGet.Restore.targets | 9 ++++++--- .../NuGet.Build.Sdk/Extensions/Directory.Packages.props | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Sources/NuGet.Build.Sdk/Core/NuGet.Restore.targets b/Sources/NuGet.Build.Sdk/Core/NuGet.Restore.targets index 2ce4df2..558e6d3 100644 --- a/Sources/NuGet.Build.Sdk/Core/NuGet.Restore.targets +++ b/Sources/NuGet.Build.Sdk/Core/NuGet.Restore.targets @@ -184,6 +184,7 @@ $([MSBuild]::ValueOrDefault($(ContinueOnError), 'false')) + $([MSBuild]::ValueOrDefault($(DisableCheckingDuplicateNuGetItems), $(DisableCheckingDuplicatePackageReferences))) + Condition="'$(DisableCheckingDuplicatePackageReferences)' != 'true'"> @@ -220,6 +221,7 @@ $([MSBuild]::ValueOrDefault($(ContinueOnError), 'false')) + $([MSBuild]::ValueOrDefault($(DisableCheckingDuplicateNuGetItems), $(DisableCheckingDuplicatePackageVersions))) + Condition="'$(DisableCheckingDuplicatePackageVersions)' != 'true'"> @@ -256,6 +258,7 @@ $([MSBuild]::ValueOrDefault($(ContinueOnError), 'false')) + $([MSBuild]::ValueOrDefault($(DisableCheckingDuplicateNuGetItems), $(DisableCheckingDuplicatePackageDownloads))) + Condition="'$(DisableCheckingDuplicatePackageDownloads)' != 'true'"> diff --git a/Sources/NuGet.Build.Sdk/Extensions/Directory.Packages.props b/Sources/NuGet.Build.Sdk/Extensions/Directory.Packages.props index 7e17724..2716743 100644 --- a/Sources/NuGet.Build.Sdk/Extensions/Directory.Packages.props +++ b/Sources/NuGet.Build.Sdk/Extensions/Directory.Packages.props @@ -45,9 +45,9 @@ - true true - true + true + true \ No newline at end of file From 4a563163cd055d0f5e7d13ac94f9f47994012017 Mon Sep 17 00:00:00 2001 From: Nirmal Guru Date: Wed, 8 Dec 2021 09:10:57 +0530 Subject: [PATCH 4/4] Prefer "TargetFramework" when specified globally - Prefer "TargetFramework" over its plural counterpart when specified globally, like on the command-line and in the MSBuild task, Properties metadata. - This also adds a "GetGlobalPropertyValueTask" for getting global properties. --- .../Core/NuGet.Restore.targets | 34 ++++++++++++++++--- .../NuGet.Build.Sdk/Tasks/NuGet.Restore.tasks | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Sources/NuGet.Build.Sdk/Core/NuGet.Restore.targets b/Sources/NuGet.Build.Sdk/Core/NuGet.Restore.targets index 558e6d3..f51ddb4 100644 --- a/Sources/NuGet.Build.Sdk/Core/NuGet.Restore.targets +++ b/Sources/NuGet.Build.Sdk/Core/NuGet.Restore.targets @@ -597,18 +597,20 @@ ============================================================ --> <_RestoreProjectFramework/> + <_PreferredTargetFrameworks Condition="'$(_IsGlobalTargetFramework)' == 'true'">$(TargetFramework) + <_PreferredTargetFrameworks Condition="'$(_IsGlobalTargetFramework)' != 'true'">$(TargetFrameworks) - <_RestoreTargetFrameworkItems Include="$(TargetFrameworks.Split(';'))"/> + <_RestoreTargetFrameworkItems Include="$(TargetFrameworks.Split(';'))" Condition="'$(_IsGlobalTargetFramework)' != 'true'"/> + + <_RestoreTargetFrameworkItems Include="$(TargetFramework)" Condition="'$(_IsGlobalTargetFramework)' == 'true'"/> @@ -1376,6 +1381,27 @@ + + + + + + + + + + <_IsGlobalTargetFramework Condition="'$(_GlobalTargetFramework)' == '$(TargetFramework)'">true + + + +