Skip to content

Commit

Permalink
Merge pull request #2371 from TheCakeIsNaOH/prefix-slash
Browse files Browse the repository at this point in the history
(#2369 #2370) Do not trim forward slashs prefixes on Linux
  • Loading branch information
gep13 authored Sep 19, 2021
2 parents 4a413d2 + 5ba9183 commit ccac272
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/chocolatey/infrastructure.app/ApplicationParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace chocolatey.infrastructure.app
using adapters;
using filesystem;
using Environment = System.Environment;
using chocolatey.infrastructure.platforms;

/// <summary>
/// Application constants and settings for the application
Expand All @@ -46,9 +47,9 @@ public static class ApplicationParameters
// start from the assembly location and if unfound, head to the machine
// locations instead. This is a merge of official and Debug modes.
private static IAssembly _assemblyForLocation = Assembly.GetEntryAssembly().UnderlyingType != null ? Assembly.GetEntryAssembly() : Assembly.GetExecutingAssembly();
public static readonly string InstallLocation = _fileSystem.file_exists(_fileSystem.combine_paths(_fileSystem.get_directory_name(_assemblyForLocation.CodeBase.Replace("file:///", string.Empty)), "chocolatey.dll")) ||
_fileSystem.file_exists(_fileSystem.combine_paths(_fileSystem.get_directory_name(_assemblyForLocation.CodeBase.Replace("file:///", string.Empty)), "choco.exe")) ?
_fileSystem.get_directory_name(_assemblyForLocation.CodeBase.Replace("file:///", string.Empty)) :
public static readonly string InstallLocation = _fileSystem.file_exists(_fileSystem.combine_paths(_fileSystem.get_directory_name(_assemblyForLocation.CodeBase.Replace(Platform.get_platform() == PlatformType.Windows ? "file:///" : "file://", string.Empty)), "chocolatey.dll")) ||
_fileSystem.file_exists(_fileSystem.combine_paths(_fileSystem.get_directory_name(_assemblyForLocation.CodeBase.Replace(Platform.get_platform() == PlatformType.Windows ? "file:///" : "file://", string.Empty)), "choco.exe")) ?
_fileSystem.get_directory_name(_assemblyForLocation.CodeBase.Replace(Platform.get_platform() == PlatformType.Windows ? "file:///" : "file://", string.Empty)) :
!string.IsNullOrWhiteSpace(System.Environment.GetEnvironmentVariable(ChocolateyInstallEnvironmentVariableName)) ?
System.Environment.GetEnvironmentVariable(ChocolateyInstallEnvironmentVariableName) :
@"C:\ProgramData\Chocolatey"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public string get_executable_path(string executableName)

public string get_current_assembly_path()
{
return Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", string.Empty);
return Assembly.GetExecutingAssembly().CodeBase.Replace(Platform.get_platform() == PlatformType.Windows ? "file:///" : "file://", string.Empty);
}

#endregion
Expand Down

0 comments on commit ccac272

Please sign in to comment.