diff --git a/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CodesignTaskBase.cs b/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CodesignTaskBase.cs index 48da25cc8e44..fff2cc95dbeb 100644 --- a/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CodesignTaskBase.cs +++ b/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CodesignTaskBase.cs @@ -140,7 +140,16 @@ IList GenerateCommandLineArguments (ITaskItem item) if (!string.IsNullOrEmpty (ExtraArgs)) args.Add (ExtraArgs); - args.Add (Path.GetFullPath (item.ItemSpec)); + // signing a framework and a file inside a framework is not *always* identical + // on macOS apps {item.ItemSpec} can be a symlink to `Versions/Current/{item.ItemSpec}` + // and `Current` also a symlink to `A`... and `_CodeSignature` will be found there + var path = PathUtils.ResolveSymbolicLinks (item.ItemSpec); + var parent = Path.GetDirectoryName (path); + + // so do not don't sign `A.framework/A`, sign `A.framework` which will always sign the *bundle* + if ((Path.GetExtension (parent) == ".framework") && (Path.GetFileName (path) == Path.GetFileNameWithoutExtension (parent))) + path = parent; + args.Add (Path.GetFullPath (path)); return args; } @@ -230,14 +239,6 @@ IEnumerable GetCodesignedFiles (ITaskItem item) } } else if (File.Exists (item.ItemSpec)) { codesignedFiles.Add (item); - - // on macOS apps {item.ItemSpec} can be a symlink to `Versions/Current/{item.ItemSpec}` - // and `Current` also a symlink to `A`... and `_CodeSignature` will be found there - var path = PathUtils.ResolveSymbolicLinks (item.ItemSpec); - var dirName = Path.GetDirectoryName (path); - - if (Path.GetExtension (dirName) == ".framework") - codesignedFiles.AddRange (Directory.EnumerateFiles (Path.Combine (dirName, CodeSignatureDirName)).Select (x => new TaskItem (x))); } return codesignedFiles;