From 5e6e53d99070d16671305e55f2dbbc7d82b9a35f Mon Sep 17 00:00:00 2001 From: Ehsan Iran-Nejad Date: Mon, 19 Oct 2020 16:58:08 -0700 Subject: [PATCH] fix re issue #1031 [cli] --- dev/pyRevitLabs/pyRevitLabs.Common/UserEnv.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dev/pyRevitLabs/pyRevitLabs.Common/UserEnv.cs b/dev/pyRevitLabs/pyRevitLabs.Common/UserEnv.cs index 269f81ca6..e703694e0 100644 --- a/dev/pyRevitLabs/pyRevitLabs.Common/UserEnv.cs +++ b/dev/pyRevitLabs/pyRevitLabs.Common/UserEnv.cs @@ -52,7 +52,10 @@ public static Version GetInstalledDotNetVersion() { public static List GetInstalledDotnetTargetPacks() { var targetPackPaths = new List(); - var frameworkPath = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework"; + var frameworkPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), + @"Reference Assemblies\Microsoft\Framework\.NETFramework" + ); foreach (string path in Directory.GetDirectories(frameworkPath)) if (Regex.Match(Path.GetFileName(path), @"\d\..+").Success) targetPackPaths.Add(path); @@ -61,7 +64,10 @@ public static List GetInstalledDotnetTargetPacks() { public static List GetInstalledDotnetCoreTargetPacks() { var targetPackPaths = new List(); - var frameworkPath = @"C:\Program Files\dotnet\sdk"; + var frameworkPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), + @"dotnet\sdk" + ); foreach (string path in Directory.GetDirectories(frameworkPath)) if (Regex.Match(Path.GetFileName(path), @"\d\..+").Success) targetPackPaths.Add(path); @@ -80,7 +86,8 @@ public static string GetLoggedInUserName() { foreach (ManagementObject oReturn in oReturnCollection) { return oReturn["UserName"].ToString(); } - } catch (Exception ex) { + } + catch (Exception ex) { logger.Debug("Failed to get logged in username. | {0}", ex.Message); } return null;