From c755dccfc3c9cb1722f16533028be9e63911307d Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 29 Jun 2022 14:44:52 -0400 Subject: [PATCH] MonoAOTCompilerTask: Don't check for temp file if cache is disabled (#71411) * MonoAOTCompilerTask: Don't check for temp file if cache is disabled Prompted by https://github.com/dotnet/runtime/pull/70851#discussion_r909061233 * Emit a message when deleting tmp files --- src/tasks/AotCompilerTask/MonoAOTCompiler.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs index 12b4dafe6b467..e3ef51a9daa22 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs @@ -936,12 +936,6 @@ private bool PrecompileLibrary(PrecompileArguments args) bool copied = false; foreach (var proxyFile in args.ProxyFiles) { - if (!File.Exists(proxyFile.TempFile)) - { - Log.LogError($"Precompile command succeeded, but can't find the expected temporary output file - {proxyFile.TempFile} for {assembly}.{Environment.NewLine}{output}"); - return false; - } - copied |= proxyFile.CopyOutputFileIfChanged(); _fileWrites.Add(proxyFile.TargetFile); } @@ -1225,11 +1219,11 @@ public bool CopyOutputFileIfChanged() if (!_cache.Enabled) return true; + if (!File.Exists(TempFile)) + throw new LogAsErrorException($"Could not find the temporary file {TempFile} for target file {TargetFile}. Look for any errors/warnings generated earlier in the build."); + try { - if (!File.Exists(TempFile)) - throw new LogAsErrorException($"Could not find the temporary file {TempFile} for target file {TargetFile}. Look for any errors/warnings generated earlier in the build."); - if (!_cache.ShouldCopy(this, out string? cause)) { _cache.Log.LogMessage(MessageImportance.Low, $"Skipping copying over {TargetFile} as the contents are unchanged"); @@ -1246,6 +1240,7 @@ public bool CopyOutputFileIfChanged() } finally { + _cache.Log.LogMessage(MessageImportance.Low, $"Deleting temp file {TempFile}"); File.Delete(TempFile); } }