Skip to content

Directories with a dot as the first character of the directory name not included in published container images #40511

Closed

Description

@martincostello

Describe the bug

If a web application is published as a container image and the application contains any directories that have a name prefixed with a . character, for example wwwroot/.well-known, the directory and all the files within are not copied to the resulting Docker image.

This only appears to occur on Linux - on Windows the files are in the container image as expected.

If a non-container publish is performed, the expected directories and files can be seen in the published application.

My hunch is that the issue is here:

options: new EnumerationOptions()
{
RecurseSubdirectories = true
});

By default, EnumerationOptions.AttributesToSkip has a value of FileAttributes.Hidden | FileAttributes.System. On Linux, such directories are considered to be hidden (if my memory of hitting this problem before in Pester is correct pester/Pester#2327), so such directories are not copied into the tar files.

If my hunch is correct, this would be fixed with the following change:

options: new EnumerationOptions()
{
+   AttributesToSkip = FileAttributes.System, // Include hidden files
    RecurseSubdirectories = true
});

To Reproduce

  1. Clone martincostello/website@264fc77
  2. Run the following command from the root directory of the repository on Linux: dotnet publish ./src/Website --arch x64 --os linux -p:PublishProfile=DefaultContainer /p:ContainerArchiveOutputPath=./artifacts/images/repro.tar.gz
  3. Extract the repro.tar.gz file and the layers to view the contents of the layer containing the app directory.
  4. Observe that the app/wwwroot folder does not contain a .well-known directory.

Exceptions (if any)

None.

Further technical details

.NET SDK 8.0.204

Activity

  1. ghost added
    untriagedRequest triage from a team member
    on Apr 28, 2024
  2. baronfel commented on Apr 28, 2024

    @baronfel
    Member

    Solid analysis, I agree with your assessment here. We should include all files in the publish directory in the container image without existing any kind of opinion about the contents.

  3. added
    Area-ContainersRelated to dotnet SDK containers functionality
    and removed on Apr 28, 2024
  4. martincostello commented on Apr 28, 2024

    @martincostello
    MemberAuthor

    Once I've unblocked myself in the original app I hit this with, I'll circle back later today and see about doing the fix (and #40501). I imagine testing it E2E is probably going to be the slightly more involved piece here if that one-liner is indeed the fix.

  5. added theissue type on Aug 12, 2026
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

    Area-ContainersRelated to dotnet SDK containers functionalityuntriagedRequest triage from a team member

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions