Skip to content

Commit 564a652

Browse files
committed
Merge branch 'stable'
* stable: (chocolateyGH-1949) Release mode - account for null entry assembly
2 parents a230cc6 + 385076d commit 564a652

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/chocolatey/infrastructure.app/ApplicationParameters.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ public static class ApplicationParameters
4545
// we might be testing on a server or in the local debugger. Either way,
4646
// start from the assembly location and if unfound, head to the machine
4747
// locations instead. This is a merge of official and Debug modes.
48-
public static readonly string InstallLocation = _fileSystem.file_exists(_fileSystem.combine_paths(_fileSystem.get_directory_name(Assembly.GetEntryAssembly().CodeBase.Replace("file:///", string.Empty)), "chocolatey.dll")) ?
49-
_fileSystem.get_directory_name(Assembly.GetEntryAssembly().CodeBase.Replace("file:///", string.Empty)) :
48+
private static IAssembly _assemblyForLocation = Assembly.GetEntryAssembly().UnderlyingType != null ? Assembly.GetEntryAssembly() : Assembly.GetExecutingAssembly();
49+
public static readonly string InstallLocation = _fileSystem.file_exists(_fileSystem.combine_paths(_fileSystem.get_directory_name(_assemblyForLocation.CodeBase.Replace("file:///", string.Empty)), "chocolatey.dll")) ||
50+
_fileSystem.file_exists(_fileSystem.combine_paths(_fileSystem.get_directory_name(_assemblyForLocation.CodeBase.Replace("file:///", string.Empty)), "choco.exe")) ?
51+
_fileSystem.get_directory_name(_assemblyForLocation.CodeBase.Replace("file:///", string.Empty)) :
5052
!string.IsNullOrWhiteSpace(System.Environment.GetEnvironmentVariable(ChocolateyInstallEnvironmentVariableName)) ?
5153
System.Environment.GetEnvironmentVariable(ChocolateyInstallEnvironmentVariableName) :
5254
@"C:\ProgramData\Chocolatey"

0 commit comments

Comments
 (0)