Search code examples
visual-studio-2019projects-and-solutions

Stop Visual Studio 2019 from automatically adding files in project folder


I have a .NET Core 3 project in Visual Studio 2019. When I copy and paste a file, through Windows Explorer, into the project folder, Visual Studio automatically includes the file into my project, which I do not want to happen. Is there a setting to disable this feature?


Solution

  • Starting from VS 2017 project format in .NET has changed. You need to add <PropertyGroup> tag at the top of your .csproj file:

    <PropertyGroup> 
        <EnableDefaultItems>false</EnableDefaultItems>
    </PropertyGroup>
    

    Here is the complete answer to your question: In Visual Studio, why are all files automatically part of my C# project?