@@ -35,9 +35,23 @@ public static class ApplicationParameters
35
35
// always look at the official location of the machine installation
36
36
public static readonly string InstallLocation = System . Environment . GetEnvironmentVariable ( ChocolateyInstallEnvironmentVariableName ) ?? _fileSystem . get_directory_name ( _fileSystem . get_current_assembly_path ( ) ) ;
37
37
public static readonly string LicensedAssemblyLocation = _fileSystem . combine_paths ( InstallLocation , "extensions" , "chocolatey" , "chocolatey.licensed.dll" ) ;
38
- #else
38
+ #elif DEBUG
39
39
// Install location is choco.exe or chocolatey.dll
40
40
public static readonly string InstallLocation = _fileSystem . get_directory_name ( _fileSystem . get_current_assembly_path ( ) ) ;
41
+ // when being used as a reference, start by looking next to Chocolatey, then in a subfolder.
42
+ public static readonly string LicensedAssemblyLocation = _fileSystem . file_exists ( _fileSystem . combine_paths ( InstallLocation , "chocolatey.licensed.dll" ) ) ? _fileSystem . combine_paths ( InstallLocation , "chocolatey.licensed.dll" ) : _fileSystem . combine_paths ( InstallLocation , "extensions" , "chocolatey" , "chocolatey.licensed.dll" ) ;
43
+ #else
44
+ // Install locations is chocolatey.dll or choco.exe - In Release mode
45
+ // we might be testing on a server or in the local debugger. Either way,
46
+ // start from the assembly location and if unfound, head to the machine
47
+ // 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 ) ) :
50
+ ! string . IsNullOrWhiteSpace ( System . Environment . GetEnvironmentVariable ( ChocolateyInstallEnvironmentVariableName ) ) ?
51
+ System . Environment . GetEnvironmentVariable ( ChocolateyInstallEnvironmentVariableName ) :
52
+ @"C:\ProgramData\Chocolatey"
53
+ ;
54
+
41
55
// when being used as a reference, start by looking next to Chocolatey, then in a subfolder.
42
56
public static readonly string LicensedAssemblyLocation = _fileSystem . file_exists ( _fileSystem . combine_paths ( InstallLocation , "chocolatey.licensed.dll" ) ) ? _fileSystem . combine_paths ( InstallLocation , "chocolatey.licensed.dll" ) : _fileSystem . combine_paths ( InstallLocation , "extensions" , "chocolatey" , "chocolatey.licensed.dll" ) ;
43
57
#endif
0 commit comments