Skip to content

Support latest package version by default when no version is specified in #:package directive #49779

@jomaxso

Description

@jomaxso

Is your feature request related to a problem? Please describe.

Currently, when adding a NuGet package via the #:package directive in a file-based run, the version must be explicitly specified. For example:

#:package Humanizer@2.*

or

#:package Humanizer@*

These work fine, but if the version is omitted like this:

#:package Humanizer

…it results in an error. This makes the initial user experience more complex, especially for beginners who are unfamiliar with versioning or just want to try out a package quickly.

Describe the solution you'd like

It would be great if omitting the version in the #:package directive would default to the latest stable version available on NuGet. For example:

#:package Humanizer

should internally resolve and use the latest version of the Humanizer package, just as if @* had been specified.

This change would:

  • Make scripts easier to write and read.
  • Lower the barrier to entry for newcomers.
  • Align with common expectations from other package managers and tools.

Additional context

This feature would provide a smoother onboarding experience and allow for quicker experimentation. Explicit versioning can still be used when needed, but shouldn't be required by default for simple scenarios.

Metadata

Metadata

Assignees

Labels

Area-run-fileItems related to the "dotnet run <file>" effort
No fields configured for Feature.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions