dotnet / dotnet/sdk

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

Open
#49,779 8 comments 5 reactions 1 assignee Claimed by @jjonescz View on GitHub
Area-run-file
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### 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:

```csharp
#:package Humanizer@2.*
```

or

```csharp
#:package Humanizer@*
```

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

```csharp
#: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:

```csharp
#: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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.