Skip to content

Validate package IDs specified via the #:package directive #47991

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

Open
DamianEdwards opened this issue Mar 28, 2025 · 0 comments
Open

Validate package IDs specified via the #:package directive #47991

DamianEdwards opened this issue Mar 28, 2025 · 0 comments
Labels
Area-CLI Area-run-file Items related to the "dotnet run <file>" effort untriaged Request triage from a team member

Comments

@DamianEdwards
Copy link
Member

We should consider improving the validation of the package IDs specified via the #:package directive and report an error rather than passing it through to the underlying build. Confusion on what is the correct syntax can make it difficult to diagnose the errors that occur.

For example, if a package is specified using the / char as the separator between ID and version like #:package System.CommandLine/1.2.3, the error is difficult to understand as Example/1.2.3 is treated as the package ID:

Project "D:\src\GitHub\DamianEdwards\runfile\webapi\webapi.csproj" (Restore target(s)):

D:\src\GitHub\DamianEdwards\runfile\webapi\webapi.csproj : warning NU1604: Project dependency System.CommandLine/1.2.3 does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
D:\src\GitHub\DamianEdwards\runfile\webapi\webapi.csproj : error NU1101: Unable to find package System.CommandLine/1.2.3. No packages exist with this id in source(s): C:\Program Files\dotnet\library-packs, dotnet-tools-internal, dotnet8-rtm-stable, Microsoft Visual Studio Offline Packages, nuget.org
Done building project "webapi.csproj" -- FAILED.

The build failed. Fix the build errors and run again.

Details on valid package IDs can be found at https://learn.microsoft.com/nuget/reference/nuspec#id

@DamianEdwards DamianEdwards added Area-CLI Area-run-file Items related to the "dotnet run <file>" effort labels Mar 28, 2025
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Request triage from a team member label Mar 28, 2025
@marcpopMSFT marcpopMSFT assigned edvilme and unassigned edvilme Apr 7, 2025
@edvilme edvilme added needs team triage Requires a full team discussion and removed untriaged Request triage from a team member labels Apr 7, 2025
@marcpopMSFT marcpopMSFT added untriaged Request triage from a team member and removed needs team triage Requires a full team discussion labels Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CLI Area-run-file Items related to the "dotnet run <file>" effort untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

3 participants