Skip to content

Commit

Permalink
Disable Mono toolpath override for Windows executables when on WSL (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Thompson authored and matkoch committed May 1, 2019
1 parent 4b9afed commit 4256d71
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
21 changes: 21 additions & 0 deletions source/Nuke.Common/EnvironmentInfo.Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
// https://github.com/nuke-build/nuke/blob/master/LICENSE

using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Nuke.Common.Utilities;

namespace Nuke.Common
{
Expand Down Expand Up @@ -54,6 +56,25 @@ public static bool Is64Bit
/// </summary>
public static bool IsOsx => Platform == PlatformFamily.OSX;

/// <summary>
/// Returns whether the operating system is running under Windows Subsystem for Linux.
/// </summary>
public static bool IsWsl { get; } = GetIsWsl();

private static bool GetIsWsl() {

if (!IsLinux)
return false;

try {
var version = File.ReadAllText("/proc/version");
return version.ContainsOrdinalIgnoreCase("Microsoft");
}
catch (IOException) {
return false;
}
}

/// <summary>
/// Returns the framework the build is running on.
/// </summary>
Expand Down
4 changes: 3 additions & 1 deletion source/Nuke.Common/Tooling/ProcessTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ private static string GetToolPathOverride(string toolPath)
}

#if NETCORE
if (EnvironmentInfo.IsUnix && toolPath.EndsWithOrdinalIgnoreCase(".exe"))
if (EnvironmentInfo.IsUnix &&
toolPath.EndsWithOrdinalIgnoreCase(".exe") &&
!EnvironmentInfo.IsWsl)
return ToolPathResolver.GetPathExecutable("mono");
#endif

Expand Down

0 comments on commit 4256d71

Please sign in to comment.