use dotnet .dll and read launch settings

This commit is contained in:
Matt Parker
2025-08-24 13:16:02 +10:00
parent b394f7e655
commit 356a535085
4 changed files with 94 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
using System.Threading.Channels;
using Ardalis.GuardClauses;
using AsyncReadProcess;
using SharpIDE.Application.Features.Evaluation;
using SharpIDE.Application.Features.Events;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
@@ -22,16 +23,29 @@ public class RunService
if (project.RunningCancellationTokenSource is not null) throw new InvalidOperationException($"Project {project.Name} is already running with a cancellation token source.");
project.RunningCancellationTokenSource = new CancellationTokenSource();
var dllFullPath = ProjectEvaluation.GetOutputDllFullPath(project);
var launchProfiles = await LaunchSettingsParser.GetLaunchSettingsProfiles(project);
var launchProfile = launchProfiles.FirstOrDefault();
try
{
var processStartInfo = new ProcessStartInfo2
{
FileName = "dotnet",
Arguments = $"run --project \"{project.FilePath}\" --no-restore",
WorkingDirectory = Path.GetDirectoryName(project.FilePath),
//Arguments = $"run --project \"{project.FilePath}\" --no-restore",
Arguments = $"\"{dllFullPath}\"",
RedirectStandardOutput = true,
RedirectStandardError = true,
EnvironmentVariables = []
};
if (launchProfile is not null)
{
foreach (var envVar in launchProfile.EnvironmentVariables)
{
processStartInfo.EnvironmentVariables[envVar.Key] = envVar.Value;
}
if (launchProfile.ApplicationUrl != null) processStartInfo.EnvironmentVariables["ASPNETCORE_URLS"] = launchProfile.ApplicationUrl;
}
var process = new Process2
{