Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dotnet] Accept invalid runtime identifiers for Restore. #15357

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1734,7 +1734,7 @@

<Target Name="_ValidateRuntimeIdentifier"
Condition="'$(RuntimeIdentifier)' != '' And '$(_RuntimeIdentifierValidation)' != 'false' And '$(_RuntimeIdentifierIsRequired)' == 'true'"
BeforeTargets="Restore;Build;ResolvedFrameworkReference;ResolveRuntimePackAssets;ProcessFrameworkReferences">
BeforeTargets="Build;ResolvedFrameworkReference;ResolveRuntimePackAssets">
<PropertyGroup>
<_IsValidRuntimeIdentifier Condition="@(_XamarinValidRuntimeIdentifier->WithMetadataValue('Platform', '$(_PlatformName)')->WithMetadataValue('Filename', '$(RuntimeIdentifier)')->Count()) &gt; 0">true</_IsValidRuntimeIdentifier>
</PropertyGroup>
Expand Down
6 changes: 6 additions & 0 deletions tests/common/DotNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public static ExecutionResult AssertPublishFailure (string project, Dictionary<s
return rv;
}

public static ExecutionResult AssertRestore (string project, Dictionary<string, string> properties = null)
{
return Execute ("restore", project, properties, true);
}

public static ExecutionResult AssertBuild (string project, Dictionary<string, string> properties = null)
{
return Execute ("build", project, properties, true);
Expand Down Expand Up @@ -105,6 +110,7 @@ public static ExecutionResult Execute (string verb, string project, Dictionary<s
case "build":
case "pack":
case "publish":
case "restore":
var args = new List<string> ();
args.Add (verb);
args.Add (project);
Expand Down
16 changes: 16 additions & 0 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,22 @@ public void InvalidRuntimeIdentifier (ApplePlatform platform, string runtimeIden
Assert.AreEqual ($"The RuntimeIdentifier '{runtimeIdentifier}' is invalid.", uniqueErrors [0], "Error message");
}

[Test]
[TestCase (ApplePlatform.iOS, "win10-x86")]
[TestCase (ApplePlatform.TVOS, "win10-x64")]
[TestCase (ApplePlatform.MacOSX, "win10-arm")]
[TestCase (ApplePlatform.MacCatalyst, "win10-arm64")]
public void InvalidRuntimeIdentifier_Restore (ApplePlatform platform, string runtimeIdentifier)
{
var project = "MySimpleApp";
Configuration.IgnoreIfIgnoredPlatform (platform);

var project_path = GetProjectPath (project, platform: platform);
Clean (project_path);
var properties = GetDefaultProperties (runtimeIdentifier);
DotNet.AssertRestore (project_path, properties);
}

[Test]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64")]
public void FilesInAppBundle (ApplePlatform platform, string runtimeIdentifiers)
Expand Down