Skip to content

Add --OutputFileNamesWithoutVersion option to dotnet pack #53780

@apurvghai

Description

@apurvghai

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

NuGet's nuget.exe pack command supports the -OutputFileNamesWithoutVersion switch, which strips the version from the
output .nupkg filename (e.g., MyPackage.nupkg instead of MyPackage.1.0.0.nupkg). However, the dotnet pack CLI does not
expose this option. Users who need versionless output filenames — for example, in CI/CD pipelines where a stable
artifact path is needed — must resort to workarounds like passing raw MSBuild properties (
-p:OutputFileNamesWithoutVersion=true) for project-based packing, and have no option at all for nuspec-based packing.

Describe the solution you'd like

Add a --OutputFileNamesWithoutVersion boolean flag to the dotnet pack CLI command, consistent with NuGet's existing
switch name. It should work for both code paths:

  • MSBuild-based packing (project files): Forward the flag as the MSBuild property
    -property:OutputFileNamesWithoutVersion=true, which NuGet's Pack.targets already consumes.
  • NuSpec-based packing (.nuspec files): Set PackArgs.OutputFileNamesWithoutVersion so that PackCommandRunner omits
    the version from the output filename.

Additional context

  • NuGet already defines and uses OutputFileNamesWithoutVersion in both PackArgs.cs and
    PackCommandRunner.GetOutputFileName(), so no NuGet-side changes are needed.
  • The MSBuild property $(OutputFileNamesWithoutVersion) is already wired in NuGet.Build.Tasks.Pack.targets — the
    dotnet pack CLI just needs to surface it as a first-class option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions