NuGet Sources Command output has changed
- Dominant language
- C#
- Stars
- 4.2k
- Forks
- 778
- Avg merge
- 3h 37m
- Merged PRs (30d)
- 21
Description
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
```c#
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
```c#
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`
Contributor guide
Research direction
Start in src/Cake.Common/Tools/NuGet/Sources/NuGetSources.cs around lines 141-142 and run `nuget sources list` to compare its current output with the alias's matching logic. Define completion as HasSource recognizing the numbered source format without partial-name matches, while preserving compatibility with the previously expected output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100