Visual Studio 2013 - 项目显示为“其他文件”

时间:2023-01-15 00:21:47

This is a weird one. I have a C# Class Library project within my solution. If I open a .cs file within this project, the Project drop-down on the code editor shows that it belongs to 'Miscellaneous Files'.

这很奇怪。我的解决方案中有一个C#类库项目。如果我在此项目中打开.cs文件,代码编辑器上的项目下拉列表显示它属于“杂项文件”。

Visual Studio 2013  - 项目显示为“其他文件”

Other symptoms: if I go to the properties of the project and look at Assembly Information, all values are blank, despite the values existing in the AssemblyInfo.cs file.

其他症状:如果我转到项目的属性并查看程序集信息,则所有值都为空,尽管AssemblyInfo.cs文件中存在值。

Both of these are annoying, but the problem is that

这两个都很烦人,但问题是

  • I don't get intellisense on any files in the project
  • 我没有对项目中的任何文件进行智能感知
  • I can't seem to step through it in the debugger (it tells me that the files do not belong to the solution and so can't be debugged).
  • 我似乎无法在调试器中单步执行它(它告诉我文件不属于解决方案,因此无法调试)。

Visual Studio 2013  - 项目显示为“其他文件”

I have tried:

我努力了:

  • Combing through the .csproj file and comparing to others in the solution (no joy)
  • 梳理.csproj文件并与解决方案中的其他人进行比较(没有快乐)
  • Re-creating the .csproj file and overwriting the old one (worked until I merged the branch into trunk, then the problem re-appeared)
  • 重新创建.csproj文件并覆盖旧文件(工作直到我将分支合并到主干,然后重新出现问题)
  • Banging my head on the keyboard (headache)
  • 在键盘上敲我的头(头疼)

Google has turned up nothing. Does anyone have any ideas as to what's going on here?

谷歌一无所获。有没有人对这里发生的事情有任何想法?

7 个解决方案

#1


26  

How I solved my issue

我是如何解决我的问题的

  1. Go to the file inside Solution Explorer.
  2. 转到解决方案资源管理器中的文件。
  3. Right-Click file and select Exclude from project.
  4. 右键单击文件,然后选择从项目中排除。
  5. Right-Click your project/folder where the file was and click add Existing Item, and add the file you just removed back into your project.
  6. 右键单击文件所在的项目/文件夹,然后单击“添加现有项”,并将刚刚删除的文件添加回项目中。

#2


6  

I have this issue in VS 2017 also.
I found that this miscellaneous files are files added outside the VS. So if switch to another git branch (where there are new files) whithout closing the VS and click to "Reload" button in VS (when it checks that sln/csproj files are modified outside the VS) then these new files are not correctly parsed by VS and "marked" as miscellaneous.

我在VS 2017也有这个问题。我发现这个杂项文件是在VS之外添加的文件。因此,如果切换到另一个git分支(有新文件)而不关闭VS并单击VS中的“重新加载”按钮(当它检查在VS外部修改sln / csproj文件时)则这些新文件未正确解析由VS和“标记”为杂项。

As workaround I close VS, remove folder .vs from disk and run VS again. After VS will fully initialized these new files are parsed successfully. Note this way clears you custom settings like StartUp Project and so on.

作为解决方法,我关闭VS,从磁盘中删除文件夹.vs并再次运行VS.在VS完全初始化后,这些新文件将被成功解析。请注意,这样可以清除自定义设置,例如StartUp Project等。

#3


4  

I had exactly the same problem and it turned out that some of the XAML files in my project were set to be built using the action 'XamlAppDef' (ie build it as a XAML Workflow) and when I turned it back to 'Compile', my Project dropdown instantly went from (Miscellaneous files) to the correct project.

我有完全相同的问题,事实证明我的项目中的一些XAML文件设置为使用动作'XamlAppDef'构建(即将其构建为XAML工作流),当我将其转回'Compile'时,我的项目下拉菜单立即从(杂项文件)转到正确的项目。

#4


2  

Here is the Solution:

这是解决方案:

  • Go to Options on the Tools menu and then select Documents in the Environment node. (If Documents does not appear in the list, select Show all settings in the Options dialog box.)
  • 转到“工具”菜单上的“选项”,然后在“环境”节点中选择“文档”。 (如果文档未显示在列表中,请选择“选项”对话框中的“显示所有设置”。)
  • Put a tick on "Miscellaneous files in Solution Explorer" and Click OK. (This option displays the "Miscellaneous Files" node in Solution Explorer. Miscellaneous files are files that are not associated with a project or solution but can appear in Solution Explorer for your convenience if you tick this option.)
  • 勾选“解决方案资源管理器中的其他文件”,然后单击“确定”。 (此选项在解决方案资源管理器中显示“其他文件”节点。其他文件是与项目或解决方案无关的文件,但如果勾选此选项,则可以在解决方案资源管理器中显示以方便使用。)
  • Locate your file in the Solution Explorer under "Miscellaneous Files". Then drag and drop your file to where it should belong and voila! This will copy the file to where you drop it. You may now safely delete the older file under Miscellaneous Files folder if you wish to do so.
  • 在“其他文件”下的解决方案资源管理器中找到您的文件。然后将文件拖放到它应该属于的位置,瞧!这会将文件复制到删除文件的位置。如果您愿意,现在可以安全地删除Miscellaneous Files文件夹下的旧文件。

#5


1  

In VS2017, I was able to fix this issue by deleting *.vs folder and *.user files

在VS2017中,我能够通过删除* .vs文件夹和* .user文件来解决此问题

#6


0  

Due to TypeScript, check that your file matches to pattern, specified in tsconfig.json file in "include" section. If .ts file not inculded by tsconfig, then intellicense will show it as Miscellaneous.

由于TypeScript,请检查您的文件是否与“include”部分中tsconfig.json文件中指定的模式匹配。如果.ts文件没有被tsconfig包含,那么intellicense会将其显示为Miscellaneous。

#7


0  

After trying all the other offered solution, what worked for me is:

在尝试了所有其他提供的解决方案之后,对我有用的是:

  • Editing the .gitattributes file.
  • 编辑.gitattributes文件。
  • adding *.xproj text eol=crlf
  • 添加* .xproj文本eol = crlf

So that my VS2015 xproj style .NET Core/Standard projects worked again.

这样我的VS2015 xproj样式的.NET Core / Standard项目再次起作用。

Turned out that my git was putting UNIX style EOL, which was confusing VS.

原来我的git放了UNIX风格的EOL,这让VS感到困惑。

#1


26  

How I solved my issue

我是如何解决我的问题的

  1. Go to the file inside Solution Explorer.
  2. 转到解决方案资源管理器中的文件。
  3. Right-Click file and select Exclude from project.
  4. 右键单击文件,然后选择从项目中排除。
  5. Right-Click your project/folder where the file was and click add Existing Item, and add the file you just removed back into your project.
  6. 右键单击文件所在的项目/文件夹,然后单击“添加现有项”,并将刚刚删除的文件添加回项目中。

#2


6  

I have this issue in VS 2017 also.
I found that this miscellaneous files are files added outside the VS. So if switch to another git branch (where there are new files) whithout closing the VS and click to "Reload" button in VS (when it checks that sln/csproj files are modified outside the VS) then these new files are not correctly parsed by VS and "marked" as miscellaneous.

我在VS 2017也有这个问题。我发现这个杂项文件是在VS之外添加的文件。因此,如果切换到另一个git分支(有新文件)而不关闭VS并单击VS中的“重新加载”按钮(当它检查在VS外部修改sln / csproj文件时)则这些新文件未正确解析由VS和“标记”为杂项。

As workaround I close VS, remove folder .vs from disk and run VS again. After VS will fully initialized these new files are parsed successfully. Note this way clears you custom settings like StartUp Project and so on.

作为解决方法,我关闭VS,从磁盘中删除文件夹.vs并再次运行VS.在VS完全初始化后,这些新文件将被成功解析。请注意,这样可以清除自定义设置,例如StartUp Project等。

#3


4  

I had exactly the same problem and it turned out that some of the XAML files in my project were set to be built using the action 'XamlAppDef' (ie build it as a XAML Workflow) and when I turned it back to 'Compile', my Project dropdown instantly went from (Miscellaneous files) to the correct project.

我有完全相同的问题,事实证明我的项目中的一些XAML文件设置为使用动作'XamlAppDef'构建(即将其构建为XAML工作流),当我将其转回'Compile'时,我的项目下拉菜单立即从(杂项文件)转到正确的项目。

#4


2  

Here is the Solution:

这是解决方案:

  • Go to Options on the Tools menu and then select Documents in the Environment node. (If Documents does not appear in the list, select Show all settings in the Options dialog box.)
  • 转到“工具”菜单上的“选项”,然后在“环境”节点中选择“文档”。 (如果文档未显示在列表中,请选择“选项”对话框中的“显示所有设置”。)
  • Put a tick on "Miscellaneous files in Solution Explorer" and Click OK. (This option displays the "Miscellaneous Files" node in Solution Explorer. Miscellaneous files are files that are not associated with a project or solution but can appear in Solution Explorer for your convenience if you tick this option.)
  • 勾选“解决方案资源管理器中的其他文件”,然后单击“确定”。 (此选项在解决方案资源管理器中显示“其他文件”节点。其他文件是与项目或解决方案无关的文件,但如果勾选此选项,则可以在解决方案资源管理器中显示以方便使用。)
  • Locate your file in the Solution Explorer under "Miscellaneous Files". Then drag and drop your file to where it should belong and voila! This will copy the file to where you drop it. You may now safely delete the older file under Miscellaneous Files folder if you wish to do so.
  • 在“其他文件”下的解决方案资源管理器中找到您的文件。然后将文件拖放到它应该属于的位置,瞧!这会将文件复制到删除文件的位置。如果您愿意,现在可以安全地删除Miscellaneous Files文件夹下的旧文件。

#5


1  

In VS2017, I was able to fix this issue by deleting *.vs folder and *.user files

在VS2017中,我能够通过删除* .vs文件夹和* .user文件来解决此问题

#6


0  

Due to TypeScript, check that your file matches to pattern, specified in tsconfig.json file in "include" section. If .ts file not inculded by tsconfig, then intellicense will show it as Miscellaneous.

由于TypeScript,请检查您的文件是否与“include”部分中tsconfig.json文件中指定的模式匹配。如果.ts文件没有被tsconfig包含,那么intellicense会将其显示为Miscellaneous。

#7


0  

After trying all the other offered solution, what worked for me is:

在尝试了所有其他提供的解决方案之后,对我有用的是:

  • Editing the .gitattributes file.
  • 编辑.gitattributes文件。
  • adding *.xproj text eol=crlf
  • 添加* .xproj文本eol = crlf

So that my VS2015 xproj style .NET Core/Standard projects worked again.

这样我的VS2015 xproj样式的.NET Core / Standard项目再次起作用。

Turned out that my git was putting UNIX style EOL, which was confusing VS.

原来我的git放了UNIX风格的EOL,这让VS感到困惑。