From b2ea1de55d87603deb8869cfd185facc46f30418 Mon Sep 17 00:00:00 2001 From: Emanuel Fernandez Dell'Oca Date: Fri, 8 Aug 2025 21:32:55 -0400 Subject: [PATCH] [Windows] Make LinkNativeCode create output file The `_LinkNativeExecutable` always runs because its inputs/outputs are not created on Windows. Its own output file was never created because the task was not configured to do so. Also, the `_MtouchSymbolsList` was being written remotely so it was never found on Windows when checking the outputs. It's safe to write this locally as it will be copied as part of running this task as it is one of its declared dependencies. Fixes https://github.com/dotnet/macios/issues/19610 --- dotnet/targets/Xamarin.Shared.Sdk.targets | 3 +-- msbuild/Xamarin.MacDev.Tasks/Tasks/LinkNativeCode.cs | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index 80a7449e71bf..bed4b2b282f3 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -1686,7 +1686,7 @@ <_NativeReferences Include="@(_FileNativeReference)" Condition="'%(_FileNativeReference.LinkToExecutable)' != 'false'" /> - + @@ -1859,7 +1859,6 @@ diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/LinkNativeCode.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/LinkNativeCode.cs index 2c3149e5f8bd..512906356e03 100644 --- a/msbuild/Xamarin.MacDev.Tasks/Tasks/LinkNativeCode.cs +++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/LinkNativeCode.cs @@ -31,7 +31,8 @@ public class LinkNativeCode : XamarinTask, ITaskCallback { public string SdkRoot { get; set; } = string.Empty; [Required] - public string OutputFile { get; set; } = string.Empty; + [Output] + public ITaskItem OutputFile { get; set; } = null!; [Required] public ITaskItem [] ObjectFiles { get; set; } = Array.Empty (); @@ -56,7 +57,7 @@ public class LinkNativeCode : XamarinTask, ITaskCallback { public override bool Execute () { if (ShouldExecuteRemotely ()) { - outputPath = PathUtils.ConvertToMacPath (Path.GetDirectoryName (OutputFile)); + outputPath = PathUtils.ConvertToMacPath (Path.GetDirectoryName (OutputFile.ItemSpec)); return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result; } @@ -205,7 +206,7 @@ bool ExecuteUnsafe () arguments.AddRange (GetEmbedEntitlementsWithDerInExecutableLinkerFlags (EntitlementsInExecutable)); arguments.Add ("-o"); - arguments.Add (Path.GetFullPath (OutputFile)); + arguments.Add (Path.GetFullPath (OutputFile.ItemSpec)); if (LinkerFlags is not null) { foreach (var flag in LinkerFlags) @@ -306,7 +307,7 @@ static bool EntitlementsRequireLinkerFlags (string path) // and the ones on Windows are empty, so we will break the build public bool ShouldCopyToBuildServer (ITaskItem item) => !PathUtils.ConvertToMacPath (item.ItemSpec).StartsWith (outputPath); - public bool ShouldCreateOutputFile (ITaskItem item) => false; + public bool ShouldCreateOutputFile (ITaskItem item) => true; public IEnumerable GetAdditionalItemsToBeCopied () => Enumerable.Empty (); }