Skip to content

Commit 67ea402

Browse files
[release/6.0.3xx] [msbuild/tools] Fix path issues in the FilterStaticFrameworks task and ExtractBindingLibraries step. Fixes #15289. (#15442)
In the FilterStaticFrameworks task: * Convert Windows-style paths to Mac-style paths. * Give a better error if a framework can't be found. * Don't try to copy frameworks that don't exist on Windows to the Mac. In the ExtractBindingLibrariesStep: * Return a relative path to frameworks we've extracted to make things easier for remote builds. * In the _ComputeFrameworkFilesToPublish target, don't compute the source directory for frameworks using RootDir + Directory, because some frameworks may only exist on the mac, and RootDir + Directory will be a Windows path when building remotely. Instead use 'Identity', which is a relative path and will work on both Windows and Mac. Fixes #15289. Backport of #15321 Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
1 parent 59d7f90 commit 67ea402

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

dotnet/targets/Xamarin.Shared.Sdk.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@
653653
<!-- Set TargetDirectory and SourceDirectory for all frameworks we have to publish -->
654654
<_FrameworkToPublish Update="@(_FrameworkToPublish)">
655655
<TargetDirectory>$(_RelativePublishDir)$(_AppBundleFrameworksDir)\%(Filename).framework</TargetDirectory>
656-
<SourceDirectory>%(RootDir)%(Directory)</SourceDirectory>
656+
<SourceDirectory>%(RelativeDir)</SourceDirectory>
657657
</_FrameworkToPublish>
658658
</ItemGroup>
659659

msbuild/Xamarin.MacDev.Tasks.Core/Tasks/FilterStaticFrameworksTaskBase.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.Build.Framework;
88

99
using Xamarin.Localization.MSBuild;
10+
using Xamarin.Utils;
1011

1112
namespace Xamarin.MacDev.Tasks {
1213
// This task takes an itemgroup of frameworks, and filters out frameworks that aren't dynamic libraries.
@@ -20,12 +21,17 @@ public override bool Execute ()
2021
var list = FrameworkToPublish.ToList ();
2122
for (var i = list.Count - 1; i >= 0; i--) {
2223
var item = list [i];
23-
var frameworkExecutablePath = item.ItemSpec;
24+
var frameworkExecutablePath = PathUtils.ConvertToMacPath (item.ItemSpec);
2425
try {
2526
if (frameworkExecutablePath.EndsWith (".framework", StringComparison.OrdinalIgnoreCase) && Directory.Exists (frameworkExecutablePath)) {
2627
frameworkExecutablePath = Path.Combine (frameworkExecutablePath, Path.GetFileNameWithoutExtension (frameworkExecutablePath));
2728
}
2829

30+
if (!File.Exists (frameworkExecutablePath)) {
31+
Log.LogError (158, frameworkExecutablePath, MSBStrings.E0158 /* The file '{0}' does not exist. */, frameworkExecutablePath);
32+
continue;
33+
}
34+
2935
if (MachO.IsDynamicFramework (frameworkExecutablePath))
3036
continue;
3137
} catch (Exception e) {

msbuild/Xamarin.MacDev.Tasks/Tasks/FilterStaticFrameworks.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied ()
3232
// Copy all the files from the framework to the mac (copying only the executable won't work if it's just a symlink to elsewhere)
3333
if (File.Exists (fw))
3434
fw = Path.GetDirectoryName (fw);
35+
if (!Directory.Exists (fw))
36+
continue;
3537
foreach (var file in Directory.EnumerateFiles (fw, "*.*", SearchOption.AllDirectories)) {
3638
yield return new TaskItem (file);
3739
}

tools/dotnet-linker/Steps/ExtractBindingLibrariesStep.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using System.Collections.Generic;
33
using System.IO;
44

5+
using Xamarin.Utils;
6+
57
namespace Xamarin.Linker {
68

79
public class ExtractBindingLibrariesStep : ConfigurationAwareStep {
@@ -70,7 +72,12 @@ protected override void TryEndProcess ()
7072
if (!Configuration.Application.VerifyDynamicFramework (fwk))
7173
continue;
7274

73-
var executable = Path.Combine (fwk, Path.GetFileNameWithoutExtension (fwk));
75+
// Store a relative path if possible, it makes things easier with XVS.
76+
var fwkDirectory = fwk;
77+
if (Path.IsPathRooted (fwkDirectory))
78+
fwkDirectory = Path.GetRelativePath (Environment.CurrentDirectory, PathUtils.ResolveSymbolicLinks (fwkDirectory));
79+
80+
var executable = Path.Combine (fwkDirectory, Path.GetFileNameWithoutExtension (fwkDirectory));
7481

7582
var item = new MSBuildItem {
7683
Include = executable,

0 commit comments

Comments
 (0)