|
5 | 5 | using System.Collections.Generic; |
6 | 6 | using System.Diagnostics; |
7 | 7 | using System.Globalization; |
| 8 | +using System.IO; |
8 | 9 | using System.Threading; |
9 | 10 | using System.Threading.Tasks; |
| 11 | +using Microsoft.DotNet.Cli.Utils; |
10 | 12 | using Microsoft.DotNet.Watcher.Internal; |
11 | 13 | using Microsoft.DotNet.Watcher.Tools; |
12 | 14 | using Microsoft.Extensions.Tools.Internal; |
| 15 | +using IReporter = Microsoft.Extensions.Tools.Internal.IReporter; |
13 | 16 |
|
14 | 17 | namespace Microsoft.DotNet.Watcher |
15 | 18 | { |
@@ -82,7 +85,10 @@ public async Task WatchAsync(DotNetWatchContext context, CancellationToken cance |
82 | 85 | return; |
83 | 86 | } |
84 | 87 |
|
85 | | - ConfigureExecutable(context, processSpec); |
| 88 | + if (context.Iteration == 0) |
| 89 | + { |
| 90 | + ConfigureExecutable(context, processSpec); |
| 91 | + } |
86 | 92 |
|
87 | 93 | using var currentRunCancellationSource = new CancellationTokenSource(); |
88 | 94 | var forceReload = _console.ListenForForceReloadRequest(); |
@@ -200,6 +206,12 @@ private static void ConfigureExecutable(DotNetWatchContext context, ProcessSpec |
200 | 206 | processSpec.EnvironmentVariables["ASPNETCORE_URLS"] = context.DefaultLaunchSettingsProfile.ApplicationUrl; |
201 | 207 | } |
202 | 208 |
|
| 209 | + var rootVariableName = Environment.Is64BitProcess ? "DOTNET_ROOT" : "DOTNET_ROOT(x86)"; |
| 210 | + if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable(rootVariableName))) |
| 211 | + { |
| 212 | + processSpec.EnvironmentVariables[rootVariableName] = Path.GetDirectoryName(new Muxer().MuxerPath); |
| 213 | + } |
| 214 | + |
203 | 215 | if (context.DefaultLaunchSettingsProfile.EnvironmentVariables is IDictionary<string, string> envVariables) |
204 | 216 | { |
205 | 217 | foreach (var entry in context.DefaultLaunchSettingsProfile.EnvironmentVariables) |
|
0 commit comments