Open
Description
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