Skip to content

Commit

Permalink
Adjusted MSTest tool resolution
Browse files Browse the repository at this point in the history
* Added fallback to check environment for VisualStudio path if not found in default location
* Fixes cake-build#823
  • Loading branch information
devlead committed Apr 15, 2016
1 parent c2ce6b3 commit 9a2fac1
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/Cake.Common/Tools/MSTest/MSTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void Run(IEnumerable<FilePath> assemblyPaths, MSTestSettings settings)
{
if (assemblyPaths == null)
{
throw new ArgumentNullException("assemblyPath");
throw new ArgumentNullException("assemblyPaths");
}
if (settings == null)
{
Expand Down Expand Up @@ -99,6 +99,15 @@ protected override IEnumerable<FilePath> GetAlternativeToolPaths(MSTestSettings
yield return path;
}
}

foreach (var environmentVariable in new[] { "VS140COMNTOOLS", "VS130COMNTOOLS", "VS120COMNTOOLS", "VS110COMNTOOLS", "VS100COMNTOOLS" })
{
var path = GetCommonToolPath(environmentVariable);
if (path != null && _fileSystem.Exist(path))
{
yield return path;
}
}
}

private FilePath GetToolPath(string version)
Expand All @@ -107,5 +116,18 @@ private FilePath GetToolPath(string version)
var root = programFiles.Combine(string.Concat("Microsoft Visual Studio ", version, "/Common7/IDE"));
return root.CombineWithFilePath("mstest.exe");
}

private FilePath GetCommonToolPath(string environmentVariable)
{
var visualStudioCommonToolsPath = _environment.GetEnvironmentVariable(environmentVariable);

if (string.IsNullOrWhiteSpace(visualStudioCommonToolsPath))
{
return null;
}

var root = new DirectoryPath(visualStudioCommonToolsPath).Combine("../IDE");
return root.CombineWithFilePath("mstest.exe");
}
}
}

0 comments on commit 9a2fac1

Please sign in to comment.