diff --git a/cake/msbuild.cake b/cake/msbuild.cake index 8bd1234ee7..cef3b6839c 100644 --- a/cake/msbuild.cake +++ b/cake/msbuild.cake @@ -5,17 +5,26 @@ DirectoryPath OUTPUT_SYMBOLS_NUGETS_PATH = MakeAbsolute(ROOT_PATH.Combine("outpu var NUGETS_SOURCES = new [] { OUTPUT_NUGETS_PATH.FullPath, - "https://api.nuget.org/v3/index.json", - "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json", - "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json", - "https://pkgs.dev.azure.com/azure-public/vside/_packaging/xamarin-impl/nuget/v3/index.json", - "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json", - "https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-aspnetcore-7c57ecbd-3/nuget/v3/index.json", - "https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-4822e3c3-5/nuget/v3/index.json", - "https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-windowsdesktop-59fea7da-4/nuget/v3/index.json", - "https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-1ec2e17f-4/nuget/v3/index.json" }; +string[] GetNuGetSources() +{ + // load all the sources from nuget.config + var xdoc = XDocument.Load("nuget.config"); + var xmlns = xdoc.Root.Name.Namespace; + var adds = xdoc.Elements(xmlns + "configuration") + .Elements(xmlns + "packageSources") + .Elements(xmlns + "add") + .Select(x => x.Attribute("value").Value) + .ToList(); + + // add the NUGETS_SOURCES because it may contain local folders + adds.AddRange(NUGETS_SOURCES); + + // return all + return adds.ToArray(); +} + void RunNuGetRestorePackagesConfig(FilePath sln) { var dir = sln.GetDirectory(); @@ -23,7 +32,7 @@ void RunNuGetRestorePackagesConfig(FilePath sln) EnsureDirectoryExists(OUTPUT_NUGETS_PATH); var settings = new NuGetRestoreSettings { - Source = NUGETS_SOURCES, + Source = GetNuGetSources(), NoCache = true, PackagesDirectory = dir.Combine("packages"), }; @@ -92,8 +101,8 @@ void RunMSBuild( c.Properties [prop.Key] = new [] { prop.Value }; } } - // c.Properties ["RestoreSources"] = NUGETS_SOURCES; + // c.Properties ["RestoreSources"] = GetNuGetSources(); var sep = IsRunningOnWindows() ? ";" : "%3B"; - c.ArgumentCustomization = args => args.Append($"/p:RestoreSources=\"{string.Join(sep, NUGETS_SOURCES)}\""); + c.ArgumentCustomization = args => args.Append($"/p:RestoreSources=\"{string.Join(sep, GetNuGetSources())}\""); }); } diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000000..e796bb2610 --- /dev/null +++ b/nuget.config @@ -0,0 +1,13 @@ + + + + + + + + + + + + +