@@ -19,6 +19,10 @@ public class BuildSettings
19
19
20
20
BuildVersion = new BuildVersion ( context ) ;
21
21
22
+ MyGetApiKey = GetApiKey ( MYGET_API_KEY , FALLBACK_MYGET_API_KEY ) ;
23
+ NuGetApiKey = GetApiKey ( NUGET_API_KEY , FALLBACK_NUGET_API_KEY ) ;
24
+ ChocolateyApiKey = GetApiKey ( CHOCO_API_KEY , FALLBACK_CHOCO_API_KEY ) ;
25
+
22
26
Net35Test = new PackageTest (
23
27
"Net35Test" ,
24
28
"Run mock-assembly.dll under .NET 3.5" ,
@@ -175,9 +179,9 @@ public class BuildSettings
175
179
public bool ShouldPublishToChocolatey => ! IsPreRelease || LABELS_WE_PUBLISH_ON_CHOCOLATEY . Contains ( PreReleaseLabel ) ;
176
180
public bool IsProductionRelease => ! IsPreRelease || LABELS_WE_RELEASE_ON_GITHUB . Contains ( PreReleaseLabel ) ;
177
181
178
- public string MyGetApiKey => _context . EnvironmentVariable ( MYGET_API_KEY ) ;
179
- public string NuGetApiKey => _context . EnvironmentVariable ( NUGET_API_KEY ) ;
180
- public string ChocolateyApiKey => _context . EnvironmentVariable ( CHOCO_API_KEY ) ;
182
+ public string MyGetApiKey { get ; }
183
+ public string NuGetApiKey { get ; }
184
+ public string ChocolateyApiKey { get ; }
181
185
182
186
public string GitHubAccessToken => _context . EnvironmentVariable ( GITHUB_ACCESS_TOKEN ) ;
183
187
@@ -291,6 +295,16 @@ public class BuildSettings
291
295
Console . WriteLine ( $ " NetCore Runner: { NETCORE_CONSOLE_PROJECT } ") ;
292
296
}
293
297
298
+ private string GetApiKey ( string name , string fallback = null )
299
+ {
300
+ var apikey = _context . EnvironmentVariable ( name ) ;
301
+
302
+ if ( string . IsNullOrEmpty ( apikey ) && fallback != null )
303
+ apikey = _context . EnvironmentVariable ( fallback ) ;
304
+
305
+ return apikey ;
306
+ }
307
+
294
308
private void ShowApiKeyAvailability ( string apikey )
295
309
{
296
310
if ( string . IsNullOrEmpty ( apikey ) )
0 commit comments