Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashes when run in a folder with many subfolders with solutions / projects #195

Closed
viblo-majority opened this issue May 24, 2024 · 3 comments

Comments

@viblo-majority
Copy link

viblo-majority commented May 24, 2024

Steps to reproduce
I apologize in advance that this might be tricky to reproduce.

We have a microservice setup, with individual git repos for each service (which then also has their own sln and csproj files). These are all checked out into a root folder, lets call it X. When I run libyear directly in this root it crashes. If I just take one or two subfolders it works.

Expected behavior
Not crash.

Observed behavior

PS C:\code\dotnet libyear

ArgumentException: An item with the same key has already been added. Key: XXX.Platform.MessageBus
  at bool TryInsert(TKey key, TValue value, InsertionBehavior behavior)
  at void Add(TKey key, TValue value)
  at Dictionary<TKey, TElement> ToDictionary<TSource,TKey,TElement>(IEnumerable<TSource> source, Func<TSource, TKey>
     keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
  at Dictionary<TKey, TElement> ToDictionary<TSource,TKey,TElement>(IEnumerable<TSource> source, Func<TSource, TKey>
     keySelector, Func<TSource, TElement> elementSelector)
  at ctor(string filename, string contents, string elementName, string[] packageAttributeNames, string versionAttributeName)
     in XmlProjectFile.cs:24
  at ctor(string filename, string contents) in CsProjFile.cs:5
  at async Task<IProjectFile> ReadFile(IFileSystemInfo fileInfo) in ProjectFileManager.cs:64
  at async Task<IReadOnlyCollection<IProjectFile>> FindProjectsInDir(IDirectoryInfo dir, SearchOption searchMode) in
     ProjectFileManager.cs:44
  at async Task<IReadOnlyCollection<IProjectFile>> GetProjectsInDir(string dirPath, bool recursive) in ProjectFileManager.cs
     :38
  at async Task<IReadOnlyCollection<IProjectFile>> GetProjects(string path, bool recursive) in ProjectFileManager.cs:27
  at async Task<IReadOnlyCollection<IProjectFile>> GetAllProjects(IReadOnlyCollection<string> paths, bool recursive) in
     ProjectFileManager.cs:19
  at async Task<int> Run(Settings settings) in App.cs:22
  at void MoveNext() in Command.cs:28
  at void MoveNext() in Status.cs:120
  at void MoveNext() in Progress.cs:138
  at async Task<T> RunAsync<T>(Func<Task<T>> func) in DefaultExclusivityMode.cs:40
  at async Task<T> StartAsync<T>(Func<ProgressContext, Task<T>> action) in Progress.cs:121
  at async Task<T> StartAsync<T>(string status, Func<StatusContext, Task<T>> func) in Status.cs:117
  at async Task<int> ExecuteAsync(CommandContext context, Settings settings) in Command.cs:18
@SteveDesmond-ca
Copy link
Member

Hi @viblo-majority, do any of your projects that reference XXX.Platform.MessageBus target multiple frameworks?

If so, this is likely a duplicate of #182.

@viblo-majority
Copy link
Author

I did some more troubleshooting today and found the issue: libyear cant handle when a package reference is both included and updated like this (in csproj):

  <ItemGroup>
    <PackageReference Include="XXX.Platform.MessageBus" Version="24.319.1" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Update="XXX.Platform.MessageBus" Version="24.319.1" />
  </ItemGroup>

As you can see this was actually an unnecessary update since nothing changed, but think libyear should handle it anyway.

@SteveDesmond-ca
Copy link
Member

Yep, agreed, #182 will handle both the crash and a more fully-fleshed subsequent solution

@SteveDesmond-ca SteveDesmond-ca closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants