From 4889bf025bf2d99775d7921266b1211240e71ba7 Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Thu, 30 Nov 2023 06:13:07 -1000 Subject: [PATCH] [MSBuildReferences.projitems] Require opt-in to use `Microsoft.Build` (#220) Projects that import `MSBuildReferences.projitems` receive a `@(PackageReference)` to the `Microsoft.Build` NuGet package. However, many consumers have `$(TargetFramework)`=netstandard2.0, and the `Microsoft.Build` package does not have support netstandard2.0, resulting in the following warnings: Warning NU1701 Package 'Microsoft.Build 17.3.2' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project. Warning NU1701 Package 'Microsoft.IO.Redist 6.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project. Most consumers do not actually need this package, so we can make it opt-in to prevent the warnings and extra dependencies in those projects. Packages opt-in to referencing the `Microsoft.Build` package by setting the `$(_IncludeMicrosoftBuildPackage)` MSBuild property to true: <_IncludeMicrosoftBuildPackage>true Note: this will be a "breaking" change to an unknown amount of consumers. We're crossing our fingers that this won't break too much. Enabling this change fixes 226 CI warnings in xamarin-android. --- .../MSBuildReferences.projitems | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Android.Build.BaseTasks/MSBuildReferences.projitems b/src/Microsoft.Android.Build.BaseTasks/MSBuildReferences.projitems index 4c6a97c..91a10a3 100644 --- a/src/Microsoft.Android.Build.BaseTasks/MSBuildReferences.projitems +++ b/src/Microsoft.Android.Build.BaseTasks/MSBuildReferences.projitems @@ -11,7 +11,7 @@ - +