From bc67d7647b4009b7b400e0cb9b44f15e88630b5e Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Mon, 18 Jan 2021 13:57:07 -0500 Subject: [PATCH] [msbuild] Fix codesign `StampPath`. Fix #10445 Using `Path.Combine` with a full qualified path for the 2nd argument will return that 2nd argument (ignoring the first one). That meant the `StampPath` was pointing to the actual files that were just signed - overwriting them with a 0-length data (empty). The solution is to make the 2nd argument relative, starting after `.app/` so `Path.Combine` works as expected (being relative) while allowing signing multiple files that have the same name (in different directories). ref: https://github.com/xamarin/xamarin-macios/issues/10445 --- msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CodesignTaskBase.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CodesignTaskBase.cs b/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CodesignTaskBase.cs index 405cae5ddf55..e020c29e9218 100644 --- a/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CodesignTaskBase.cs +++ b/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CodesignTaskBase.cs @@ -76,7 +76,9 @@ string GetFullPathToTool () string GetOutputPath (ITaskItem item) { - return Path.Combine (StampPath, item.ItemSpec); + var path = item.ItemSpec; + var app = path.LastIndexOf (".app/"); + return Path.Combine (StampPath, path.Substring (app + ".app/".Length)); } bool NeedsCodesign (ITaskItem item)