Skip to content

Commit c80a981

Browse files
committed
Fix switch to .NET Core 2 process
1 parent 611cfa7 commit c80a981

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Core/Generator.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ public bool Run()
259259
{
260260
Logger.Trace($"Different assembly framework found. Switching to {this.environment.SwitchToFramework}...");
261261
}
262-
Logger.Trace("===============================");
263-
ProcessStartInfo startInfo = new ProcessStartInfo();
264262
string location = Assembly.GetEntryAssembly()?.Location ?? throw new InvalidOperationException("No location found");
265263
Regex regex = new Regex(@"(?<separator>[\\/])(?<framework>net[^\\/]+)[\\/]");
266264
Match match = regex.Match(location);
@@ -275,10 +273,12 @@ public bool Run()
275273
location = location.Replace(separator + framework + separator, separator + switchedFramework + separator);
276274
if (FileSystem.FileExists(location))
277275
{
278-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
276+
ProcessStartInfo startInfo = new ProcessStartInfo();
277+
string locationExe = location.Replace(".dll", ".exe");
278+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && FileSystem.FileExists(locationExe))
279279
{
280280
// Always use the .exe on Windows to fix the dotnet.exe x86 problem
281-
startInfo.FileName = location.Replace(".dll", ".exe");;
281+
startInfo.FileName = locationExe;
282282
}
283283
else
284284
{
@@ -297,6 +297,7 @@ public bool Run()
297297
//startInfo.UseShellExecute = false;
298298
//startInfo.RedirectStandardOutput = true;
299299
//startInfo.RedirectStandardError = true;
300+
Logger.Trace("===============================");
300301
Process process = Process.Start(startInfo);
301302
process.OutputDataReceived += (sender, args) => Logger.Trace(">> " + args.Data);
302303
process.ErrorDataReceived += (sender, args) => Logger.Error(">> " + args.Data);

0 commit comments

Comments
 (0)