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

[DRAFT] Fix stuff to make RuntimeIdentifiers work on Windows. #20799

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 5 additions & 1 deletion dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,11 @@
<ReadLinesFromFile File="%(_RidSpecificSymbolsListPath.Identity)">
<Output TaskParameter="Lines" ItemName="_AllExecutableSymbols" />
</ReadLinesFromFile>
<WriteLinesToFile File="$(_MtouchSymbolsList)" Lines="@(_AllExecutableSymbols->DistinctWithCase())" Overwrite="true" />
<WriteLinesToFile
SessionId="$(BuildSessionId)"
File="$(_MtouchSymbolsList)"
Lines="@(_AllExecutableSymbols->DistinctWithCase())"
Overwrite="true" />
</Target>

<!-- When we're building a universal app, we need to collect the list of user frameworks we need to run dsymutil on -->
Expand Down
13 changes: 12 additions & 1 deletion msbuild/Xamarin.MacDev.Tasks/Tasks/WriteItemsToFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
using Microsoft.Build.Tasks;
using System.Xml.Linq;

using Xamarin.Messaging.Build.Client;

namespace Xamarin.MacDev.Tasks {
public class WriteItemsToFile : XamarinTask {
public class WriteItemsToFile : XamarinTask, ICancelableTask {
static readonly XNamespace XmlNs = XNamespace.Get ("http://schemas.microsoft.com/developer/msbuild/2003");

static readonly XName ProjectElementName = XmlNs + "Project";
Expand All @@ -34,6 +36,9 @@ public class WriteItemsToFile : XamarinTask {

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

Write (this, File?.ItemSpec, Items, ItemName, Overwrite, IncludeMetadata);
return true;
}
Expand Down Expand Up @@ -78,5 +83,11 @@ static IEnumerable<XElement> CreateMetadataFromItem (ITaskItem item, bool includ

return Enumerable.Empty<XElement> ();
}

public void Cancel ()
{
if (ShouldExecuteRemotely ())
BuildConnection.CancelAsync (BuildEngine4).Wait ();
}
}
}
13 changes: 12 additions & 1 deletion tests/dotnet/UnitTests/WindowsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,14 @@ public void PluralRuntimeIdentifiersWithHotRestart (ApplePlatform platform, stri
DotNetProjectTest.PluralRuntimeIdentifiersImpl (platform, runtimeIdentifiers, properties, isUsingHotRestart: true);
}

[Category ("RemoteWindows")]
[TestCase (ApplePlatform.iOS, "ios-arm64")]
public void PluralRuntimeIdentifiersWithRemoteMac (ApplePlatform platform, string runtimeIdentifiers)
{
var properties = AddRemoteProperties ();
DotNetProjectTest.PluralRuntimeIdentifiersImpl (platform, runtimeIdentifiers, properties);
}

static void AssertWarningsEqual (IList<string> expected, IList<string> actual, string message)
{
if (expected.Count == actual.Count) {
Expand Down Expand Up @@ -368,14 +376,17 @@ public void RemoteTest (ApplePlatform platform, string runtimeIdentifiers)
Assert.AreEqual ("3.14", infoPlist.GetString ("CFBundleShortVersionString").Value, "CFBundleShortVersionString");
}

protected void AddRemoteProperties (Dictionary<string, string> properties)
protected Dictionary<string, string> AddRemoteProperties (Dictionary<string, string>? properties = null)
{
properties ??= new Dictionary<string, string> ();
properties ["ServerAddress"] = Environment.GetEnvironmentVariable ("MAC_AGENT_IP") ?? string.Empty;
properties ["ServerUser"] = Environment.GetEnvironmentVariable ("MAC_AGENT_USER") ?? string.Empty;
properties ["ServerPassword"] = Environment.GetEnvironmentVariable ("XMA_PASSWORD") ?? string.Empty;

if (!string.IsNullOrEmpty (properties ["ServerUser"]))
properties ["EnsureRemoteConnection"] = "true";

return properties;
}

protected Dictionary<string, string> AddHotRestartProperties (Dictionary<string, string>? properties = null)
Expand Down