Skip to content

Commit

Permalink
Handle case where package directory cannot be determined (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfederm authored Oct 1, 2024
1 parent ca7ecac commit 16c84c6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Tasks/CollectDeclaredReferencesTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,15 @@ private Dictionary<string, PackageInfo> GetPackageInfos()
}

string nugetLibraryRelativePath = lockFile.GetLibrary(nugetLibrary.Name, nugetLibrary.Version).Path;
string nugetLibraryAbsolutePath = packageFolders
string? nugetLibraryAbsolutePath = packageFolders
.Select(packageFolder => Path.Combine(packageFolder, nugetLibraryRelativePath))
.First(Directory.Exists);
.FirstOrDefault(Directory.Exists);
if (nugetLibraryAbsolutePath is null)
{
// This can happen if the project has a stale lock file.
// Just ignore it as NuGet itself will likely error.
continue;
}

List<string> nugetLibraryAssemblies = nugetLibrary.CompileTimeAssemblies
.Select(item => item.Path)
Expand Down

0 comments on commit 16c84c6

Please sign in to comment.