NuKeeperDotNet / NuKeeper

Automagically update nuget packages in .NET projects
Apache License 2.0
540 stars 129 forks source link

Weird csproj results in ArgumentNullException #1142

Closed tiesmaster closed 2 years ago

tiesmaster commented 2 years ago

🐛 Bug Report

Running $ nukeeper inspect on this project file results in an ArgumentNullException (see below for the full trace). I've tracked that down to this ItemGroup (both ProjectReference elements need to be removed to get the command to execute without throwing), and they came with the template I used to generate the solution structure (the source of this template can be found in the dotnet/roslyn-sdk repo, and I believe it this file).

I don't fully understand the purpose of those items in the project file, and the 2nd link is dead, so I'm a bit reluctant to remove that from the project file, and I'd expect that this is a bug in NuKeeper parsing the project file. If it's not, then I'm fine with closing the issue, and find a different way on how to solve this. Alternatively, I was hoping for an option to ignore a given project (either on the commandline, or in the configuration option), but couldn't find any support for that.

  <ItemGroup>
    <!-- https://github.com/dotnet/sdk/issues/433 -->
    <ProjectReference Update="@(ProjectReference)" AdditionalProperties="TargetFramework=netstandard2.0" />

    <!-- https://github.com/Microsoft/extendvs/issues/57 -->
    <ProjectReference Update="@(ProjectReference)" Name="%(Filename)" />
  </ItemGroup>
Full trace of the `ArgumentNullException` ````xml System.ArgumentNullException: Value cannot be null. (Parameter 'path2') at System.IO.Path.Combine(String path1, String path2) at NuKeeper.Inspection.RepositoryInspection.ProjectFileReader.MakeProjectPath(XElement el, String currentPath) in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper.Inspection\RepositoryInspection\ProjectFileReader.cs:line 98 at NuKeeper.Inspection.RepositoryInspection.ProjectFileReader.<>c__DisplayClass6_0.b__1(XElement el) in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper.Inspection\RepositoryInspection\ProjectFileReader.cs:line 66 at System.Linq.Enumerable.SelectEnumerableIterator`2.ToList() at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at NuKeeper.Inspection.RepositoryInspection.ProjectFileReader.Read(Stream fileContents, String baseDirectory, String relativePath) in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper.Inspection\RepositoryInspection\ProjectFileReader.cs:line 64 at NuKeeper.Inspection.RepositoryInspection.ProjectFileReader.ReadFile(String baseDirectory, String relativePath) in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper.Inspection\RepositoryInspection\ProjectFileReader.cs:line 30 at NuKeeper.Inspection.RepositoryInspection.RepositoryScanner.<>c__DisplayClass4_0.b__1(FileInfo f) in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper.Inspection\RepositoryInspection\RepositoryScanner.cs:line 49 at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext() at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection) at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection) at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.ToList() at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at NuKeeper.Inspection.RepositoryInspection.RepositoryScanner.FindAllNuGetPackages(IFolder workingFolder) in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper.Inspection\RepositoryInspection\RepositoryScanner.cs:line 33 at NuKeeper.Inspection.UpdateFinder.FindPackages(IFolder workingFolder) in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper.Inspection\UpdateFinder.cs:line 95 at NuKeeper.Inspection.UpdateFinder.FindPackageUpdateSets(IFolder workingFolder, NuGetSources sources, VersionChange allowedChange, UsePrerelease usePrerelease, Regex includes, Regex excludes) in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper.Inspection\UpdateFinder.cs:line 50 at NuKeeper.Local.LocalEngine.GetSortedUpdates(IFolder folder, NuGetSources sources, VersionChange allowedChange, UsePrerelease usePrerelease, Regex includes, Regex excludes) in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper\Local\LocalEngine.cs:line 87 at NuKeeper.Local.LocalEngine.Run(SettingsContainer settings, Boolean write) in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper\Local\LocalEngine.cs:line 63 at NuKeeper.Commands.InspectCommand.Run(SettingsContainer settings) in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper\Commands\InspectCommand.cs:line 33 at NuKeeper.Commands.CommandBase.OnExecute() in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper\Commands\CommandBase.cs:line 108 at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.InvokeAsync(MethodInfo method, Object instance, Object[] arguments) at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context, CancellationToken cancellationToken) at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<b__0>d.MoveNext() --- End of stack trace from previous location --- at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken) at NuKeeper.Program.Main(String[] args) in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper\Program.cs:line 35 ````

Expected behavior

Reproduction steps

  1. Clone Vinyl: $ git clone https://github.com/tiesmaster/vinyl.git
  2. $ cd vinyl
  3. $ git checkout d918cc4
  4. $ nukeeper inspect

Alternatively:

  1. Do File > New Project in Visual Studio
  2. Select the project "Analyzer with Code Fix (.NET Standard)"
    • NOTE: this is not included in the default installation of Visual Studio: this requires the "Visual Studio extension development" workload, and the optional ".NET Compiler Platform SDK" option to be selected
  3. Run nukeeper inspect on the generated solution

Configuration

Version: 0.35.0

Platform if applicable:

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

tiesmaster commented 2 years ago

Seeing the future of NuKeeper (#1155), I understand that this project is not being maintained anymore, and I can probably switch over to dotnet-outdated or renovate.