From 5e969452c6453a60ed4f818e7b4a2ff5ffc8963a Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Thu, 14 May 2026 08:37:42 -0700 Subject: [PATCH] Fix MSB3491 race condition in WriteLaunchers parallel builds Write build variables to \ (per-project output directory) instead of a shared global temp path. Multiple projects building in parallel each get their own unique output directory, eliminating the delete-then-create race on the shared temp file. Update the RepositoryPaths.BuildVariables reader to use AppContext.BaseDirectory instead of Path.GetTempPath(), since the .tmp file now lives alongside the built assembly. AppContext.BaseDirectory is AOT-safe and correctly resolves in Live Unit Testing scenarios. Remove the now-unnecessary TempStagingPath property and collapse the two conditional WriteLinesToFile calls into one unconditional write. --- IntelliTect.Multitool.AotTest/Program.cs | 2 +- IntelliTect.Multitool/Build/IntelliTect.Multitool.targets | 4 +--- IntelliTect.Multitool/RepositoryPaths.cs | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/IntelliTect.Multitool.AotTest/Program.cs b/IntelliTect.Multitool.AotTest/Program.cs index 0d040c2..e8ed701 100644 --- a/IntelliTect.Multitool.AotTest/Program.cs +++ b/IntelliTect.Multitool.AotTest/Program.cs @@ -20,7 +20,7 @@ return 1; } -// RepositoryPaths is excluded: its static initializer reads a build-time temp file +// RepositoryPaths is excluded: its static initializer reads a build-time file from the output directory // that doesn't exist at AOT runtime. The class is AOT-compatible (file I/O + LINQ only). Console.WriteLine("AOT test passed."); diff --git a/IntelliTect.Multitool/Build/IntelliTect.Multitool.targets b/IntelliTect.Multitool/Build/IntelliTect.Multitool.targets index d366ba6..2ca85d3 100644 --- a/IntelliTect.Multitool/Build/IntelliTect.Multitool.targets +++ b/IntelliTect.Multitool/Build/IntelliTect.Multitool.targets @@ -24,7 +24,6 @@ - $([System.IO.Path]::GetTempPath()) BuildingForLiveUnitTesting::$(BuildingForLiveUnitTesting) SolutionDir::$(SolutionDir) @@ -32,7 +31,6 @@ - - + diff --git a/IntelliTect.Multitool/RepositoryPaths.cs b/IntelliTect.Multitool/RepositoryPaths.cs index 35db6a5..9327cec 100644 --- a/IntelliTect.Multitool/RepositoryPaths.cs +++ b/IntelliTect.Multitool/RepositoryPaths.cs @@ -15,7 +15,7 @@ public static class RepositoryPaths /// /// Holds the key value pairs of the build variables that this class can use. /// - public static ReadOnlyDictionary BuildVariables { get; } = new(File.ReadAllLines(Path.Combine(Path.GetTempPath(), BuildVariableFileName)) + public static ReadOnlyDictionary BuildVariables { get; } = new(File.ReadAllLines(Path.Combine(AppContext.BaseDirectory, BuildVariableFileName)) .Select(line => line.Split("::")) .ToDictionary(split => split[0].Trim(), split => !string.IsNullOrEmpty(split[1]) ? split[1].Trim() : null));