[mono] Cache aotdata file in AOTCompiler task (#65472)
authorSteve Pfister <steveisok@users.noreply.github.com>
Fri, 18 Feb 2022 03:29:36 +0000 (22:29 -0500)
committerGitHub <noreply@github.com>
Fri, 18 Feb 2022 03:29:36 +0000 (22:29 -0500)
This change improves the inner devloop experience by making sure to cache the .aotdata file when it's generated. Otherwise, if you clean your artifacts directory and no aot changes have been made, it will not be generated again.  The result being an error when building an app.

I believe this mostly impacts iOS configurations.

src/tasks/AotCompilerTask/MonoAOTCompiler.cs

index fbf3aed..b428348 100644 (file)
@@ -698,8 +698,10 @@ public class MonoAOTCompiler : Microsoft.Build.Utilities.Task
         if (UseAotDataFile)
         {
             string aotDataFile = Path.ChangeExtension(assembly, ".aotdata");
-            aotArgs.Add($"data-outfile={aotDataFile}");
-            aotAssembly.SetMetadata("AotDataFile", aotDataFile);
+            ProxyFile proxyFile = _cache.NewFile(aotDataFile);
+            proxyFiles.Add(proxyFile);
+            aotArgs.Add($"data-outfile={proxyFile.TempFile}");
+            aotAssembly.SetMetadata("AotDataFile", proxyFile.TargetFile);
         }
 
         if (AotProfilePath?.Length > 0)