do not run project on failed build

This commit is contained in:
Matt Parker
2026-01-18 17:00:47 +10:00
parent fc9e6ef3ec
commit 56784ecfd3
2 changed files with 24 additions and 7 deletions

View File

@@ -33,15 +33,23 @@ public partial class RunService(ILogger<RunService> logger, RoslynAnalysis rosly
var semaphoreSlim = _projectLocks.GetOrAdd(project, new SemaphoreSlim(1, 1));
var waitResult = await semaphoreSlim.WaitAsync(0).ConfigureAwait(false);
if (waitResult is false) throw new InvalidOperationException($"Project {project.Name} is already running.");
if (project.RunningCancellationTokenSource is not null) throw new InvalidOperationException($"Project {project.Name} is already running with a cancellation token source.");
project.RunningCancellationTokenSource = new CancellationTokenSource();
await _buildService.MsBuildAsync(project.FilePath);
var launchProfiles = await LaunchSettingsParser.GetLaunchSettingsProfiles(project);
var launchProfile = launchProfiles.FirstOrDefault();
try
{
if (project.RunningCancellationTokenSource is not null) throw new InvalidOperationException($"Project {project.Name} is already running with a cancellation token source.");
var buildResult = await _buildService.MsBuildAsync(project.FilePath);
if (buildResult is not SharpIdeBuildResult.Success)
{
_logger.LogInformation("Build failed for project {ProjectName}. Aborting run/debug.", project.Name);
return;
}
project.RunningCancellationTokenSource = new CancellationTokenSource();
var launchProfiles = await LaunchSettingsParser.GetLaunchSettingsProfiles(project);
var launchProfile = launchProfiles.FirstOrDefault();
var fileName = launchProfile?.CommandName switch
{
"Executable" => launchProfile.ExecutablePath,