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

improve packages directory detection #10912

Merged
merged 2 commits into from
Nov 11, 2024
Merged

Conversation

brettfo
Copy link
Contributor

@brettfo brettfo commented Nov 8, 2024

This came from a bug found in the wild where we didn't detect the packages directory from a .csproj and went with the default of "../packages". That's not an unreasonable default, but there was one more check we could do to try and find a reasonable solution; check other <HintPath> values and see if any of those specify "packages" anywhere and use that.

@brettfo brettfo requested a review from a team as a code owner November 8, 2024 00:02
@github-actions github-actions bot added the L: dotnet:nuget NuGet packages via nuget or dotnet label Nov 8, 2024
@brettfo brettfo force-pushed the dev/brettfo/nuget-hint-path branch from 2620658 to 31d0776 Compare November 8, 2024 16:49
{
var hintPath = hintPathNode.GetContentValue();
var match = Regex.Match(hintPath, @"^(?<PackagesPath>.*)[/\\](?<PackageNameAndVersion>[^/\\]+)[/\\]lib[/\\](?<Tfm>[^/\\]+)[/\\](?<AssemblyName>[^/\\]+)$");
// e.g., ..\..\packages \ Some.Package.1.2.3 \ lib\ net45 \ Some.Package.dll
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improved regex and comment describing what it does. It's harder to read, but much more accurate.

@sachin-sandhu sachin-sandhu merged commit 313fcff into main Nov 11, 2024
90 checks passed
@sachin-sandhu sachin-sandhu deleted the dev/brettfo/nuget-hint-path branch November 11, 2024 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: dotnet:nuget NuGet packages via nuget or dotnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants