Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,9 @@ To display a value, specify the corresponding command-line option without provid
<data name="PackCmdVersionDescription" xml:space="preserve">
<value>The version of the package to create</value>
</data>
<data name="PackCmdOutputFileNamesWithoutVersionDescription" xml:space="preserve">
<value>Do not include the version in the output file name.</value>
</data>
<data name="PackCmdVersion" xml:space="preserve">
<value>VERSION</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ internal sealed class PackCommandDefinition : Command
Arity = ArgumentArity.Zero
}.ForwardAs("-property:Serviceable=true");

public readonly Option<bool> OutputFileNamesWithoutVersionOption = new Option<bool>("--OutputFileNamesWithoutVersion")
{
Description = CommandDefinitionStrings.PackCmdOutputFileNamesWithoutVersionDescription,
Arity = ArgumentArity.Zero
}.ForwardAs("-property:OutputFileNamesWithoutVersion=true");
Comment on lines +54 to +58
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

public readonly Option<bool> NoLogoOption = CommonOptions.CreateNoLogoOption();

public readonly Option<bool> NoRestoreOption = CommonOptions.CreateNoRestoreOption();
Expand Down Expand Up @@ -102,6 +108,7 @@ public PackCommandDefinition()
Options.Add(IncludeSymbolsOption);
Options.Add(IncludeSourceOption);
Options.Add(ServiceableOption);
Options.Add(OutputFileNamesWithoutVersionOption);
Options.Add(NoLogoOption);
Options.Add(InteractiveOption);
Options.Add(NoRestoreOption);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/Cli/dotnet/Commands/Pack/PackCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public static int RunPackCommand(ParseResult parseResult)
Exclude = new List<string>(),
OutputDirectory = parseResult.GetValue(definition.OutputOption),
LogLevel = MappingVerbosityToNugetLogLevel(parseResult.GetValue(definition.VerbosityOption)),
OutputFileNamesWithoutVersion = parseResult.GetValue(definition.OutputFileNamesWithoutVersionOption),
Arguments = [nuspecPath]
};

Expand Down
40 changes: 40 additions & 0 deletions test/dotnet.Tests/CommandTests/Pack/PackTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,5 +431,45 @@ public void DotnetPack_FailsForNonExistentNuspec()

result.Should().Fail();
}

[Fact]
public void DotnetPack_OutputFileNamesWithoutVersion_MSBuild()
{
var testInstance = TestAssetsManager.CopyTestAsset("TestLibraryWithConfiguration")
.WithSource();

var outputDir = new DirectoryInfo(Path.Combine(testInstance.Path, "bin2"));

new DotnetPackCommand(Log)
.WithWorkingDirectory(testInstance.Path)
.Execute("-o", outputDir.FullName, "--OutputFileNamesWithoutVersion")
.Should().Pass();

outputDir.Should().Exist()
.And.HaveFile("TestLibraryWithConfiguration.nupkg");
}

[Fact]
public void DotnetPack_OutputFileNamesWithoutVersion_Nuspec()
{
var testInstance = TestAssetsManager.CopyTestAsset("TestNuspecProject")
.WithSource();

string nuspecPath = Path.Combine(testInstance.Path, "PackNoCsproj.nuspec");

var result = new DotnetPackCommand(Log)
.WithWorkingDirectory(testInstance.Path)
.Execute(nuspecPath, "--property", "id=PackNoCsproj",
"--property", "authors=CustomAuthor", "--OutputFileNamesWithoutVersion");

result.Should().Pass();

var outputDir = new DirectoryInfo(testInstance.Path);
outputDir.Should().Exist()
.And.HaveFile("PackNoCsproj.nupkg");

var nupkgPath = Path.Combine(testInstance.Path, "PackNoCsproj.nupkg");
File.Exists(nupkgPath).Should().BeTrue("The package should be created without version in the file name.");
}
}
}
Loading