Add --OutputFileNamesWithoutVersion option to dotnet pack#53781
Add --OutputFileNamesWithoutVersion option to dotnet pack#53781apurvghai wants to merge 1 commit intodotnet:mainfrom
Conversation
|
@dotnet-policy-service agree company="Microsoft" |
There was a problem hiding this comment.
Pull request overview
Exposes NuGet’s “versionless output filename” behavior as a first-class dotnet pack option, supporting both MSBuild-based packing (project files) and the .nuspec pack path.
Changes:
- Added a new
dotnet packflag that forwardsOutputFileNamesWithoutVersion=trueto MSBuild and populatesPackArgs.OutputFileNamesWithoutVersionfor.nuspecpacking. - Added localized help text for the new option.
- Added tests covering both MSBuild and
.nuspecpacking scenarios.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/dotnet.Tests/CommandTests/Pack/PackTests.cs | Adds tests verifying versionless .nupkg naming for both MSBuild and .nuspec pack paths. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/Commands/Pack/PackCommandDefinition.cs | Adds the new CLI option and forwards it as an MSBuild property. |
| src/Cli/dotnet/Commands/Pack/PackCommand.cs | Wires the option into PackArgs for the .nuspec pack code path. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/CommandDefinitionStrings.resx | Adds the option description string. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.cs.xlf | Adds localization entry for the new option description. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.de.xlf | Adds localization entry for the new option description. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.es.xlf | Adds localization entry for the new option description. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.fr.xlf | Adds localization entry for the new option description. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.it.xlf | Adds localization entry for the new option description. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.ja.xlf | Adds localization entry for the new option description. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.ko.xlf | Adds localization entry for the new option description. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.pl.xlf | Adds localization entry for the new option description. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.pt-BR.xlf | Adds localization entry for the new option description. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.ru.xlf | Adds localization entry for the new option description. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.tr.xlf | Adds localization entry for the new option description. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.zh-Hans.xlf | Adds localization entry for the new option description. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.zh-Hant.xlf | Adds localization entry for the new option description. |
| public readonly Option<bool> OutputFileNamesWithoutVersionOption = new Option<bool>("--OutputFileNamesWithoutVersion") | ||
| { | ||
| Description = CommandDefinitionStrings.PackCmdOutputFileNamesWithoutVersionDescription, | ||
| Arity = ArgumentArity.Zero | ||
| }.ForwardAs("-property:OutputFileNamesWithoutVersion=true"); |
There was a problem hiding this comment.
The new option name uses PascalCase (--OutputFileNamesWithoutVersion), which is inconsistent with the established dotnet pack/CLI long-option naming in this command (e.g., --no-build, --include-symbols, --output). Consider switching to a kebab-case long option (e.g., --output-file-names-without-version) and optionally keeping the PascalCase form as an alias if you need to mirror NuGet’s switch name.
|
We likely won't take this as-is - option names that are multiple words should use Unix-style kebab-casing for their names, like |
|
I agree with @baronfel overall. There's also the aspect of, I don't necessarily think this is a best practice or even a good to be frank, so I don't want to perpetuate the usage of this option and instead have customers move to a versioned nupkg. |
|
Yes, @baronfel and I discussed. In general, I think the comment makes perfect sense. However, there are scenarios, where the new file names are a problem. The fact NuGet pack supported those, the change was trying to support backward compatibility. |
Description:
This PR exposes the --OutputFileNamesWithoutVersion option in the dotnet pack CLI, matching the existing NuGet
-OutputFileNamesWithoutVersion switch.
What it does
When specified, the output .nupkg filename omits the version — e.g., MyPackage.nupkg instead of MyPackage.1.0.0.nupkg.
How it works
Pack.targets already consumes.
PackCommandRunner.GetOutputFileName(excludeVersion: true).
Changes
For more details, see #53780