Skip to content
This repository was archived by the owner on Nov 6, 2018. It is now read-only.
This repository was archived by the owner on Nov 6, 2018. It is now read-only.

PhysicalFileProvider can't find ".env" file #232

Description

@HaoK

Maybe files that start with .causing issues?

Found by aspnet/Configuration#505

Simple repro:

        [Fact]
        public void CanAddDotEnvFile()
        {
#if NET451
            _basePath = AppDomain.CurrentDomain.GetData("APP_CONTEXT_BASE_DIRECTORY") as string ??
                AppDomain.CurrentDomain.BaseDirectory ??
                string.Empty;
#else
            _basePath = AppContext.BaseDirectory ?? string.Empty;
#endif

            File.WriteAllText(Path.Combine(_basePath, "works.env"), "foo");
            Assert.True(File.Exists(Path.Combine(_basePath, "works.env")));
            Assert.True(new PhysicalFileProvider(_basePath).GetFileInfo("works.env").Exists);

            File.WriteAllText(Path.Combine(_basePath, ".env"), "foo");
            Assert.True(File.Exists(Path.Combine(_basePath, ".env")));
            Assert.True(new PhysicalFileProvider(_basePath).GetFileInfo(".env").Exists); // Failes
        }

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions