Workaround MacCatalyst .app output path change in cmake 3.25 (#79084)
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Thu, 1 Dec 2022 17:03:18 +0000 (18:03 +0100)
committerGitHub <noreply@github.com>
Thu, 1 Dec 2022 17:03:18 +0000 (18:03 +0100)
Fixes https://github.com/dotnet/runtime/issues/78778

src/tasks/AppleAppBuilder/Xcode.cs

index 403aa9b..227ff37 100644 (file)
@@ -528,8 +528,15 @@ internal sealed class Xcode
 
         Utils.RunProcess(Logger, "xcodebuild", args.ToString(), workingDir: Path.GetDirectoryName(xcodePrjPath));
 
-        string appPath = Path.Combine(Path.GetDirectoryName(xcodePrjPath)!, config + "-" + sdk,
-            Path.GetFileNameWithoutExtension(xcodePrjPath) + ".app");
+        string appDirectory = Path.Combine(Path.GetDirectoryName(xcodePrjPath)!, config + "-" + sdk);
+        if (!Directory.Exists(appDirectory))
+        {
+            // cmake 3.25.0 seems to have changed the output directory for MacCatalyst, move it back to the old format
+            string appDirectoryWithoutSdk = Path.Combine(Path.GetDirectoryName(xcodePrjPath)!, config);
+            Directory.Move(appDirectoryWithoutSdk, appDirectory);
+        }
+
+        string appPath = Path.Combine(appDirectory, Path.GetFileNameWithoutExtension(xcodePrjPath) + ".app");
 
         if (destination != null)
         {