Skip to content

Commit

Permalink
fix re issue #1031 [cli]
Browse files Browse the repository at this point in the history
  • Loading branch information
eirannejad committed Oct 19, 2020
1 parent f58dde3 commit 5e6e53d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions dev/pyRevitLabs/pyRevitLabs.Common/UserEnv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ public static Version GetInstalledDotNetVersion() {

public static List<string> GetInstalledDotnetTargetPacks() {
var targetPackPaths = new List<string>();
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);
Expand All @@ -61,7 +64,10 @@ public static List<string> GetInstalledDotnetTargetPacks() {

public static List<string> GetInstalledDotnetCoreTargetPacks() {
var targetPackPaths = new List<string>();
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);
Expand All @@ -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;
Expand Down

0 comments on commit 5e6e53d

Please sign in to comment.