private static bool LaunchedFromVisualStudio()
{
if (PATH != null)
{
return true;
}
var processAndParent = ParentProcessUtils.CurrentProcessWithAncestors().ToArray();
Process process = null;
try
{
process = processAndParent.FirstOrDefault(x => x.MainModule.FileName.EndsWith("devenv.exe"));
}
catch (Exception)
{
// Any exception means we are not working in this environment.
return false;
}
if (process != null)
{
var processModule = process.MainModule;
var version = processModule.FileVersionInfo.FileMajorPart;
if (11 <= version)
{
PATH = processModule.FileName;
}
}
return PATH != null;
}
}