Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,9 @@
<Uri>https://github.com/dotnet/dotnet</Uri>
<Sha>ab01524bbb2ef1eea0ffaef161b3ef5686e8f256</Sha>
</Dependency>
<Dependency Name="MSTest" Version="4.3.0-preview.26224.6">
<Uri>https://github.com/microsoft/testfx</Uri>
<Sha>7d4c0f051d6e8d52daaa0f7f354d57e95c475a03</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<MicrosoftNETWorkloadEmscriptenPackageVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest110100preview4PackageVersion)</MicrosoftNETWorkloadEmscriptenPackageVersion>
<MicrosoftTemplateEngineAuthoringTasksPackageVersion>11.0.100-preview.4.26215.121</MicrosoftTemplateEngineAuthoringTasksPackageVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.5-preview.26215.121</MicrosoftDotNetCecilPackageVersion>
<MSTestPackageVersion>4.3.0-preview.26224.6</MSTestPackageVersion>
<SystemIOHashingPackageVersion>10.0.7</SystemIOHashingPackageVersion>
<SystemReflectionMetadataPackageVersion>11.0.0-preview.1.26104.118</SystemReflectionMetadataPackageVersion>
<!-- Previous .NET Android version -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,6 +28,21 @@ public class BaseTest

public string Root => Path.GetFullPath (XABuildPaths.TestOutputDirectory);

/// <summary>
/// Retrieves the value of an <see cref="AssemblyMetadataAttribute"/> embedded in the test assembly.
/// </summary>
protected string GetAssemblyMetadataValue (string key)
{
var assembly = GetType ().Assembly;
var value = assembly
.GetCustomAttributes<AssemblyMetadataAttribute> ()
.FirstOrDefault (a => a.Key == key)?.Value;
if (value == null) {
throw new InvalidOperationException ($"AssemblyMetadata '{key}' not found in {assembly.GetName ().Name}");
}
return value;
}

/// <summary>
/// Checks if a commercial .NET for Android is available
/// * Defaults to Assert.Ignore ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
<PackageReference Include="Humanizer" Version="$(HumanizerVersion)" />
</ItemGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>MSTestPackageVersion</_Parameter1>
<_Parameter2>$(MSTestPackageVersion)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Xamarin.Android.Build.Tasks\Xamarin.Android.Build.Tasks.csproj" />
<ProjectReference Include="..\..\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Xamarin.ProjectTools.csproj" />
Expand Down
16 changes: 12 additions & 4 deletions tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
$"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 ();
Expand Down