Skip to content

nuget pack includes files and directories beginning with dot (.), despite default excludes #10588

Open

Description

@jzebedee

This issue was closed as fixed in #8798 but is still occurring as of nuget.exe 5.9.0-preview.2 and 5.8.1.

Details about Problem

NuGet product used (NuGet.exe | Visual Studio | MSBuild.exe | dotnet.exe): nuget.exe

Product version: 5.9.0-preview.2 and 5.8.1

Worked before? If so, with which NuGet version: no

Repro steps and/or sample project

Repro: repro.zip

Running nuget pack with both the latest stable and latest preview version will produce WARNING: NU5119 but add dot-prefixed entries anyway.

5.9.0-preview.2 also produces an exception of The given key was not present in the dictionary.

Verbose Logs

With nuget.exe 5.9.0-preview.2

> nuget pack LibDeflate.Native.nuspec -Verbosity detailed
NuGet Version: 5.9.0.6967
Attempting to build package from 'LibDeflate.Native.nuspec'.
WARNING: NU5119: File 'C:\Dropbox\Data\LocalRepos\LibDeflate.Native\.gitattributes' was not added to the package. Files and folders starting with '.' or ending with '.nupkg' are excluded by default. To include this file, use -NoDefaultExcludes from the commandline
WARNING: NU5119: File 'C:\Dropbox\Data\LocalRepos\LibDeflate.Native\.gitignore' was not added to the package. Files and folders starting with '.' or ending with '.nupkg' are excluded by default. To include this file, use -NoDefaultExcludes from the commandline
WARNING: NU5119: File 'C:\Dropbox\Data\LocalRepos\LibDeflate.Native\LibDeflate.Native.1.7.0.nupkg' was not added to the package. Files and folders starting with '.' or ending with '.nupkg' are excluded by default. To include this file, use -NoDefaultExcludes from the commandline
WARNING: NU5119: File 'C:\Dropbox\Data\LocalRepos\LibDeflate.Native\.dummy\LibDeflate.Native.1.7.0 - Copy.nupkg' was not added to the package. Files and folders starting with '.' or ending with '.nupkg' are excluded by default. To include this file, use -NoDefaultExcludes from the commandline
WARNING: NU5119: File 'C:\Dropbox\Data\LocalRepos\LibDeflate.Native\.vs\LibDeflate.Native\v16\.suo' was not added to the package. Files and folders starting with '.' or ending with '.nupkg' are excluded by default. To include this file, use -NoDefaultExcludes from the commandline

Id: LibDeflate.Native
Version: 1.7.0
Authors: jzebedee
Description: LibDeflate.NET dependency containing all supported native binaries of libdeflate
Project Url: https://github.com/jzebedee/LibDeflate.Native
Tags: native, libdeflate, libdeflate.net, deflate, zlib, gzip, gz
Dependencies: None

Added file '.build/download_all.sh'.
Added file '.build/setup.sh'.
Added file '.build/verify.sh'.
Added file '.git/COMMIT_EDITMSG'.
Added file '.git/config'.
Added file '.git/description'.
Added file '.git/HEAD'.
Added file '.git/hooks/applypatch-msg.sample'.
Added file '.git/hooks/commit-msg.sample'.
Added file '.git/hooks/fsmonitor-watchman.sample'.
Added file '.git/hooks/post-update.sample'.
Added file '.git/hooks/pre-applypatch.sample'.
Added file '.git/hooks/pre-commit.sample'.
Added file '.git/hooks/pre-merge-commit.sample'.
Added file '.git/hooks/prepare-commit-msg.sample'.
Added file '.git/hooks/pre-push.sample'.
Added file '.git/hooks/pre-rebase.sample'.
Added file '.git/hooks/pre-receive.sample'.
Added file '.git/hooks/push-to-checkout.sample'.
Added file '.git/hooks/update.sample'.
Added file '.git/index'.
Added file '.git/info/exclude'.
Added file '.git/logs/HEAD'.
Added file '.git/logs/refs/heads/main'.
Added file '.git/logs/refs/remotes/origin/main'.
Added file '.git/ms-persist.xml'.
Added file '.git/objects/1b/aefd83cf40b5d725a3177885e944bd80e44f76'.
Added file '.git/objects/1f/f0c423042b46cb1d617b81efb715defbe8054d'.
Added file '.git/objects/21/26112033916b006b99e2f9bf74ac48f627f9e7'.
Added file '.git/objects/28/51af88d40f13ff70a1b12f6eaaac7205aca778'.
Added file '.git/objects/2b/5c46ba8ce33ae9bb44d6abfc90917b11afaf07'.
Added file '.git/objects/2c/409433e24a5b869971b6e091b4eea811558101'.
Added file '.git/objects/2f/3191ffdb947372f8431e5da7dcca7b76236b42'.
Added file '.git/objects/34/6d3e2f2ac5ab324e7c7811fc36f5280f4b8ecf'.
Added file '.git/objects/37/055389225fed5d798e8afcd0164d8d312e7c30'.
Added file '.git/objects/41/bd5c2341f856d58531e22c22685d3f893d3d4c'.
Added file '.git/objects/55/0f45af7b32b3a70b22038f58992a6cb742c6a9'.
Added file '.git/objects/5a/71f8f7cc188e67092ae5e22471758ac761b6c2'.
Added file '.git/objects/5c/8849e26b5f28b90c75e79f22a79b7591f04dba'.
Added file '.git/objects/6b/f61989c58fcc5a35d8524330b2c9cd52109b41'.
Added file '.git/objects/70/bc608075370910267fa4f1aa808c6e4bab20b5'.
Added file '.git/objects/7b/e9418acca88304e6219090b903f5478559da67'.
Added file '.git/objects/82/06ad429b483cbb6bc4dc65f4c1812eddb0a4be'.
Added file '.git/objects/8b/8e553974b3b4108517814ba8045d8c22420ded'.
Added file '.git/objects/93/af649f8b56759235066c65aa6abf24fef1b0e8'.
Added file '.git/objects/94/91a2fda28342ab358eaf234e1afe0c07a53d62'.
Added file '.git/objects/99/f5b4d181d4f83324e601db32c8223fdd170dd8'.
Added file '.git/objects/9d/35f39189ca20267bec8f72a9431935ebd9d08c'.
Added file '.git/objects/a4/0b318bf00eaca503859282f03fc910f574c033'.
Added file '.git/objects/a5/adbbdd626f6b168b49537190cab0f75c34483c'.
Added file '.git/objects/a9/956f4daf142b02b95f92e57810456eb12334a5'.
Added file '.git/objects/b9/8ec252af2fd1697e7e1209a824afad8342de6c'.
Added file '.git/objects/ba/c59bec4abab2e429ee44e49142de71848416ca'.
Added file '.git/objects/bb/cbff158f635be64560a37ff890810acb7d80f2'.
Added file '.git/objects/be/d2eebff9f98f22f98c4a5dfa1fc19377f423fa'.
Added file '.git/objects/cb/08322b7eced4ef31bfce9e5e7f07683d85116a'.
Added file '.git/objects/cd/254e2a7c8504d6f68156b12c016c36292f5b72'.
Added file '.git/objects/ce/6347d025f711cbc80ecc3de3a4b7ac18ff56b0'.
Added file '.git/objects/da/387b8134910b5ec7004ccb39318fae8d2a55a3'.
Added file '.git/objects/dc/ca2899f02dad557288a06210fdfa8f0d787d69'.
Added file '.git/objects/e0/bd5507095b58e4d9acb517ceab7b7a58be334f'.
Added file '.git/objects/ec/8cc47118081f16f1fb7b36ee8632a978a62a19'.
Added file '.git/objects/f0/d3a70ceaa69fb70811f58254dc738e0f939eac'.
Added file '.git/objects/f8/925381a3e3a97d39ccfdc38729612757f78e29'.
Added file '.git/objects/f9/f3f7af80756a4bfcab17e3511c7a08d94b9302'.
Added file '.git/objects/fa/64fccf33c75768b11190b7f102f3106c4a2372'.
Added file '.git/objects/fa/f304a72413897d0e33437c25118712c5c3d7ef'.
Added file '.git/objects/fb/5d1f4e7bc6c93c14a50a5cfcb3d64f506fdc79'.
Added file '.git/objects/ff/4ff3c20db6b5a08d9d6b1fa4fb312bf922a5b1'.
Added file '.git/refs/heads/main'.
Added file '.git/refs/remotes/origin/main'.
Added file '.vs/slnx.sqlite'.
Added file '.vs/VSWorkspaceState.json'.
Added file '[Content_Types].xml'.
Added file '_rels/.rels'.
Added file 'LibDeflate.Native.nuspec'.
Added file 'package/services/metadata/core-properties/78be4f3e35ac4e258e2838e563a7466b.psmdcp'.
Added file 'runtimes/linux-x64/native/libdeflate.so'.
Added file 'runtimes/osx.10.13-x64/native/libdeflate.dylib'.
Added file 'runtimes/osx.10.14-x64/native/libdeflate.dylib'.
Added file 'runtimes/osx.10.15-x64/native/libdeflate.dylib'.
Added file 'runtimes/osx.11.0-arm64/native/libdeflate.dylib'.
Added file 'runtimes/osx.11.0-x64/native/libdeflate.dylib'.
Added file 'runtimes/win-x32/native/libdeflate.dll'.
Added file 'runtimes/win-x64/native/libdeflate.dll'.

The given key was not present in the dictionary.
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at NuGet.Packaging.Rules.InvalidUndottedFrameworkRule.ValidateFiles(IEnumerable`1 files)
   at NuGet.Packaging.Rules.InvalidUndottedFrameworkRule.Validate(XDocument xml, IEnumerable`1 files)
   at NuGet.Commands.PackCommandRunner.AnalyzePackage(PackageArchiveReader package)
   at NuGet.Commands.PackCommandRunner.BuildPackage(PackageBuilder builder, String outputPath, Boolean symbolsPackage)
   at NuGet.Commands.PackCommandRunner.BuildFromNuspec(String path)
   at NuGet.CommandLine.PackCommand.ExecuteCommand()
   at NuGet.CommandLine.Command.ExecuteCommandAsync()
   at NuGet.CommandLine.Command.Execute()
   at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)

With nuget.exe 5.8.1

> nuget pack LibDeflate.Native.nuspec -Verbosity detailed
NuGet Version: 5.8.1.7021
Attempting to build package from 'LibDeflate.Native.nuspec'.
WARNING: NU5119: File 'C:\Dropbox\Data\LocalRepos\LibDeflate.Native\.gitattributes' was not added to the package. Files and folders starting with '.' or ending with '.nupkg' are excluded by default. To include this file, use -NoDefaultExcludes from the commandline
WARNING: NU5119: File 'C:\Dropbox\Data\LocalRepos\LibDeflate.Native\.gitignore' was not added to the package. Files and folders starting with '.' or ending with '.nupkg' are excluded by default. To include this file, use -NoDefaultExcludes from the commandline
WARNING: NU5119: File 'C:\Dropbox\Data\LocalRepos\LibDeflate.Native\LibDeflate.Native.1.7.0.nupkg' was not added to the package. Files and folders starting with '.' or ending with '.nupkg' are excluded by default. To include this file, use -NoDefaultExcludes from the commandline
WARNING: NU5119: File 'C:\Dropbox\Data\LocalRepos\LibDeflate.Native\.dummy\LibDeflate.Native.1.7.0 - Copy.nupkg' was not added to the package. Files and folders starting with '.' or ending with '.nupkg' are excluded by default. To include this file, use -NoDefaultExcludes from the commandline
WARNING: NU5119: File 'C:\Dropbox\Data\LocalRepos\LibDeflate.Native\.vs\LibDeflate.Native\v16\.suo' was not added to the package. Files and folders starting with '.' or ending with '.nupkg' are excluded by default. To include this file, use -NoDefaultExcludes from the commandline

Id: LibDeflate.Native
Version: 1.7.0
Authors: jzebedee
Description: LibDeflate.NET dependency containing all supported native binaries of libdeflate
Project Url: https://github.com/jzebedee/LibDeflate.Native
Tags: native, libdeflate, libdeflate.net, deflate, zlib, gzip, gz
Dependencies: None

Added file '.build/download_all.sh'.
Added file '.build/setup.sh'.
Added file '.build/verify.sh'.
Added file '.git/COMMIT_EDITMSG'.
Added file '.git/config'.
Added file '.git/description'.
Added file '.git/HEAD'.
Added file '.git/hooks/applypatch-msg.sample'.
Added file '.git/hooks/commit-msg.sample'.
Added file '.git/hooks/fsmonitor-watchman.sample'.
Added file '.git/hooks/post-update.sample'.
Added file '.git/hooks/pre-applypatch.sample'.
Added file '.git/hooks/pre-commit.sample'.
Added file '.git/hooks/pre-merge-commit.sample'.
Added file '.git/hooks/prepare-commit-msg.sample'.
Added file '.git/hooks/pre-push.sample'.
Added file '.git/hooks/pre-rebase.sample'.
Added file '.git/hooks/pre-receive.sample'.
Added file '.git/hooks/push-to-checkout.sample'.
Added file '.git/hooks/update.sample'.
Added file '.git/index'.
Added file '.git/info/exclude'.
Added file '.git/logs/HEAD'.
Added file '.git/logs/refs/heads/main'.
Added file '.git/logs/refs/remotes/origin/main'.
Added file '.git/ms-persist.xml'.
Added file '.git/objects/1b/aefd83cf40b5d725a3177885e944bd80e44f76'.
Added file '.git/objects/1f/f0c423042b46cb1d617b81efb715defbe8054d'.
Added file '.git/objects/21/26112033916b006b99e2f9bf74ac48f627f9e7'.
Added file '.git/objects/28/51af88d40f13ff70a1b12f6eaaac7205aca778'.
Added file '.git/objects/2b/5c46ba8ce33ae9bb44d6abfc90917b11afaf07'.
Added file '.git/objects/2c/409433e24a5b869971b6e091b4eea811558101'.
Added file '.git/objects/2f/3191ffdb947372f8431e5da7dcca7b76236b42'.
Added file '.git/objects/34/6d3e2f2ac5ab324e7c7811fc36f5280f4b8ecf'.
Added file '.git/objects/37/055389225fed5d798e8afcd0164d8d312e7c30'.
Added file '.git/objects/41/bd5c2341f856d58531e22c22685d3f893d3d4c'.
Added file '.git/objects/55/0f45af7b32b3a70b22038f58992a6cb742c6a9'.
Added file '.git/objects/5a/71f8f7cc188e67092ae5e22471758ac761b6c2'.
Added file '.git/objects/5c/8849e26b5f28b90c75e79f22a79b7591f04dba'.
Added file '.git/objects/6b/f61989c58fcc5a35d8524330b2c9cd52109b41'.
Added file '.git/objects/70/bc608075370910267fa4f1aa808c6e4bab20b5'.
Added file '.git/objects/7b/e9418acca88304e6219090b903f5478559da67'.
Added file '.git/objects/82/06ad429b483cbb6bc4dc65f4c1812eddb0a4be'.
Added file '.git/objects/8b/8e553974b3b4108517814ba8045d8c22420ded'.
Added file '.git/objects/93/af649f8b56759235066c65aa6abf24fef1b0e8'.
Added file '.git/objects/94/91a2fda28342ab358eaf234e1afe0c07a53d62'.
Added file '.git/objects/99/f5b4d181d4f83324e601db32c8223fdd170dd8'.
Added file '.git/objects/9d/35f39189ca20267bec8f72a9431935ebd9d08c'.
Added file '.git/objects/a4/0b318bf00eaca503859282f03fc910f574c033'.
Added file '.git/objects/a5/adbbdd626f6b168b49537190cab0f75c34483c'.
Added file '.git/objects/a9/956f4daf142b02b95f92e57810456eb12334a5'.
Added file '.git/objects/b9/8ec252af2fd1697e7e1209a824afad8342de6c'.
Added file '.git/objects/ba/c59bec4abab2e429ee44e49142de71848416ca'.
Added file '.git/objects/bb/cbff158f635be64560a37ff890810acb7d80f2'.
Added file '.git/objects/be/d2eebff9f98f22f98c4a5dfa1fc19377f423fa'.
Added file '.git/objects/cb/08322b7eced4ef31bfce9e5e7f07683d85116a'.
Added file '.git/objects/cd/254e2a7c8504d6f68156b12c016c36292f5b72'.
Added file '.git/objects/ce/6347d025f711cbc80ecc3de3a4b7ac18ff56b0'.
Added file '.git/objects/da/387b8134910b5ec7004ccb39318fae8d2a55a3'.
Added file '.git/objects/dc/ca2899f02dad557288a06210fdfa8f0d787d69'.
Added file '.git/objects/e0/bd5507095b58e4d9acb517ceab7b7a58be334f'.
Added file '.git/objects/ec/8cc47118081f16f1fb7b36ee8632a978a62a19'.
Added file '.git/objects/f0/d3a70ceaa69fb70811f58254dc738e0f939eac'.
Added file '.git/objects/f8/925381a3e3a97d39ccfdc38729612757f78e29'.
Added file '.git/objects/f9/f3f7af80756a4bfcab17e3511c7a08d94b9302'.
Added file '.git/objects/fa/64fccf33c75768b11190b7f102f3106c4a2372'.
Added file '.git/objects/fa/f304a72413897d0e33437c25118712c5c3d7ef'.
Added file '.git/objects/fb/5d1f4e7bc6c93c14a50a5cfcb3d64f506fdc79'.
Added file '.git/objects/ff/4ff3c20db6b5a08d9d6b1fa4fb312bf922a5b1'.
Added file '.git/refs/heads/main'.
Added file '.git/refs/remotes/origin/main'.
Added file '.vs/slnx.sqlite'.
Added file '.vs/VSWorkspaceState.json'.
Added file '[Content_Types].xml'.
Added file '_rels/.rels'.
Added file 'LibDeflate.Native.nuspec'.
Added file 'package/services/metadata/core-properties/f9c7484b793442158eb98076bab4f325.psmdcp'.
Added file 'runtimes/linux-x64/native/libdeflate.so'.
Added file 'runtimes/osx.10.13-x64/native/libdeflate.dylib'.
Added file 'runtimes/osx.10.14-x64/native/libdeflate.dylib'.
Added file 'runtimes/osx.10.15-x64/native/libdeflate.dylib'.
Added file 'runtimes/osx.11.0-arm64/native/libdeflate.dylib'.
Added file 'runtimes/osx.11.0-x64/native/libdeflate.dylib'.
Added file 'runtimes/win-x32/native/libdeflate.dll'.
Added file 'runtimes/win-x64/native/libdeflate.dll'.

Successfully created package 'C:\Dropbox\Data\LocalRepos\LibDeflate.Native\LibDeflate.Native.1.7.0.nupkg'.

Activity

  1. donnie-msft commented on Feb 24, 2021

    @donnie-msft
    Contributor
  2. jzebedee commented on Feb 26, 2021

    @jzebedee
    Author

    It looks like dot-prefixed files are correctly excluded, but directories are not:

    I created a new repro to illustrate the behavior.

    repro.zip

    Folder structure:
      .testfolder/
        .nestedprefixedtest
        nestednotprefixedtest
      .prefixedtest
      notprefixedtest
      test.nuspec
    

    Expected output:

    Folder structure:
      notprefixedtest
    

    Actual output:

    Folder structure:
      .testfolder/
        nestednotprefixedtest
      notprefixedtest
    

    Nuget output:

    > nuget pack test.nuspec -Verbosity detailed
    NuGet Version: 5.9.0.6967
    Attempting to build package from 'test.nuspec'.
    WARNING: NU5119: File 'H:\OneDrive\Desktop\dot-prefixed-entries\.prefixedtest' was not added to the package. Files and folders starting with '.' or ending with '.nupkg' are excluded by default. To include this file, use -NoDefaultExcludes from the commandline
    WARNING: NU5119: File 'H:\OneDrive\Desktop\dot-prefixed-entries\.testfolder\.nestedprefixedtest' was not added to the package. Files and folders starting with '.' or ending with '.nupkg' are excluded by default. To include this file, use -NoDefaultExcludes from the commandline
    
    Id: test
    Version: 0.1.0
    Authors: jzebedee
    Description: dummy test spec
    Dependencies: None
    
    Added file '.testfolder/nestednotprefixedtest'.
    Added file '[Content_Types].xml'.
    Added file '_rels/.rels'.
    Added file 'notprefixedtest'.
    Added file 'package/services/metadata/core-properties/4002b80f80be4fdf875dcc875e6156d0.psmdcp'.
    Added file 'test.nuspec'.
    
    Successfully created package 'H:\OneDrive\Desktop\dot-prefixed-entries\test.0.1.0.nupkg'.
    
  3. TomaszWegrzyn commented on Sep 6, 2022

    @TomaszWegrzyn

    I am on 6.2.1.2, still seeing this problem 😞

  4. added
    Priority:3Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog.
    and removed
    Priority:2Issues for the current backlog.
    on Sep 8, 2022
  5. brinko99 commented on Jan 11, 2024

    @brinko99

    nuget 6.8 will add files prefixed with . if there is another . found in the name (e.g. an extension). I would expect it to ignore all files starting with ..

    nuget pack -Verbosity detailed
    ...
    Added file '.dontAddMe.txt'.
    
  6. llin100 commented on Jul 31, 2025

    @llin100

    Still seeing this issue with 6.14.0.116.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Functionality:PackPriority:3Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog.Product:NuGet.exeNuGet.exeType:Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions