Skip to content

Commit 54ddf11

Browse files
committed
Merge branch 'stable'
* stable: (chocolateyGH-1949) Add missed compilation symbol official (chocolateyGH-1949) Use only official/unofficial on resolve
2 parents 0308984 + 88eefa1 commit 54ddf11

File tree

5 files changed

+22
-27
lines changed

5 files changed

+22
-27
lines changed

src/chocolatey.console/Program.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,15 @@ private static void add_assembly_resolver()
189189
{
190190
var requestedAssembly = new AssemblyName(args.Name);
191191

192+
#if FORCE_CHOCOLATEY_OFFICIAL_KEY
193+
var chocolateyPublicKey = ApplicationParameters.OfficialChocolateyPublicKey;
194+
#else
195+
var chocolateyPublicKey = ApplicationParameters.UnofficialChocolateyPublicKey;
196+
#endif
197+
192198
// There are things that are ILMerged into Chocolatey. Anything with
193199
// the right public key except licensed should use the choco/chocolatey assembly
194-
if ((requestedAssembly.get_public_key_token().is_equal_to(ApplicationParameters.OfficialChocolateyPublicKey)
195-
#if !FORCE_CHOCOLATEY_OFFICIAL_KEY
196-
|| requestedAssembly.get_public_key_token().is_equal_to(ApplicationParameters.UnofficialChocolateyPublicKey)
197-
#endif
198-
)
200+
if (requestedAssembly.get_public_key_token().is_equal_to(chocolateyPublicKey)
199201
&& !requestedAssembly.Name.is_equal_to(ApplicationParameters.LicensedChocolateyAssemblySimpleName)
200202
&& !requestedAssembly.Name.EndsWith(".resources", StringComparison.OrdinalIgnoreCase))
201203
{
@@ -204,11 +206,7 @@ private static void add_assembly_resolver()
204206

205207
try
206208
{
207-
if ((requestedAssembly.get_public_key_token().is_equal_to(ApplicationParameters.OfficialChocolateyPublicKey)
208-
#if !FORCE_CHOCOLATEY_OFFICIAL_KEY
209-
|| requestedAssembly.get_public_key_token().is_equal_to(ApplicationParameters.UnofficialChocolateyPublicKey)
210-
#endif
211-
)
209+
if (requestedAssembly.get_public_key_token().is_equal_to(chocolateyPublicKey)
212210
&& requestedAssembly.Name.is_equal_to(ApplicationParameters.LicensedChocolateyAssemblySimpleName))
213211
{
214212
"chocolatey".Log().Debug(() => "Resolving reference to chocolatey.licensed...");

src/chocolatey.resources/chocolatey.resources.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</PropertyGroup>
4141
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseOfficial|AnyCPU'">
4242
<OutputPath>bin\ReleaseOfficial\</OutputPath>
43-
<DefineConstants>TRACE</DefineConstants>
43+
<DefineConstants>TRACE;FORCE_CHOCOLATEY_OFFICIAL_KEY</DefineConstants>
4444
<Optimize>true</Optimize>
4545
<PlatformTarget>AnyCPU</PlatformTarget>
4646
<ErrorReport>prompt</ErrorReport>

src/chocolatey/GetChocolatey.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ private static void add_assembly_resolver()
6868

6969
// There are things that are ILMerged into Chocolatey. Anything with
7070
// the right public key except licensed should use the choco/chocolatey assembly
71-
if ((requestedAssembly.get_public_key_token().is_equal_to(ApplicationParameters.OfficialChocolateyPublicKey)
72-
#if !FORCE_CHOCOLATEY_OFFICIAL_KEY
73-
|| requestedAssembly.get_public_key_token().is_equal_to(ApplicationParameters.UnofficialChocolateyPublicKey)
71+
#if FORCE_CHOCOLATEY_OFFICIAL_KEY
72+
var chocolateyPublicKey = ApplicationParameters.OfficialChocolateyPublicKey;
73+
#else
74+
var chocolateyPublicKey = ApplicationParameters.UnofficialChocolateyPublicKey;
7475
#endif
75-
)
76+
if (requestedAssembly.get_public_key_token().is_equal_to(chocolateyPublicKey)
7677
&& !requestedAssembly.Name.is_equal_to(ApplicationParameters.LicensedChocolateyAssemblySimpleName)
7778
&& !requestedAssembly.Name.EndsWith(".resources", StringComparison.OrdinalIgnoreCase))
7879
{
@@ -81,11 +82,7 @@ private static void add_assembly_resolver()
8182

8283
try
8384
{
84-
if ((requestedAssembly.get_public_key_token().is_equal_to(ApplicationParameters.OfficialChocolateyPublicKey)
85-
#if !FORCE_CHOCOLATEY_OFFICIAL_KEY
86-
|| requestedAssembly.get_public_key_token().is_equal_to(ApplicationParameters.UnofficialChocolateyPublicKey)
87-
#endif
88-
)
85+
if (requestedAssembly.get_public_key_token().is_equal_to(chocolateyPublicKey)
8986
&& requestedAssembly.Name.is_equal_to(ApplicationParameters.LicensedChocolateyAssemblySimpleName))
9087
{
9188
_logger.Debug("Resolving reference to chocolatey.licensed...");

src/chocolatey/chocolatey.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseOfficial|AnyCPU'">
5454
<DebugSymbols>true</DebugSymbols>
5555
<OutputPath>bin\ReleaseOfficial\</OutputPath>
56-
<DefineConstants>TRACE</DefineConstants>
56+
<DefineConstants>TRACE;FORCE_CHOCOLATEY_OFFICIAL_KEY</DefineConstants>
5757
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
5858
<DocumentationFile>bin\Release\chocolatey.xml</DocumentationFile>
5959
<Optimize>true</Optimize>

src/chocolatey/infrastructure/licensing/License.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ public static ChocolateyLicense validate_license()
3232
{
3333
try
3434
{
35-
var licensedAssembly = AssemblyResolution.resolve_or_load_assembly(ApplicationParameters.LicensedChocolateyAssemblySimpleName, ApplicationParameters.OfficialChocolateyPublicKey, ApplicationParameters.LicensedAssemblyLocation);
3635

37-
#if !FORCE_CHOCOLATEY_OFFICIAL_KEY
38-
if (licensedAssembly == null)
39-
{
40-
licensedAssembly = AssemblyResolution.resolve_or_load_assembly(ApplicationParameters.LicensedChocolateyAssemblySimpleName, ApplicationParameters.UnofficialChocolateyPublicKey, ApplicationParameters.LicensedAssemblyLocation);
41-
}
36+
#if FORCE_CHOCOLATEY_OFFICIAL_KEY
37+
var chocolateyPublicKey = ApplicationParameters.OfficialChocolateyPublicKey;
38+
#else
39+
var chocolateyPublicKey = ApplicationParameters.UnofficialChocolateyPublicKey;
4240
#endif
41+
var licensedAssembly = AssemblyResolution.resolve_or_load_assembly(ApplicationParameters.LicensedChocolateyAssemblySimpleName, chocolateyPublicKey, ApplicationParameters.LicensedAssemblyLocation);
42+
4343
if (licensedAssembly == null) throw new ApplicationException("Unable to load licensed assembly.");
4444
license.AssemblyLoaded = true;
4545
license.Assembly = licensedAssembly;

0 commit comments

Comments
 (0)