Skip to content

Commit 3f5fde0

Browse files
committed
(chocolateyGH-1949) switch assembly location on official key
Previously, Debug vs Release was the switch to where Chocolatey resolved its location along with where the licensed dll would be. Now use the official key setting to determine that switching. This should allow locating items next to chocolatey if local as well as when installed at the machine level. For release official mode, maintain what used to be Release to allow for that same behavior to continue.
1 parent 49221ed commit 3f5fde0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/chocolatey/infrastructure.app/ApplicationParameters.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ public static class ApplicationParameters
3030
private static readonly IFileSystem _fileSystem = new DotNetFileSystem();
3131
public static readonly string ChocolateyInstallEnvironmentVariableName = "ChocolateyInstall";
3232
public static readonly string Name = "Chocolatey";
33-
#if DEBUG
34-
public static readonly string InstallLocation = _fileSystem.get_directory_name(_fileSystem.get_current_assembly_path());
35-
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");
3633

37-
#else
34+
#if FORCE_CHOCOLATEY_OFFICIAL_KEY
35+
// always look at the official location of the machine installation
3836
public static readonly string InstallLocation = System.Environment.GetEnvironmentVariable(ChocolateyInstallEnvironmentVariableName) ?? _fileSystem.get_directory_name(_fileSystem.get_current_assembly_path());
3937
public static readonly string LicensedAssemblyLocation = _fileSystem.combine_paths(InstallLocation, "extensions", "chocolatey", "chocolatey.licensed.dll");
38+
#else
39+
// Install location is choco.exe or chocolatey.dll
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");
4043
#endif
4144

4245
public static readonly string CommonAppDataChocolatey = _fileSystem.combine_paths(System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData), Name);

0 commit comments

Comments
 (0)