Example #1
0
        protected override async Task RunDistribute(IEnumerable <BuildPath> buildPaths, TaskToken task)
        {
            if (string.IsNullOrEmpty(scriptPath))
            {
                throw new Exception("ScriptDistro: Script path not set.");
            }

            if (individual)
            {
                task.Report(0, buildPaths.Count());
                foreach (var buildPath in buildPaths)
                {
                    task.Report(0, description: $"Running script {Path.GetFileName(scriptPath)} for {buildPath.target}");
                    var args = ReplaceVariablesIndividual(arguments, buildPath);
                    await Execute(new ExecutionArgs(scriptPath, args), task);

                    task.baseStep++;
                }
            }
            else
            {
                task.Report(0, 1, $"Running script {Path.GetFileName(scriptPath)}");
                var args = ReplaceVariables(arguments, buildPaths);
                await Execute(new ExecutionArgs(scriptPath, args), task);
            }
        }
Example #2
0
        protected async Task Upload(BuildPath zipPath, TaskToken task)
        {
            var archive = zipPath.path;

            if (!File.Exists(archive))
            {
                throw new System.Exception("UploadDistro: Archive file does not exist: " + archive);
            }

            // Append a / to the url if necessary, otherwise curl treats the last part as a file name
            var url = uploadUrl;

            if (url[url.Length - 1] != '/')
            {
                url += "/";
            }

            string input = null;

            if (!string.IsNullOrEmpty(login.User))
            {
                input = string.Format("-u \"{0}:{1}\"", login.User, login.GetPassword(keychainService));
            }

            var arguments = string.Format(
                "-T '{0}' {1} --ssl -v '{2}'",
                archive, input != null ? "-K -" : "", url
                );

            task.Report(0, $"Uploading {Path.GetFileName(archive)} to {uploadUrl}");
            await Execute(new ExecutionArgs(curlPath, arguments) { input = input }, task);
        }
Example #3
0
        protected override async Task RunDistribute(IEnumerable <BuildPath> buildPaths, TaskToken task)
        {
            if (!File.Exists(butlerPath))
            {
                throw new Exception("ItchDistro: Butler path not set or file does not exist.");
            }

            if (string.IsNullOrEmpty(project))
            {
                throw new Exception("ItchDistro: project not set.");
            }

            task.Report(0, buildPaths.Count());

            foreach (var pair in buildPaths)
            {
                if (!ChannelNames.ContainsKey(pair.target))
                {
                    Debug.LogWarning("ItchDistro: Build target " + pair.target + " not supported, skipping.");
                    continue;
                }

                if (macNotarization != null)
                {
                    await macNotarization.NotarizeIfMac(pair, task);
                }

                await Distribute(pair, task);

                task.baseStep++;
            }
        }
Example #4
0
        protected override async Task RunDistribute(IEnumerable <BuildPath> buildPaths, TaskToken task)
        {
            if (string.IsNullOrEmpty(curlPath))
            {
                throw new Exception("UploadDistro: Path to curl not set.");
            }

            if (!File.Exists(curlPath))
            {
                throw new Exception("UploadDistro: curl not found at path: " + curlPath);
            }

            if (string.IsNullOrEmpty(uploadUrl))
            {
                throw new Exception("UploadDistro: No upload URL set.");
            }

            if (!string.IsNullOrEmpty(login.User) && login.GetPassword(keychainService) == null)
            {
                throw new Exception("UploadDistro: No password set for user: "******"Archiving builds");

            IEnumerable <BuildPath> zipPaths;
            var child = task.StartChild("Zip Builds");

            try {
                zipPaths = await ZipBuilds(buildPaths, child);
            } finally {
                child.Remove();
            }

            task.Report(1, description: "Uploading builds");

            child = task.StartChild("Upload Builds");
            try {
                foreach (var path in zipPaths)
                {
                    await Upload(path, child);
                }
            } finally {
                child.Remove();
            }
        }
Example #5
0
        void TaskBuild(Job job)
        {
            // Handle switching build target when necessary
            var activeTargetMatches = (EditorUserBuildSettings.activeBuildTarget == job.target);

            if (continueTask == ContinueTask.BuildAfterSwitchingTarget && !activeTargetMatches)
            {
                throw new Exception($"Trimmer BuildRunner: Failed to switch active build target to {job.target}.");
            }
            else if (!activeTargetMatches)
            {
                token.Report(jobIndex, description: $"Switching active build target to {job.target}");

                var group = BuildPipeline.GetBuildTargetGroup(job.target);
                EditorUserBuildSettings.SwitchActiveBuildTarget(group, job.target);

                ContinueWith(ContinueTask.BuildAfterSwitchingTarget, afterDomainRelaod: true);
                return;
            }

            // Build
            token.Report(jobIndex, description: $"Building {job.target}");
            BuildReport report;

            try {
                var options = BuildManager.GetDefaultOptions(job.target);
                if (!string.IsNullOrEmpty(job.outputPath))
                {
                    options.locationPathName = job.outputPath;
                }

                report = BuildManager.BuildSync(job.profile, options);
                results[jobIndex].report = report;
            } catch (Exception e) {
                results[jobIndex] = ProfileBuildResult.Error(job.profile, e.Message);
                throw;
            }

            if (report.summary.result != BuildResult.Succeeded)
            {
                throw new Exception($"Trimmer BuildRunner: Build failed");
            }

            ContinueWith(ContinueTask.NextJob);
        }
Example #6
0
        protected async Task Process(string path, TaskToken task)
        {
            task.Report(0, 2);

            // Create archive
            var projectPath = Path.Combine(path, "Unity-iPhone.xcodeproj");

            if (!Directory.Exists(projectPath))
            {
                throw new Exception($"iOSDistro: Could not find Xcode project at path '{projectPath}'");
            }

            var archiveName = $"{scheme}-{PlayerSettings.iOS.buildNumber}-{DateTime.Now.ToString("O")}.xcarchive";
            var archivePath = Path.Combine(archivesPath, archiveName);

            task.Report(0, description: $"Building scheme '{scheme}'");
            await Archive(projectPath, scheme, archivePath, task);

            // Upload archive
            var    cleanUpOptions    = false;
            string exportOptionsPath = null;

            try {
                if (exportOptions != null)
                {
                    exportOptionsPath = AssetDatabase.GetAssetPath(exportOptions);
                }

                if (string.IsNullOrEmpty(exportOptionsPath))
                {
                    cleanUpOptions    = true;
                    exportOptionsPath = Path.GetTempFileName();
                    File.WriteAllText(exportOptionsPath, DefaultExportOptions);
                }

                task.Report(1, description: $"Uploading archive");
                await Upload(archivePath, exportOptionsPath, task);
            } finally {
                if (cleanUpOptions)
                {
                    File.Delete(exportOptionsPath);
                }
            }
        }
Example #7
0
        protected async Task <IEnumerable <BuildPath> > ZipBuilds(IEnumerable <BuildPath> buildPaths, TaskToken task)
        {
            var queue   = new Queue <BuildPath>(buildPaths);
            var results = new List <BuildPath>();

            task.Report(0, queue.Count);

            while (queue.Count > 0)
            {
                var next = queue.Dequeue();

                if (macNotarization != null)
                {
                    await macNotarization.NotarizeIfMac(next, task);
                }

                results.Add(await Zip(next, task));

                task.baseStep++;
            }

            return(results);
        }
Example #8
0
        async Task Distribute(BuildPath buildPath, TaskToken task)
        {
            task.Report(0, description: $"Pushing {buildPath.target}");

            var path = OptionHelper.GetBuildBasePath(buildPath.path);

            var channel = ChannelNames[buildPath.target];

            if (!string.IsNullOrEmpty(channelSuffix))
            {
                channel += "-" + channelSuffix;
            }

            var version = Application.version;

            var buildInfo = BuildInfo.FromPath(path);

            if (buildInfo != null)
            {
                if (!buildInfo.version.IsDefined)
                {
                    Debug.LogWarning("ItchDistro: build.json exists but contains no version.");
                }
                else
                {
                    version = buildInfo.version.MajorMinorPatchBuild;
                }
            }

            var args = string.Format(
                "push '{0}' '{1}:{2}' --userversion '{3}' --ignore='*.DS_Store' --ignore='build.json'",
                path, project, channel, Application.version
                );

            await Execute(new ExecutionArgs(butlerPath, args), task);
        }
Example #9
0
        /// <summary>
        /// Notarize a macOS build.
        /// </summary>
        /// <remarks>
        /// This method will throw if the given build is not a macOS build.
        /// </remarks>
        /// <param name="macBuildPath">Path to the app bundle</param>
        public async Task Notarize(BuildPath macBuildPath, TaskToken task)
        {
            if (macBuildPath.target != BuildTarget.StandaloneOSX)
            {
                throw new Exception($"NotarizationDistro: Notarization is only available for macOS builds (got {macBuildPath.target})");
            }

            var path = macBuildPath.path;

            // Check settings
            if (string.IsNullOrEmpty(appSignIdentity))
            {
                throw new Exception("NotarizationDistro: App sign identity not set.");
            }

            if (entitlements == null)
            {
                throw new Exception("NotarizationDistro: Entitlements file not set.");
            }

            // Check User
            if (string.IsNullOrEmpty(ascLogin.User))
            {
                throw new Exception("NotarizationDistro: No App Store Connect user set.");
            }

            if (ascLogin.GetPassword(keychainService) == null)
            {
                throw new Exception("NotarizationDistro: No App Store Connect password found in Keychain.");
            }

            task.Report(0, 6, "Checking if app is already notarized");

            // Try stapling in case the build has already been notarized
            if (await Staple(path, silentError: true, task))
            {
                Debug.Log("Build already notarized, nothing more to do...");
                return;
            }

            task.Report(1, description: "Signing app");

            // Sign plugins
            // codesign --deep --force does not resign nested plugins,
            // --force only applies to the main bundle. If we want to
            // resign nested plugins, we have to call codesign for each.
            // This is required for library validation with the hardened runtime.
            var plugins = Path.Combine(path, "Contents/Plugins");

            if (Directory.Exists(plugins))
            {
                await Sign(Directory.GetFiles(plugins, "*.dylib", SearchOption.TopDirectoryOnly), task);
                await Sign(Directory.GetFiles(plugins, "*.bundle", SearchOption.TopDirectoryOnly), task);
                await Sign(Directory.GetDirectories(plugins, "*.bundle", SearchOption.TopDirectoryOnly), task);
            }

            // Sign application
            var entitlementsPath = AssetDatabase.GetAssetPath(entitlements);

            await Sign(path, task, entitlementsPath);

            task.Report(2, description: "Zipping app");

            // Zip app
            var zipPath = path + ".zip";

            await Zip(path, zipPath, task);

            task.Report(3, description: "Uploading app");

            // Upload for notarization
            string requestUUID = null;

            try {
                requestUUID = await Upload(zipPath, task);

                if (requestUUID == null)
                {
                    throw new Exception("NotarizationDistro: Could not parse request UUID from upload output");
                }
            } finally {
                // Delete ZIP regardless of upload result
                File.Delete(zipPath);
            }

            task.Report(4, description: "Waiting for notarization result");

            // Wait for notarization to complete
            var status = await WaitForCompletion(requestUUID, task);

            if (status != "success")
            {
                throw new Exception($"NotarizationDistro: Got '{status}' notarization status");
            }

            task.Report(5, description: "Stapling ticket to app");

            // Staple
            await Staple(path, silentError : false, task);
        }
Example #10
0
        protected async Task <BuildPath> Zip(BuildPath buildPath, TaskToken task)
        {
            var target = buildPath.target;
            var path   = buildPath.path;

            if (!File.Exists(path) && !Directory.Exists(path))
            {
                throw new Exception("ZipDistro: Path to compress does not exist: " + path);
            }

            if (ZipIgnorePatterns == null)
            {
                ZipIgnorePatterns = new Regex[ZipIgnore.Length];
                for (int i = 0; i < ZipIgnore.Length; i++)
                {
                    var regex = Regex.Escape(ZipIgnore[i]).Replace(@"\*", ".*").Replace(@"\?", ".");
                    ZipIgnorePatterns[i] = new Regex(regex);
                }
            }

            var sevenZPath = Get7ZipPath();

            // Path can point to executable file but there might be files
            // in the containing directory we need as well
            var basePath = OptionHelper.GetBuildBasePath(path);

            // Check the files in containing directory
            var files = new List <string>(Directory.GetFileSystemEntries(basePath));

            for (int i = files.Count - 1; i >= 0; i--)
            {
                var filename = Path.GetFileName(files[i]);
                foreach (var pattern in ZipIgnorePatterns)
                {
                    if (pattern.IsMatch(filename))
                    {
                        files.RemoveAt(i);
                        goto ContinueOuter;
                    }
                }
                ContinueOuter :;
            }

            if (files.Count == 0)
            {
                throw new Exception("ZipDistro: Nothing to ZIP in directory: " + basePath);
            }

            // Determine output path first to make it consistent and use absolute path
            // since the script will be run in a different working directory
            var prettyName = GetPrettyName(target);

            if (prettyName == null)
            {
                prettyName = Path.GetFileNameWithoutExtension(basePath);
            }

            var versionSuffix = "";

            if (appendVersion)
            {
                var buildInfo = BuildInfo.FromPath(path);
                if (buildInfo != null)
                {
                    if (!buildInfo.version.IsDefined)
                    {
                        Debug.LogWarning("ZipDistro: build.json exists but contains no version");
                    }
                    else
                    {
                        versionSuffix = " " + buildInfo.version.MajorMinorPatch;
                    }
                }

                if (versionSuffix.Length == 0)
                {
                    versionSuffix = " " + Application.version;
                }
            }

            var extension = FileExtensions[(int)format];
            var zipName   = prettyName + versionSuffix + extension;

            zipName = zipName.Replace(" ", "_");

            var outputPath = Path.Combine(Path.GetDirectoryName(basePath), zipName);

            outputPath = Path.GetFullPath(outputPath);

            // Delete existing archive, otherwise 7za will update it
            if (File.Exists(outputPath))
            {
                File.Delete(outputPath);
            }

            // In case it only contains a single file, just zip that file
            var singleFile = false;

            if (files.Count == 1)
            {
                singleFile = true;
                basePath   = files[0];
            }

            // Run 7za command to create ZIP file
            var excludes = "";

            foreach (var pattern in ZipIgnore)
            {
                excludes += @" -xr\!'" + pattern + "'";
            }

            var inputName = Path.GetFileName(basePath);
            var args      = string.Format(
                "a '{0}' '{1}' -r -mx{2} {3}",
                outputPath, inputName, (int)compression, excludes
                );

            var startInfo = new System.Diagnostics.ProcessStartInfo();

            startInfo.FileName         = sevenZPath;
            startInfo.Arguments        = args;
            startInfo.WorkingDirectory = Path.GetDirectoryName(basePath);

            task.Report(0, description: $"Archiving {inputName}");

            await Execute(new ExecutionArgs()
            {
                startInfo = startInfo
            }, task);

            if (!singleFile && prettyName != inputName)
            {
                await RenameRoot(outputPath, inputName, prettyName, task);
            }

            return(new BuildPath(buildPath.profile, target, outputPath));
        }
Example #11
0
        protected async Task Process(string path, TaskToken task)
        {
            // Check settings
            if (string.IsNullOrEmpty(appSignIdentity))
            {
                throw new Exception("MASDistro: App sign identity not set.");
            }

            if (entitlements == null)
            {
                throw new Exception("MASDistro: Entitlements file not set.");
            }

            if (provisioningProfile == null)
            {
                throw new Exception("MASDistro: Provisioning profile not set.");
            }

            if (linkFrameworks != null && linkFrameworks.Length > 0 && !File.Exists(optoolPath))
            {
                throw new Exception("MASDistro: optool path not set for linking frameworks.");
            }

            var plistPath = Path.Combine(path, "Contents/Info.plist");

            if (!File.Exists(plistPath))
            {
                throw new Exception("MASDistro: Info.plist file not found at path: " + plistPath);
            }

            task.Report(0, 3);

            var doc = new PlistDocument();

            doc.ReadFromFile(plistPath);

            // Edit Info.plist
            if (!string.IsNullOrEmpty(copyright) || !string.IsNullOrEmpty(languages))
            {
                if (!string.IsNullOrEmpty(copyright))
                {
                    doc.root.SetString("NSHumanReadableCopyright", string.Format(copyright, System.DateTime.Now.Year));
                }

                if (!string.IsNullOrEmpty(languages))
                {
                    var parts = languages.Split(',');

                    var array = doc.root.CreateArray("CFBundleLocalizations");
                    foreach (var part in parts)
                    {
                        array.AddString(part.Trim());
                    }
                }

                doc.WriteToFile(plistPath);
            }

            // Link frameworks
            if (linkFrameworks != null && linkFrameworks.Length > 0)
            {
                task.Report(0, description: "Linking frameworks");

                var binaryPath = Path.Combine(path, "Contents/MacOS");
                binaryPath = Path.Combine(binaryPath, doc.root["CFBundleExecutable"].AsString());

                foreach (var framework in linkFrameworks)
                {
                    var frameworkBinaryPath = FindFramework(framework);
                    if (frameworkBinaryPath == null)
                    {
                        throw new Exception("MASDistro: Could not locate framework: " + framework);
                    }

                    var otoolargs = string.Format(
                        "install -c weak -p '{0}' -t '{1}'",
                        frameworkBinaryPath, binaryPath
                        );
                    await Execute(new ExecutionArgs(optoolPath, otoolargs), task);
                }
            }

            // Copy provisioning profile
            var profilePath  = AssetDatabase.GetAssetPath(provisioningProfile);
            var embeddedPath = Path.Combine(path, "Contents/embedded.provisionprofile");

            File.Copy(profilePath, embeddedPath, true);

            // Sign plugins
            var plugins = Path.Combine(path, "Contents/Plugins");

            if (Directory.Exists(plugins))
            {
                task.Report(0, description: "Signing plugins");
                await Sign(Directory.GetFiles(plugins, "*.dylib", SearchOption.AllDirectories), task);
                await Sign(Directory.GetFiles(plugins, "*.bundle", SearchOption.AllDirectories), task);
                await Sign(Directory.GetDirectories(plugins, "*.bundle", SearchOption.TopDirectoryOnly), task);
            }

            // Sign application
            task.Report(1, description: "Singing app");
            var entitlementsPath = AssetDatabase.GetAssetPath(entitlements);

            await Sign(path, task, entitlementsPath);

            // Create installer
            var pkgPath = Path.ChangeExtension(path, ".pkg");

            if (!string.IsNullOrEmpty(installerSignIdentity))
            {
                task.Report(1, description: "Creating installer");
                var args = string.Format(
                    "--component '{0}' /Applications --sign '{1}' '{2}'",
                    path, installerSignIdentity, pkgPath
                    );
                await Execute(new ExecutionArgs("productbuild", args), task);
            }

            // Upload to App Store
            if (!string.IsNullOrEmpty(ascLogin.User))
            {
                task.Report(2, description: "Uploading to App Store Connect");
                await Upload(pkgPath, task);
            }
        }
Example #12
0
        protected override async Task RunDistribute(IEnumerable <BuildPath> buildPaths, TaskToken task)
        {
            // Check Pipeline Builder Executable
            var cmd = FindPipelineBuilder();

            // Check User
            if (string.IsNullOrEmpty(gogLogin.User))
            {
                throw new Exception("GOGDistro: No GOG user set.");
            }

            if (gogLogin.GetPassword(keychainService) == null)
            {
                throw new Exception("GOGDistro: No GOG password found in Keychain.");
            }

            // Check projects
            if (string.IsNullOrEmpty(projectsFolder) || !Directory.Exists(projectsFolder))
            {
                throw new Exception("GOGDistro: Path to projects folder not set.");
            }

            // Check ignore list
            if (!string.IsNullOrEmpty(ignoreList) && !File.Exists(ignoreList))
            {
                throw new Exception("GOGDistro: Ignore list could not be found: " + ignoreList);
            }

            // Process projects
            var tempDir = FileUtil.GetUniqueTempPathInProject();

            try {
                Directory.CreateDirectory(tempDir);

                var    targets      = new HashSet <BuildTarget>(buildPaths.Select(p => p.target));
                var    projects     = new List <string>();
                string convertError = null;
                foreach (var file in Directory.GetFiles(projectsFolder))
                {
                    if (Path.GetExtension(file).ToLower() != ".json")
                    {
                        continue;
                    }

                    var contents = PathVarRegex.Replace(File.ReadAllText(file), (match) => {
                        var platformName = match.Groups[1].Value.ToLower();

                        if (platformName == "project")
                        {
                            return(Path.GetDirectoryName(Application.dataPath));
                        }
                        else if (platformName == "projects")
                        {
                            return(Path.GetFullPath(projectsFolder));
                        }

                        BuildTarget target;
                        try {
                            target = (BuildTarget)System.Enum.Parse(typeof(BuildTarget), platformName, true);
                        } catch {
                            convertError = $"Invalid build target path variable '{platformName}' in project JSON: {file}";
                            return("");
                        }

                        if (!buildPaths.Any(p => p.target == target))
                        {
                            convertError = $"Build target '{platformName}' not part of given build profile(s) in project JSON: {file}";
                            return("");
                        }
                        targets.Remove(target);

                        var path = buildPaths.Where(p => p.target == target).Select(p => p.path).First();
                        path     = OptionHelper.GetBuildBasePath(path);

                        return(Path.GetFullPath(path));
                    });
                    if (convertError != null)
                    {
                        break;
                    }

                    var targetPath = Path.Combine(tempDir, Path.GetFileName(file));
                    File.WriteAllText(targetPath, contents);
                    projects.Add(targetPath);
                }

                if (convertError != null)
                {
                    throw new Exception($"GOGDistro: {convertError}");
                }

                if (targets.Count > 0)
                {
                    Debug.LogWarning("GOGDistro: Not all build targets filled into variables. Left over: "
                                     + string.Join(", ", targets.Select(t => t.ToString()).ToArray()));
                }

                task.Report(0, targets.Count + 1);

                // Notarize mac builds
                if (macNotarization != null)
                {
                    task.Report(0, description: "Notarizing macOS builds");
                    foreach (var path in buildPaths.Where(p => p.target == BuildTarget.StandaloneOSX))
                    {
                        await macNotarization.Notarize(path, task);
                    }
                }

                // Build
                task.baseStep++;
                foreach (var project in projects)
                {
                    var args = string.Format(
                        "build-game '{0}' --username='******' --password='******' --version={3}",
                        Path.GetFullPath(project), gogLogin.User, gogLogin.GetPassword(keychainService),
                        string.IsNullOrEmpty(overrideVersion) ? Application.version : overrideVersion
                        );

                    if (!string.IsNullOrEmpty(ignoreList))
                    {
                        args += $" --ignore_list='{Path.GetFullPath(ignoreList)}'";
                    }

                    if (!string.IsNullOrEmpty(branch.User))
                    {
                        args += $" --branch='{branch.User}'";

                        var pwd = branch.GetPassword(branchKeychainService);
                        if (pwd != null)
                        {
                            args += $" --branch_password='******'";
                        }
                    }

                    task.Report(0, description: $"Uploading {Path.GetFileName(project)}");

                    await Execute(new ExecutionArgs(cmd, args), task);

                    task.baseStep++;
                }
            } finally {
                // Always clean up temporary files
                Directory.Delete(tempDir, true);
            }
        }
Example #13
0
        protected override async Task RunDistribute(IEnumerable <BuildPath> buildPaths, TaskToken task)
        {
            // Check SDK
            var cmd = FindSteamCmd();

            // Check User
            if (string.IsNullOrEmpty(steamLogin.User))
            {
                throw new Exception("SteamDistro: No Steam user set.");
            }

            if (steamLogin.GetPassword(keychainService) == null)
            {
                throw new Exception("SteamDistro: No Steam password found in Keychain.");
            }

            // Check scripts
            if (string.IsNullOrEmpty(scriptsFolder) || !Directory.Exists(scriptsFolder))
            {
                throw new Exception("SteamDistro: Path to scripts folder not set.");
            }

            if (string.IsNullOrEmpty(appScript))
            {
                throw new Exception("SteamDistro: Name of app script not set.");
            }

            var appScriptPath = Path.Combine(scriptsFolder, appScript);

            if (!File.Exists(appScriptPath))
            {
                throw new Exception("SteamDistro: App script not found in scripts folder.");
            }

            // Process scripts
            var tempDir = FileUtil.GetUniqueTempPathInProject();

            try {
                Directory.CreateDirectory(tempDir);

                var    targets      = new HashSet <BuildTarget>(buildPaths.Select(p => p.target));
                string convertError = null;
                foreach (var file in Directory.GetFiles(scriptsFolder))
                {
                    if (Path.GetExtension(file).ToLower() != ".vdf")
                    {
                        continue;
                    }

                    var contents = PathVarRegex.Replace(File.ReadAllText(file), (match) => {
                        var platformName = match.Groups[1].Value.ToLower();

                        if (platformName == "project")
                        {
                            return(Path.GetDirectoryName(Application.dataPath));
                        }
                        else if (platformName == "scripts")
                        {
                            return(Path.GetFullPath(scriptsFolder));
                        }

                        BuildTarget target;
                        try {
                            target = (BuildTarget)System.Enum.Parse(typeof(BuildTarget), platformName, true);
                        } catch {
                            convertError = $"SteamDistro: Invalid build target path variable '{platformName}' in VDF script: {file}";
                            return("");
                        }

                        if (!buildPaths.Any(p => p.target == target))
                        {
                            convertError = $"SteamDistro: Build target '{platformName}' not part of given build profile(s) in VDF script: {file}";
                            return("");
                        }
                        targets.Remove(target);

                        var path = buildPaths.Where(p => p.target == target).Select(p => p.path).First();
                        path     = OptionHelper.GetBuildBasePath(path);

                        return(Path.GetFullPath(path));
                    });
                    if (convertError != null)
                    {
                        break;
                    }

                    var targetPath = Path.Combine(tempDir, Path.GetFileName(file));
                    File.WriteAllText(targetPath, contents);
                }

                if (convertError != null)
                {
                    throw new Exception($"SteamDistro: {convertError}");
                }

                if (targets.Count > 0)
                {
                    Debug.LogWarning("SteamDistro: Not all build targets filled into variables. Left over: "
                                     + string.Join(", ", targets.Select(t => t.ToString()).ToArray()));
                }

                // Notarize mac builds
                if (macNotarization != null)
                {
                    task.Report(0, description: "Notarizing macOS builds");
                    foreach (var path in buildPaths.Where(p => p.target == BuildTarget.StandaloneOSX))
                    {
                        await macNotarization.Notarize(path, task);
                    }
                }

                // Build
                var scriptPath = Path.GetFullPath(Path.Combine(tempDir, appScript));
                var args       = string.Format(
                    "+login '{0}' '{1}' +run_app_build_http '{2}' +quit",
                    steamLogin.User, steamLogin.GetPassword(keychainService), scriptPath
                    );

                await Execute(new ExecutionArgs(cmd, args) {
                    onOutput = (output) => {
                        if (output.Contains("Logged in OK"))
                        {
                            task.Report(0, description: "Logged in");
                        }
                        else if (output.Contains("Building depot"))
                        {
                            var match = BuildingDepotRegex.Match(output);
                            if (match.Success)
                            {
                                task.Report(0, description: $"Building depo {match.Groups[1].Value}");
                            }
                        }
                        else if (output.Contains(""))
                        {
                            var match = SuccessBuildIdRegex.Match(output);
                            if (match.Success)
                            {
                                Debug.Log("SteamDistro: Build uploaded, ID = " + match.Groups[1].Value);
                            }
                        }
                    }
                }, task);
            } finally {
                // Always clean up temp files
                Directory.Delete(tempDir, true);
            }
        }