diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 6b3488e5356..f7c89a7a69f 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -44,5 +44,9 @@ https://github.com/dotnet/dotnet ab01524bbb2ef1eea0ffaef161b3ef5686e8f256 + + https://github.com/microsoft/testfx + 7d4c0f051d6e8d52daaa0f7f354d57e95c475a03 + diff --git a/eng/Versions.props b/eng/Versions.props index 35b2f33059e..632fa8826da 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -15,6 +15,7 @@ $(MicrosoftNETWorkloadEmscriptenCurrentManifest110100preview4PackageVersion) 11.0.100-preview.4.26215.121 0.11.5-preview.26215.121 + 4.3.0-preview.26224.6 10.0.7 11.0.0-preview.1.26104.118 diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs index f8f78db81f5..fc5e4e3ed81 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs @@ -6,6 +6,7 @@ using System.Globalization; using System.IO; using System.Linq; +using System.Reflection; using System.Text; using System.Threading; using System.Xml.Linq; @@ -27,6 +28,21 @@ public class BaseTest public string Root => Path.GetFullPath (XABuildPaths.TestOutputDirectory); + /// + /// Retrieves the value of an embedded in the test assembly. + /// + protected string GetAssemblyMetadataValue (string key) + { + var assembly = GetType ().Assembly; + var value = assembly + .GetCustomAttributes () + .FirstOrDefault (a => a.Key == key)?.Value; + if (value == null) { + throw new InvalidOperationException ($"AssemblyMetadata '{key}' not found in {assembly.GetName ().Name}"); + } + return value; + } + /// /// Checks if a commercial .NET for Android is available /// * Defaults to Assert.Ignore () diff --git a/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.csproj b/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.csproj index 1d1693df49f..051786dd116 100644 --- a/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.csproj +++ b/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.csproj @@ -45,6 +45,13 @@ + + + <_Parameter1>MSTestPackageVersion + <_Parameter2>$(MSTestPackageVersion) + + + diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs index 6d1d6ea5a8d..b1380a1bd5b 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs @@ -2248,15 +2248,23 @@ public void DotNetNewAndroidTest (string mode, AndroidRuntime runtime) var dotnet = new DotNetCLI (Path.Combine (projectDirectory, $"{templateName}.csproj")); Assert.IsTrue (dotnet.New ("androidtest"), "`dotnet new androidtest` should succeed"); + // Override the MSTest version from the template with the version used by our build + var msTestVersion = GetAssemblyMetadataValue ("MSTestPackageVersion"); + var csprojPath = Path.Combine (projectDirectory, $"{templateName}.csproj"); + var doc = XDocument.Load (csprojPath); + var ns = doc.Root?.Name.Namespace ?? XNamespace.None; + var msTestRef = doc.Descendants (ns + "PackageReference") + .FirstOrDefault (e => e.Attribute ("Include")?.Value == "MSTest"); + Assert.IsNotNull (msTestRef, "MSTest PackageReference should exist in the generated project"); + msTestRef.SetAttributeValue ("Version", msTestVersion); + doc.Save (csprojPath); + bool useMonoRuntime = runtime == AndroidRuntime.MonoVM; var buildParameters = new List { $"UseMonoRuntime={useMonoRuntime}", + "RestoreAdditionalProjectSources=https://pkgs.dev.azure.com/dnceng/public/_packaging/test-tools/nuget/v3/index.json", }; - if (runtime == AndroidRuntime.CoreCLR) { - Assert.Ignore ("https://github.com/dotnet/android/issues/11174"); - } - // Build and assert 0 warnings Assert.IsTrue (dotnet.Build (parameters: buildParameters.ToArray ()), "`dotnet build` should succeed"); dotnet.AssertHasNoWarnings ();