该文件无法添加到项目中.该文件在项目目录树错误中 [英] The file could not be added to the project. This file is within the project directory tree error

查看:172
本文介绍了该文件无法添加到项目中.该文件在项目目录树错误中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试将文件添加到Visual Studio项目时,都会收到以下警告:

Whenever I try to add a file to my Visual Studio project, I get the following warning:

无法将文件[文件名]添加到项目中.该文件位于项目目录树中

The file [filename] could not be added to the project. This file is within the project directory tree

如何解决此错误?

推荐答案

进入Windows文件资源管理器并导航到.csproj文件,然后使用记事本(或高级文本编辑器,如NotePad ++)将其打开

Go in to your Windows File Explorer and navigate to the .csproj file and open it with Notepad (or advanced text editor like NotePad++)

您会注意到两行具有相似或重复的编译包含"行:

You will notice two lines that have similar or duplicate Compile Include lines:

<Compile Include="..\ProjectDir\SubDir\MyClass.cs">
  <Link>"SubDir\MyClass.cs"</Link>
</Compile>

删除上一行"并仅保留与下一行类似的行:

Remove the Above line and keep only the line similar to the one below:

<Compile Include="SubDir\MyClass.cs" />

这篇关于该文件无法添加到项目中.该文件在项目目录树错误中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆