Skip to content

Commit 459c640

Browse files
committed
Merge branch 'hotfix/0.13.3'
* hotfix/0.13.3: (#65) Remove usage of NuGet.config file
2 parents 7463162 + 210b1b9 commit 459c640

File tree

1 file changed

+19
-35
lines changed

1 file changed

+19
-35
lines changed

Chocolatey.Cake.Recipe/Content/parameters.cake

+19-35
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public static class BuildParameters
9191
public static string StrongNameDependentAssembliesInputPath { get; private set; }
9292
public static string AssemblyNamesRegexPattern { get; private set; }
9393
public static bool UseChocolateyGuiStrongNameKey { get; private set; }
94-
public static FilePath NuGetConfig { get; private set; }
9594
public static ICollection<string> NuGetSources { get; private set; }
9695
public static DirectoryPath RestorePackagesDirectory { get; private set; }
9796
public static Func<FilePathCollection> GetFilesToObfuscate { get; private set; }
@@ -162,7 +161,6 @@ public static class BuildParameters
162161
context.Information("BuildAgentOperatingSystem: {0}", BuildAgentOperatingSystem);
163162
context.Information("RepositoryOwner: {0}", RepositoryOwner);
164163
context.Information("RepositoryName: {0}", RepositoryName);
165-
context.Information("NuGetConfig: {0} ({1})", NuGetConfig, context.FileExists(NuGetConfig));
166164
context.Information("Build Counter: {0}", BuildCounter);
167165
context.Information("Test Execution Type: {0}", TestExecutionType);
168166
context.Information("RestorePackagesDirectory: {0}", RestorePackagesDirectory);
@@ -278,7 +276,6 @@ public static class BuildParameters
278276
bool useChocolateyGuiStrongNameKey = false,
279277
string strongNameDependentAssembliesInputPath = null,
280278
string assemblyNamesRegexPattern = null,
281-
FilePath nugetConfig = null,
282279
ICollection<string> nuGetSources = null,
283280
bool treatWarningsAsErrors = true,
284281
DirectoryPath restorePackagesDirectory = null,
@@ -379,7 +376,6 @@ public static class BuildParameters
379376
AssemblyNamesRegexPattern = assemblyNamesRegexPattern ?? "chocolatey.lib|chocolatey-licensed.lib|ChocolateyGui.Common|ChocolateyGui.Common.Windows";
380377
UseChocolateyGuiStrongNameKey = useChocolateyGuiStrongNameKey;
381378

382-
NuGetConfig = context.MakeAbsolute(nugetConfig ?? (FilePath)"./NuGet.Config");
383379
NuGetSources = nuGetSources;
384380
RestorePackagesDirectory = restorePackagesDirectory;
385381
GetFilesToObfuscate = getFilesToObfuscate;
@@ -402,47 +398,35 @@ public static class BuildParameters
402398

403399
if (nuGetSources == null)
404400
{
405-
if (context.FileExists(NuGetConfig))
401+
var primaryNuGetSource = context.EnvironmentVariable("PRIMARY_NUGET_SOURCE");
402+
403+
if (!string.IsNullOrEmpty(primaryNuGetSource))
406404
{
407-
NuGetSources = (
408-
from configuration in System.Xml.Linq.XDocument.Load(NuGetConfig.FullPath).Elements("configuration")
409-
from packageSources in configuration.Elements("packageSources")
410-
from add in packageSources.Elements("add")
411-
from value in add.Attributes("value")
412-
select value.Value
413-
).ToArray();
414-
415-
context.Information("NuGet Sources configured from nuget.config file.");
405+
NuGetSources = new []{
406+
primaryNuGetSource
407+
};
408+
409+
context.Information("NuGet Sources configured using primary NuGet Source.");
416410
}
417411
else
418412
{
419-
var primaryNuGetSource = context.EnvironmentVariable("PRIMARY_NUGET_SOURCE");
413+
var nuGetDevRestoreNuGetSource = context.EnvironmentVariable("NUGETDEVRESTORE_SOURCE");
420414

421-
if (!string.IsNullOrEmpty(primaryNuGetSource))
415+
var devNuGetSources = new List<string>
422416
{
423-
NuGetSources = new []{
424-
primaryNuGetSource
425-
};
417+
"https://www.nuget.org/api/v2/",
418+
"https://api.nuget.org/v3/index.json"
419+
};
426420

427-
context.Information("NuGet Sources configured using primary NuGet Source.");
428-
}
429-
else
421+
if (!string.IsNullOrEmpty(nuGetDevRestoreNuGetSource))
430422
{
431-
var devNuGetSources = new List<string>
432-
{
433-
"https://www.nuget.org/api/v2/",
434-
"https://api.nuget.org/v3/index.json"
435-
};
436-
437-
if (context.HasEnvironmentVariable("NUGETDEVRESTORE_SOURCE"))
438-
{
439-
devNuGetSources.Add(context.EnvironmentVariable("NUGETDEVRESTORE_SOURCE"));
440-
}
423+
context.Information("Adding source to default values: {0}", nuGetDevRestoreNuGetSource);
424+
devNuGetSources.Add(nuGetDevRestoreNuGetSource);
425+
}
441426

442-
NuGetSources = devNuGetSources;
427+
NuGetSources = devNuGetSources;
443428

444-
context.Information("NuGet Sources configured using default values.");
445-
}
429+
context.Information("NuGet Sources configured using default values.");
446430
}
447431
}
448432

0 commit comments

Comments
 (0)