【问题标题】:Stop Visual Studio 2019 from automatically adding files in project folder阻止 Visual Studio 2019 在项目文件夹中自动添加文件
【发布时间】:2021-02-12 22:24:26
【问题描述】:

我在 Visual Studio 2019 中有一个 .NET Core 3 项目。当我通过 Windows 资源管理器将文件复制并粘贴到项目文件夹中时,Visual Studio 会自动将文件包含到我的项目中,这是我不希望发生的.是否有禁用此功能的设置?

【问题讨论】:

    标签: visual-studio-2019 projects-and-solutions


    【解决方案1】:

    从 VS 2017 开始,.NET 中的项目格式发生了变化。您需要在 .csproj 文件的顶部添加 标记:

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

    以下是您问题的完整答案: In Visual Studio, why are all files automatically part of my C# project?

    【讨论】:

      【解决方案2】:

      好吧,你可以修改已知的项目文件(.csproj for c# project),通过自定义满足你的包含文件的项目包含路径。

      有关详细信息,您可以查看以下内容: https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-well-known-item-metadata?view=vs-2015&redirectedfrom=MSDN

      Understanding a csproj assembly reference

      Including content files in .csproj that are outside the project cone

      充满信心地享受和部署!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-11-24
        • 1970-01-01
        • 1970-01-01
        • 2012-05-22
        • 1970-01-01
        • 1970-01-01
        • 2019-11-23
        • 2021-05-08
        相关资源
        最近更新 更多