Skip to content

Commit

Permalink
Add CollectNuGetAuditSupressions target
Browse files Browse the repository at this point in the history
Related to PR dotnet#9470.

After PR dotnet#9470, VS and C# Dev Kit will attempt to collect NuGet audit suppression items via the `CollectNuGetAuditSuppressions` target. However, this target new to the 8.0.400 version of the .NET SDK. If a project is using an older version of the SDK our design-time build will now fail with complaints that the target doesn't exist.

To work around this, here we update Microsoft.Managed.DesignTime.targets to include a no-op version of the target. This file ships with VS and the C# Dev Kit, not the SDK, and so we can guarantee that the target will always be present when we need it. The real definition in the SDK is in NuGet.targets; this file is imported _after_ Microsoft.Managed.DesignTime.targets and so the real definition, when it exists, will automatically replace the no-op definition.
  • Loading branch information
tmeschter committed Jun 14, 2024
1 parent 8fdde78 commit df5a2b5
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@
sent to NuGet to be restored.-->
<Target Name="CollectPackageReferences" Returns="@(PackageReference)" />

<!-- This target is used to collect the NuGet audit supression items. It is defined by the .NET SDK starting in version 8.0.400, but we need this no-op
implementation when using older SDKs that don't have it; otherwise our design-time builds will fail. The NuGet.targets file in the SDK is imported
_after_ this file, and will override this implementation with the real one (when present).
This can (and should) be removed when we no longer need to support SDKs older than 8.0.400. -->
<Target Name="CollectNuGetAuditSuppressions" Returns="@(NuGetAuditSuppress)" />

<!-- This target is used to collect the SuggestedWorkload items in the project.-->
<Target Name="CollectSuggestedWorkloads"
Returns="@(SuggestedWorkload)"
Expand Down

0 comments on commit df5a2b5

Please sign in to comment.