cake icon indicating copy to clipboard operation
cake copied to clipboard

NuGet Sources Command output has changed

Open JonCubed opened this issue 9 years ago • 1 comments

I was trying out the NuGet Aliases and found that HasSource was not working. After some investigation and running the command nuget sources list manually I can see that the output format

Registered Sources:

  1.  nuget.org [Enabled]
      https://api.nuget.org/v3/index.json
  2.  Microsoft Visual Studio Offline Packages [Enabled]
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

has changed and is not was is expected by the alias (L#142)

https://github.com/cake-build/cake/blob/3dccfa1dec00c17b6c038d2564a99cc36d03598a/src/Cake.Common/Tools/NuGet/Sources/NuGetSources.cs#L141-L142

A naive fix that was backwards compatable would be something like

process => result = process.GetStandardOutput().Any(line => line.TrimStart() == source || line.Contains(source))

but this has the problem of partial matches if one source name is a substring of another. (How likely?)

Alternatively we could have some regex that matches on the line format

process => result = process.GetStandardOutput().Any(line => line.TrimStart() == source || Regex.IsMatch(line, $@"\d+\.  {source} \["))

second method is my preference and happy to put in a pr for either or alternate solution

Update 1: using NuGet Version: 4.1.0.2450

JonCubed avatar Nov 17 '17 05:11 JonCubed

Same for me

NuGet Version : 6.8.0.131 Cake 4.0.0

Florian2145 avatar Nov 30 '23 14:11 Florian2145