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

Fix msbuild parser allowing missing versions #1559

Merged
merged 1 commit into from
Dec 20, 2024
Merged

Fix msbuild parser allowing missing versions #1559

merged 1 commit into from
Dec 20, 2024

Conversation

maxrake
Copy link
Contributor

@maxrake maxrake commented Dec 20, 2024

This change updates the msbuild lockfile parser so that it will not allow for missing names and or versions. Before this change, a *.csproj file parsed as a lockfile (e.g., with type of msbuild) would show entries with missing name or version as an empty string. This causes analysis failures when submitting to the API since a valid package descriptor requires a non-empty version field.

Dependency management in NuGet's "Central Package Management" (CPM) allows for *.csproj files containing PackageReference elements without a Version attribute. Those versions will be included, along with the fully transitive set, in the packages.lock.json lockfile generated by NuGet. When both files are present in the same directory, the changes in this patch will correctly parse both. For more about CPM, see this reference:

https://devblogs.microsoft.com/nuget/introducing-central-package-management/

The sample.csproj test fixture was updated to include an entry with neither a name or version and another entry with a name but no version.

This change updates the `msbuild` lockfile parser so that it will not
allow for missing names and or versions. Before this change, a
`*.csproj` file parsed as a lockfile (e.g., with type of `msbuild`)
would show entries with missing name or version as an empty string. This
causes analysis failures when submitting to the API since a valid
package descriptor requires a non-empty `version` field.

Dependency management in NuGet's "Central Package Management" (CPM)
allows for `*.csproj` files containing `PackageReference` elements
without a `Version` attribute. Those versions will be included, along
with the fully transitive set, in the `packages.lock.json` lockfile
generated by NuGet. When both files are present in the same directory,
the changes in this patch will correctly parse both. For more about CPM,
see this reference:

https://devblogs.microsoft.com/nuget/introducing-central-package-management/

The `sample.csproj` test fixture was updated to include an entry with
neither a name or version and another entry with a name but no version.
@maxrake maxrake requested a review from cd-work December 20, 2024 20:06
@maxrake maxrake self-assigned this Dec 20, 2024
@maxrake maxrake requested a review from a team as a code owner December 20, 2024 20:06
@maxrake maxrake merged commit d0323dd into main Dec 20, 2024
17 checks passed
@maxrake maxrake deleted the cpm_fix branch December 20, 2024 20:22
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

Successfully merging this pull request may close these issues.

2 participants