Skip to content

Add dotnet pack --no-default-excludes - #55669

Open
cedrikewers wants to merge 1 commit into
dotnet:mainfrom
cedrikewers:CedrikE/DotnetPackNoDefaultExclude
Open

Add dotnet pack --no-default-excludes#55669
cedrikewers wants to merge 1 commit into
dotnet:mainfrom
cedrikewers:CedrikE/DotnetPackNoDefaultExclude

Conversation

@cedrikewers

Copy link
Copy Markdown

Packing a .nuspec directly (dotnet pack MyPackage.nuspec) bypasses MSBuild and constructs PackArgs by hand in PackCommand.RunPackCommand. NoDefaultExcludes was never set there and no CLI option existed to set it, so files and folders starting with a dot and files ending in .nupkg were always dropped with NU5119 with no way to opt out. Passing -p:NoDefaultExcludes=true has no effect either, because on this path --property values feed nuspec token replacement rather than pack settings.

Add a --no-default-excludes option. It is forwarded as -property:NoDefaultExcludes=true so the project-based path continues to flow through NuGet.Build.Tasks.Pack.targets to PackTask, and it is read into PackArgs.NoDefaultExcludes for the nuspec path, so one flag covers both entry points.

Also propagate --serviceable and --version-suffix into PackArgs, which were silently dropped on the nuspec path for the same reason.

Fixes #55252
Related: NuGet/Home#15023

Packing a .nuspec directly (`dotnet pack MyPackage.nuspec`) bypasses MSBuild
and constructs PackArgs by hand in PackCommand.RunPackCommand. NoDefaultExcludes
was never set there and no CLI option existed to set it, so files and folders
starting with a dot and files ending in .nupkg were always dropped with NU5119
with no way to opt out. Passing -p:NoDefaultExcludes=true has no effect either,
because on this path --property values feed nuspec token replacement rather
than pack settings.

Add a --no-default-excludes option. It is forwarded as
-property:NoDefaultExcludes=true so the project-based path continues to flow
through NuGet.Build.Tasks.Pack.targets to PackTask, and it is read into
PackArgs.NoDefaultExcludes for the nuspec path, so one flag covers both entry
points.

Also propagate --serviceable and --version-suffix into PackArgs, which were
silently dropped on the nuspec path for the same reason.

Fixes dotnet#55252
Related: NuGet/Home#15023
@cedrikewers
cedrikewers requested review from a team as code owners August 7, 2026 09:06
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@cedrikewers

Copy link
Copy Markdown
Author

@dotnet-policy-service agree company="Beckhoff Automation GmbH & Co. KG"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dotnet pack <nuspec> provides no way to disable default excludes (no NoDefaultExcludes equivalent)

1 participant