Skip to content

Commit

Permalink
[release/7.0.3xx] [msbuild] Add support to the ResolveNativeReference…
Browse files Browse the repository at this point in the history
…s task to execute remotely. Fixes #19027. (#19048)

It looks like ResolveNativeReferences was always intended to execute remotely
from Windows (when used in the _ExpandNativeReferences target, the task is
given a session id, and only called when IsMacEnabled=true), but the task
itself never implemented the code to execute remotely.

Weirdly enough this was never an issue, because the task never did something
that had to be done on a Mac.

That is, until recently, when the task learned to decompress zip files, by
executing /usr/bin/unzip.

Obviously this doesn't work on Windows, so fix it by adding support for the
task to execute remotely.

Fixes #19027.

Backport of #19047.
  • Loading branch information
rolfbjarne committed Sep 20, 2023
1 parent c3b9c48 commit 14a9d8d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
4 changes: 0 additions & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/ResolveNativeReferences.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Xml;

using Microsoft.Build.Framework;
Expand All @@ -10,12 +11,13 @@
using Xamarin.MacDev;
using Xamarin.MacDev.Tasks;
using Xamarin.Localization.MSBuild;
using Xamarin.Messaging.Build.Client;

#nullable enable

namespace Xamarin.MacDev.Tasks {

public abstract class ResolveNativeReferencesBase : XamarinTask {
public class ResolveNativeReferences : XamarinTask, ITaskCallback {
#region Inputs

[Required]
Expand Down Expand Up @@ -57,6 +59,14 @@ public abstract class ResolveNativeReferencesBase : XamarinTask {
}

public override bool Execute ()
{
if (ShouldExecuteRemotely ())
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;

return ExecuteLocally ();
}

bool ExecuteLocally ()
{
var native_frameworks = new List<ITaskItem> ();

Expand Down Expand Up @@ -270,5 +280,24 @@ void ProcessSidecar (ITaskItem r, string resources, List<ITaskItem> native_frame
}
return String.Empty;
}

public void Cancel ()
{
if (ShouldExecuteRemotely ())
BuildConnection.CancelAsync (BuildEngine4).Wait ();
}

public bool ShouldCopyToBuildServer (ITaskItem item) => true;

public bool ShouldCreateOutputFile (ITaskItem item)
{
// Don't copy any files to Windows, because
// 1. They're not used in Inputs/Outputs, so the lack of them won't affect anything
// 2. They may be directories, and as such we'd have to expand them to (potentially numerous and large) files to copy them (uselessly) to Windows.
// 3. They may contain symlinks, which may not work correctly on Windows.
return false;
}

public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied () => Enumerable.Empty<ITaskItem> ();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Xcode12_x (string platform, string variant, string architecture, str
// on Xcode 12.2+ you get arm64 for all (iOS, tvOS and watchOS) simulators
var path = Path.Combine (Path.GetDirectoryName (GetType ().Assembly.Location), "Resources", "xcf-xcode12.2.plist");
var plist = PDictionary.FromFile (path);
var result = ResolveNativeReferencesBase.ResolveXCFramework (plist, platform, variant, architecture);
var result = ResolveNativeReferences.ResolveXCFramework (plist, platform, variant, architecture);
Assert.That (result, Is.EqualTo (expected), expected);
}

Expand All @@ -42,15 +42,15 @@ public void PreXcode12 (string platform, string variant, string architecture, st
{
var path = Path.Combine (Path.GetDirectoryName (GetType ().Assembly.Location), "Resources", "xcf-prexcode12.plist");
var plist = PDictionary.FromFile (path);
var result = ResolveNativeReferencesBase.ResolveXCFramework (plist, platform, variant, architecture);
var result = ResolveNativeReferences.ResolveXCFramework (plist, platform, variant, architecture);
Assert.That (result, Is.EqualTo (expected), expected);
}

[Test]
public void BadInfoPlist ()
{
var plist = new PDictionary ();
var result = ResolveNativeReferencesBase.ResolveXCFramework (plist, "iOS", null, "x86_64");
var result = ResolveNativeReferences.ResolveXCFramework (plist, "iOS", null, "x86_64");
Assert.Null (result, "Invalid Info.plist");
}
}
Expand Down

8 comments on commit 14a9d8d

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS M1 - Mac Big Sur (11.5) passed 💻

All tests on macOS M1 - Mac Big Sur (11.5) passed.

Pipeline on Agent
Hash: 14a9d8d77450b06c33062edd2f009f405c84f7cf [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS M1 - Mac Ventura (13.0) passed 💻

All tests on macOS M1 - Mac Ventura (13.0) passed.

Pipeline on Agent
Hash: 14a9d8d77450b06c33062edd2f009f405c84f7cf [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Windows Integration Tests passed 💻

All Windows Integration Tests passed.

Pipeline on Agent
Hash: 14a9d8d77450b06c33062edd2f009f405c84f7cf [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ API diff for current PR / commit

NET (empty diffs)
  • iOS: (empty diff detected)
  • tvOS: (empty diff detected)
  • MacCatalyst: (empty diff detected)
  • macOS: (empty diff detected)

✅ API diff vs stable

.NET (No breaking changes)

✅ Generator diff

Generator diff is empty

Pipeline on Agent
Hash: 14a9d8d77450b06c33062edd2f009f405c84f7cf [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📚 [CI Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMMINI-070.Ventura
Hash: 14a9d8d77450b06c33062edd2f009f405c84f7cf [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 [CI Build] Test results 🔥

Test results

❌ Tests failed on VSTS: simulator tests

0 tests crashed, 1 tests failed, 78 tests passed.

Failures

❌ dotnettests tests

1 tests failed, 0 tests passed.
  • DotNet tests: Failed (Execution failed with exit code 1)

Html Report (VSDrops) Download

Successes

⚠️ bcl: No tests selected. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ framework: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 1 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 4 tests passed. Html Report (VSDrops) Download
⚠️ install_source: No tests selected. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 40 tests passed. Html Report (VSDrops) Download
⚠️ mac_binding_project: No tests selected. Html Report (VSDrops) Download
⚠️ mmp: No tests selected. Html Report (VSDrops) Download
⚠️ mononative: No tests selected. Html Report (VSDrops) Download
✅ monotouch: All 13 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
⚠️ mtouch: No tests selected. Html Report (VSDrops) Download
⚠️ xammac: No tests selected. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 14a9d8d77450b06c33062edd2f009f405c84f7cf [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 [CI Build] Test results 🔥

Test results

❌ Tests failed on VSTS: simulator tests

0 tests crashed, 1 tests failed, 78 tests passed.

Failures

❌ dotnettests tests [attempt 2]

1 tests failed, 0 tests passed.
  • DotNet tests: Failed (Execution failed with exit code 1)

Html Report (VSDrops) Download

Successes

⚠️ bcl: No tests selected. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ framework: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 1 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 4 tests passed. Html Report (VSDrops) Download
⚠️ install_source: No tests selected. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 40 tests passed. Html Report (VSDrops) Download
⚠️ mac_binding_project: No tests selected. Html Report (VSDrops) Download
⚠️ mmp: No tests selected. Html Report (VSDrops) Download
⚠️ mononative: No tests selected. Html Report (VSDrops) Download
✅ monotouch: All 13 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
⚠️ mtouch: No tests selected. Html Report (VSDrops) Download
⚠️ xammac: No tests selected. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 14a9d8d77450b06c33062edd2f009f405c84f7cf [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 [CI Build] Test results 🚀

Test results

✅ All tests passed on VSTS: simulator tests.

🎉 All 79 tests passed 🎉

Tests counts

⚠️ bcl: No tests selected. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests: All 1 tests passed. [attempt 3] Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ framework: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 1 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 4 tests passed. Html Report (VSDrops) Download
⚠️ install_source: No tests selected. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 40 tests passed. Html Report (VSDrops) Download
⚠️ mac_binding_project: No tests selected. Html Report (VSDrops) Download
⚠️ mmp: No tests selected. Html Report (VSDrops) Download
⚠️ mononative: No tests selected. Html Report (VSDrops) Download
✅ monotouch: All 13 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
⚠️ mtouch: No tests selected. Html Report (VSDrops) Download
⚠️ xammac: No tests selected. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 14a9d8d77450b06c33062edd2f009f405c84f7cf [CI build]

Please sign in to comment.