diff --git a/src/Core/RemoteRefExtensions.cs b/src/Core/RemoteRefExtensions.cs index bdda884..39097ae 100644 --- a/src/Core/RemoteRefExtensions.cs +++ b/src/Core/RemoteRefExtensions.cs @@ -1,6 +1,4 @@ -using System.Runtime.InteropServices; - -namespace Devlooped; +namespace Devlooped; public static class RemoteRefExtensions { @@ -11,13 +9,12 @@ public static class RemoteRefExtensions public string EnsureTempPath() => Directory.CreateUserDirectory(location.TempPath); } - /// Obtains the temporary directory root, e.g., /tmp/dotnet/runfile/. + /// Obtains the temporary directory root, e.g., ~/.local/share/dotnet/runfile/. static string GetTempRoot() { - // We want a location where permissions are expected to be restricted to the current user. - string directory = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? Path.GetTempPath() - : Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + // We use LocalApplicationData (not the system temp folder) on all platforms so that + // dnx's built-in cleanup of %TEMP% doesn't prune our cached repo downloads mid-run. + string directory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); return Directory.CreateUserDirectory(Path.Join(directory, "dotnet", "runfile")); } diff --git a/src/Core/RemoteRunner.cs b/src/Core/RemoteRunner.cs index 089ff48..4fea6aa 100644 --- a/src/Core/RemoteRunner.cs +++ b/src/Core/RemoteRunner.cs @@ -108,8 +108,11 @@ await AnsiConsole.Status().StartAsync($":open_file_folder: {location} :backhand_ if (updated) { - // Clean since otherwise we sometimes get stale build outputs? :/ - Process.Start(DotnetMuxer.Path.FullName, ["clean", "-v:q", program]).WaitForExit(); + var objDir = Path.Combine(location.TempPath, "obj"); + // Only clean when there are existing build artifacts; skip on freshly extracted + // directories (no obj/) since dotnet clean on a new dir can corrupt the lock file. + if (Directory.Exists(objDir)) + Process.Start(DotnetMuxer.Path.FullName, ["clean", "-v:q", program]).WaitForExit(); } string[] runargs = aot