Skip to content

Commit b595e11

Browse files
authored
[build] Use netstandard2.0 for all workload packs (#5812)
Context: #5806 Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=4614104&view=logs&j=96fd57f5-f69e-53c7-3d47-f67e6cf9b93e&t=9492f091-fb29-57d7-1f68-ecbf86da9c24 PR #5806 (currently a draft) bumped the system mono and msbuild on various CI machines. As these machines are *not* VMs, and do *not* "start from clean" for every PR build (for performance reasons), the inadvertent result is that *every subsequent build* on these machines now *fails* when packing our workload .nupkg files: /Users/builder/.dotnet/sdk/5.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(141,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 6.0. Either target .NET Core 5.0 or lower, or use a version of the .NET SDK that supports .NET Core 6.0. [/Users/builder/azdo/_work/1/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj] The target framework used by the projects that create our workload packs should not matter; they do not need to be `net6.0`. Update `$(TargetFramework)` to `netstandard2.0`, which improves compatibility when restoring, packing, or otherwise using these projects to invoke other targets. The `$(TargetFramework)` value *does* end up in the `.nuspec` file in these packages however, but we can prevent this by setting the [`$(SuppressDependenciesWhenPacking)` property][0] to true: <SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking> Finally, these packages use the DotnetPlatform or Template PackageType and are not intended to be functional NuGets. We can suppress certain nuspec related warnings to clean up build output: …\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5128: Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder do not have exact matches in the other location. Consult the list of actions below: …\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5128: - Add lib or ref assemblies for the netstandard2.0 target framework …\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5130: Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder have compatible matches, but not exact matches in the other location. Unless intentional, consult the list of actions below: …\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5130: - Add a dependency group for net6.0 to the nuspec …\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5131: References were found in the nuspec, but some reference assemblies were not found in both the nuspec and ref folder. Add the following reference assemblies: …\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5131: - Add Java.Interop.dll to the net6.0 reference group in the nuspec …\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5131: - Add Mono.Android.dll to the net6.0 reference group in the nuspec …\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5131: - Add Mono.Android.Export.dll to the net6.0 reference group in the nuspec …\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5131: - Add mono.android.jar to the net6.0 reference group in the nuspec …\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5131: - Add mono.android.dex to the net6.0 reference group in the nuspec …\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5131: - Add AndroidApiInfo.xml to the net6.0 reference group in the nuspec [0]: https://docs.microsoft.com/nuget/reference/msbuild-targets#pack-target-inputs
1 parent 12da145 commit b595e11

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

build-tools/create-packs/Directory.Build.props

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
<Import Project="..\..\Directory.Build.props" />
33

44
<PropertyGroup>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>netstandard2.0</TargetFramework>
66
<PackageType>DotnetPlatform</PackageType>
77
<Authors>Microsoft</Authors>
88
<OutputPath>..\..\bin\Build$(Configuration)\nuget-unsigned\</OutputPath>
99
<GenerateDependencyFile>false</GenerateDependencyFile>
1010
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
11+
<!-- Remove the `<group targetFramework=".NETStandard2.0" />` entry from the .nuspec. -->
12+
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
13+
<!-- Ignore TargetFramework reference group related warnings, these are workload packs not functional NuGets. -->
14+
<NoWarn>$(NoWarn);NU5128;NU5131</NoWarn>
1115
</PropertyGroup>
1216

1317
</Project>

src/Microsoft.Android.Templates/Microsoft.Android.Templates.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<IncludeBuildOutput>false</IncludeBuildOutput>
1212
<ContentTargetFolders>content</ContentTargetFolders>
1313
<OutputPath>..\..\bin\Build$(Configuration)\nuget-unsigned\</OutputPath>
14+
<!-- Remove the `<group targetFramework=".NETStandard2.0" />` entry from the .nuspec. -->
15+
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
1416
</PropertyGroup>
1517

1618
<Import Project="..\..\Configuration.props" />

0 commit comments

Comments
 (0)