The file could not be added to the project. This file is within the project directory tree error

拈花ヽ惹草 提交于 2019-11-30 23:14:12

问题


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

How do I fix this error?


回答1:


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" />


来源:https://stackoverflow.com/questions/15845598/the-file-could-not-be-added-to-the-project-this-file-is-within-the-project-dire

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!