Exemplo n.º 1
0
        public async override System.Threading.Tasks.Task RunTaskAsync()
        {
            try {
                LoadResourceCaseMap();

                assemblyMap.Load(Path.Combine(WorkingDirectory, AssemblyIdentityMapFile));

                proguardRuleOutputTemp = GetTempFile();

                await this.WhenAll(ManifestFiles, ProcessManifest);

                ProcessOutput();
                // now check for
                foreach (var kvp in apks)
                {
                    string currentResourceOutputFile = kvp.Key;
                    bool   aaptResult = Daemon.JobSucceded(kvp.Value);
                    LogDebugMessage($"Processing {currentResourceOutputFile} JobId: {kvp.Value} Exists: {File.Exists (currentResourceOutputFile)} JobWorked: {aaptResult}");
                    if (!string.IsNullOrEmpty(currentResourceOutputFile))
                    {
                        var tmpfile = currentResourceOutputFile + ".bk";
                        // aapt2 might not produce an archive and we must provide
                        // and -o foo even if we don't want one.
                        if (File.Exists(tmpfile))
                        {
                            if (aaptResult)
                            {
                                LogDebugMessage($"Copying {tmpfile} to {currentResourceOutputFile}");
                                MonoAndroidHelper.CopyIfZipChanged(tmpfile, currentResourceOutputFile);
                            }
                            File.Delete(tmpfile);
                        }
                        // Delete the archive on failure
                        if (!aaptResult && File.Exists(currentResourceOutputFile))
                        {
                            LogDebugMessage($"Link did not succeed. Deleting {currentResourceOutputFile}");
                            File.Delete(currentResourceOutputFile);
                        }
                    }
                }
                if (!string.IsNullOrEmpty(ProguardRuleOutput))
                {
                    MonoAndroidHelper.CopyIfChanged(proguardRuleOutputTemp, ProguardRuleOutput);
                }
            } finally {
                lock (tempFiles) {
                    foreach (var temp in tempFiles)
                    {
                        File.Delete(temp);
                    }
                    tempFiles.Clear();
                }
            }
        }