Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/Core/RemoteRefExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Runtime.InteropServices;

namespace Devlooped;
namespace Devlooped;

public static class RemoteRefExtensions
{
Expand All @@ -11,13 +9,12 @@ public static class RemoteRefExtensions
public string EnsureTempPath() => Directory.CreateUserDirectory(location.TempPath);
}

/// <summary>Obtains the temporary directory root, e.g., <c>/tmp/dotnet/runfile/</c>.</summary>
/// <summary>Obtains the temporary directory root, e.g., <c>~/.local/share/dotnet/runfile/</c>.</summary>
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"));
}
Expand Down
7 changes: 5 additions & 2 deletions src/Core/RemoteRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down