dotnet-installer/test/Installer/Microsoft.DotNet.Cli.Msi.Tests/Utils.cs
Eric Erhardt d9adc9214a Running Windows installer tests on Docker.
Cleaning up the Installer tests
- rename project to conform to the rest of the tests
- convert to .xproj
- clean up unused usings
2016-02-19 16:45:37 -06:00

25 lines
758 B
C#

using System.IO;
using System.Linq;
using Microsoft.Win32;
namespace Dotnet.Cli.Msi.Tests
{
class Utils
{
internal static bool ExistsOnPath(string fileName)
{
var paths = GetCurrentPathEnvironmentVariable();
return paths
.Split(';')
.Any(path => File.Exists(Path.Combine(path, fileName)));
}
internal static string GetCurrentPathEnvironmentVariable()
{
var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
var regKey = hklm.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", false);
return (string)regKey.GetValue("Path");
}
}
}