diff --git a/Configuration.props b/Configuration.props index a38424b5179..e7f6aa27f32 100644 --- a/Configuration.props +++ b/Configuration.props @@ -47,7 +47,7 @@ portable True latest - 32.0.476 + 32.0.485 Windows diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs index bb009c736de..fc71d167495 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs @@ -303,12 +303,8 @@ public String Say (String quote) { }", }, }, - ExtraNuGetConfigSources = { - // Projects targeting net6.0 require ref/runtime packs on NuGet.org - "https://api.nuget.org/v3/index.json", - "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json", - }, }; + proj.AddNuGetSourcesForOlderTargetFrameworks (); if (IsPreviewFrameworkVersion (targetFramework)) { proj.SetProperty ("EnablePreviewFeatures", "true"); } @@ -841,12 +837,8 @@ public void DotNetPublish ([Values (false, true)] bool isRelease, [ValueSource(n var proj = new XASdkProject { TargetFramework = targetFramework, IsRelease = isRelease, - ExtraNuGetConfigSources = { - // Projects targeting net6.0 require ref/runtime packs on NuGet.org - "https://api.nuget.org/v3/index.json", - "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json", - }, }; + proj.AddNuGetSourcesForOlderTargetFrameworks (); proj.SetProperty (KnownProperties.RuntimeIdentifier, runtimeIdentifier); var preview = IsPreviewFrameworkVersion (targetFramework); @@ -935,13 +927,9 @@ public void XamarinLegacySdk ([Values ("net6.0-android32.0", "net7.0-android33.0 new AndroidItem.AndroidLibrary ("javaclasses.jar") { BinaryContent = () => ResourceData.JavaSourceJarTestJar, } - }, - ExtraNuGetConfigSources = { - // Projects targeting net6.0 require ref/runtime packs on NuGet.org - "https://api.nuget.org/v3/index.json", - "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json", - }, + } }; + proj.AddNuGetSourcesForOlderTargetFrameworks (dotnetTargetFramework); using var b = new Builder (); var legacyTargetFrameworkVersion = "13.0"; @@ -969,12 +957,8 @@ public void MauiTargetFramework (string dotnetVersion, string platform, int apiL var targetFramework = $"{dotnetVersion}-{platform}"; var library = new XASdkProject (outputType: "Library") { TargetFramework = targetFramework, - ExtraNuGetConfigSources = { - // Projects targeting net6.0 require ref/runtime packs on NuGet.org - "https://api.nuget.org/v3/index.json", - "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json", - }, }; + library.AddNuGetSourcesForOlderTargetFrameworks (); var preview = IsPreviewFrameworkVersion (targetFramework); if (preview) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetStandard.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetStandard.cs index 95ba72809c5..e5144738481 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetStandard.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetStandard.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -34,6 +34,21 @@ public string TargetFramework { get { return GetProperty ("TargetFramework"); } set { SetProperty ("TargetFramework", value); } } + + /// + /// Projects targeting net6.0/net7.0 require ref/runtime packs on NuGet.org or dotnet6/dotnet7 + /// + public void AddNuGetSourcesForOlderTargetFrameworks (string targetFramework = null) + { + targetFramework ??= TargetFramework; + if (targetFramework.IndexOf ("net6.0", StringComparison.OrdinalIgnoreCase) != -1) { + ExtraNuGetConfigSources = new List { + "https://api.nuget.org/v3/index.json", + "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json", + }; + } + } + public string Sdk { get; set; } public IList OtherBuildItems { get; private set; } diff --git a/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs b/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs index e6dddedb980..cb3cde43781 100644 --- a/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs @@ -74,13 +74,7 @@ public void DotNetInstallAndRun (bool isRelease, bool xamarinForms, string targe }; } proj.TargetFramework = targetFramework; - if (targetFramework.Contains ("net6.0")) { - proj.ExtraNuGetConfigSources = new List () { - // Projects targeting net6.0 require ref/runtime packs on NuGet.org or dotnet6 - "https://api.nuget.org/v3/index.json", - "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json", - }; - } + proj.AddNuGetSourcesForOlderTargetFrameworks (); proj.SetRuntimeIdentifier (DeviceAbi); var relativeProjDir = Path.Combine ("temp", TestName); @@ -160,13 +154,7 @@ public void DotNetDebug ([Values("net6.0-android", "net7.0-android")] string tar var proj = new XASdkProject (); proj.TargetFramework = targetFramework; - if (targetFramework.Contains ("net6.0")) { - proj.ExtraNuGetConfigSources = new List () { - // Projects targeting net6.0 require ref/runtime packs on NuGet.org or dotnet6 - "https://api.nuget.org/v3/index.json", - "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json", - }; - } + proj.AddNuGetSourcesForOlderTargetFrameworks (); proj.SetRuntimeIdentifier (DeviceAbi); string runtimeId = proj.GetProperty (KnownProperties.RuntimeIdentifier);