Get output dll path from workspace

This commit is contained in:
Matt Parker
2025-11-19 00:01:58 +10:00
parent 5794020ee2
commit 06a5c47a7e
4 changed files with 21 additions and 15 deletions

View File

@@ -1000,6 +1000,15 @@ public class RoslynAnalysis(ILogger<RoslynAnalysis> logger, BuildService buildSe
_workspace.TryApplyChanges(updatedSolution);
}
public async Task<string> GetOutputDllPathForProject(SharpIdeProjectModel projectModel)
{
await _solutionLoadedTcs.Task;
var project = GetProjectForSharpIdeProjectModel(projectModel);
var outputPath = project.OutputFilePath;
Guard.Against.NullOrWhiteSpace(outputPath);
return outputPath;
}
private static Project GetProjectForSharpIdeFile(SharpIdeFile sharpIdeFile)
{
var sharpIdeProjectModel = ((IChildSharpIdeNode)sharpIdeFile).GetNearestProjectNode()!;

View File

@@ -32,14 +32,6 @@ public static class ProjectEvaluation
project.ReevaluateIfNecessary();
}
public static string? GetOutputDllFullPath(SharpIdeProjectModel projectModel)
{
var project = _projectCollection.GetLoadedProjects(projectModel.FilePath).Single();
var targetPath = project.GetPropertyValue("TargetPath");
Guard.Against.NullOrWhiteSpace(targetPath, nameof(targetPath));
return targetPath;
}
public static Guid GetOrCreateDotnetUserSecretsId(SharpIdeProjectModel projectModel)
{
Guard.Against.Null(projectModel, nameof(projectModel));

View File

@@ -3,6 +3,7 @@ using System.Threading.Channels;
using Ardalis.GuardClauses;
using AsyncReadProcess;
using Microsoft.Extensions.Logging;
using SharpIDE.Application.Features.Analysis;
using SharpIDE.Application.Features.Debugging;
using SharpIDE.Application.Features.Evaluation;
using SharpIDE.Application.Features.Events;
@@ -11,13 +12,14 @@ using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
namespace SharpIDE.Application.Features.Run;
public class RunService(ILogger<RunService> logger)
public class RunService(ILogger<RunService> logger, RoslynAnalysis roslynAnalysis)
{
private readonly ConcurrentDictionary<SharpIdeProjectModel, SemaphoreSlim> _projectLocks = [];
public ConcurrentDictionary<SharpIdeFile, List<Breakpoint>> Breakpoints { get; } = [];
private Debugger? _debugger; // TODO: Support multiple debuggers for multiple running projects
private readonly ILogger<RunService> _logger = logger;
private readonly RoslynAnalysis _roslynAnalysis = roslynAnalysis;
public async Task RunProject(SharpIdeProjectModel project, bool isDebug = false, string? debuggerExecutablePath = null)
{
@@ -40,7 +42,7 @@ public class RunService(ILogger<RunService> logger)
FileName = "dotnet",
WorkingDirectory = Path.GetDirectoryName(project.FilePath),
//Arguments = $"run --project \"{project.FilePath}\" --no-restore",
Arguments = GetRunArguments(project),
Arguments = await GetRunArguments(project),
RedirectStandardOutput = true,
RedirectStandardError = true,
EnvironmentVariables = []
@@ -156,9 +158,9 @@ public class RunService(ILogger<RunService> logger)
return await _debugger!.GetInfoAtStopPoint();
}
private string GetRunArguments(SharpIdeProjectModel project)
private async Task<string> GetRunArguments(SharpIdeProjectModel project)
{
var dllFullPath = ProjectEvaluation.GetOutputDllFullPath(project);
var dllFullPath = await _roslynAnalysis.GetOutputDllPathForProject(project);
if (project.IsBlazorProject)
{
var blazorDevServerVersion = project.BlazorDevServerVersion;

View File

@@ -1,12 +1,15 @@
using SharpIDE.Application.Features.Evaluation;
using SharpIDE.Application.Features.Analysis;
using SharpIDE.Application.Features.Evaluation;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
using SharpIDE.Application.Features.Testing.Client;
using SharpIDE.Application.Features.Testing.Client.Dtos;
namespace SharpIDE.Application.Features.Testing;
public class TestRunnerService
public class TestRunnerService(RoslynAnalysis roslynAnalysis)
{
private readonly RoslynAnalysis _roslynAnalysis = roslynAnalysis;
public async Task<List<TestNode>> DiscoverTests(SharpIdeSolutionModel solutionModel)
{
await Task.WhenAll(solutionModel.AllProjects.Select(s => s.MsBuildEvaluationProjectTask));
@@ -59,7 +62,7 @@ public class TestRunnerService
private async Task<TestingPlatformClient> GetInitialisedClientAsync(SharpIdeProjectModel project)
{
var outputDllPath = ProjectEvaluation.GetOutputDllFullPath(project);
var outputDllPath = await _roslynAnalysis.GetOutputDllPathForProject(project);
var outputExecutablePath = 0 switch
{
_ when OperatingSystem.IsWindows() => outputDllPath!.Replace(".dll", ".exe"),