[英]Visual Studio - project shows up as "Miscellaneous Files"
This is a weird one.这是一个奇怪的问题。 I have a C# Class Library project within my solution.
我的解决方案中有一个 C# 类库项目。 If I open a
.cs
file within this project, the Project
drop-down on the code editor shows that it belongs to 'Miscellaneous Files'.如果我在这个项目中打开一个
.cs
文件,代码编辑器上的Project
下拉菜单显示它属于“杂项文件”。
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.其他症状:如果我转到项目的属性并查看
Assembly Information
,所有值都是空白的,尽管AssemblyInfo.cs
文件中存在值。
Both of these are annoying, but the problem is that这两个都很烦人,但问题是
I have tried:我努力了:
.csproj
file and comparing to others in the solution (no joy).csproj
文件并与解决方案中的其他文件进行比较(不高兴).csproj
file and overwriting the old one (worked until I merged the branch into trunk, then the problem re-appeared).csproj
文件并覆盖旧文件(一直工作到我将分支合并到主干中,然后问题再次出现) Google has turned up nothing.谷歌一无所获。 Does anyone have any ideas as to what's going on here?
有人对这里发生的事情有任何想法吗?
How I solved my issue:我如何解决我的问题:
I have this issue in VS 2017 also.我在 VS 2017 中也有这个问题。
I found that this miscellaneous
files are files added outside the VS.我发现这个
miscellaneous
文件是在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 的情况下切换到另一个 git 分支(其中有新文件)并单击 VS 中的“重新加载”按钮(当它检查 sln/csproj 文件是否在 VS 之外被修改时),那么这些新文件没有正确解析由 VS 并“标记”为
miscellaneous
。
As workaround I close VS, remove folder .vs
from disk and run VS again.作为解决方法,我关闭 VS,从磁盘中删除文件夹
.vs
并再次运行 VS。 After VS will fully initialized these new files are parsed successfully. VS 将完全初始化后,这些新文件被成功解析。 Note this way clears you custom settings like
StartUp Project
and so on.请注意,这种方式会清除您的自定义设置,例如
StartUp Project
等。
Here is the Solution:这是解决方案:
Check that link https://www.reddit.com/r/VisualStudio/comments/b8vbj8/help_netf461_project_opened_in_vs2019_all_files/检查该链接https://www.reddit.com/r/VisualStudio/comments/b8vbj8/help_netf461_project_opened_in_vs2019_all_files/
On the side window of "Microsoft.Net.Compilers" click the update button在“Microsoft.Net.Compilers”的侧面窗口中单击更新按钮
So, just update Microsoft.Net.Compilers according to you vs's version因此,只需根据您的 vs 版本更新 Microsoft.Net.Compilers
在 VS2017 中,我可以通过删除 *.vs 文件夹和 *.user 文件来解决这个问题
我遇到了完全相同的问题,结果发现我的项目中的一些 XAML 文件设置为使用操作“XamlAppDef”构建(即构建为 XAML 工作流),当我将其转回“编译”时,我的项目下拉列表立即从(杂项文件)转到正确的项目。
I had this problem in VS2019 after upgrade from 2017. Clean and rebuild of solution fixed it.从 2017 年升级后,我在 VS2019 中遇到了这个问题。清理和重建解决方案修复了它。
When you add a new file in a project, some times visual studio adds it in your project.csproj in <itemGroup>
as <Compile Remove>
so that file will not be compiled and will not be copied with the build files.当您在项目中添加新文件时,有时 Visual Studio 会将其添加到
<itemGroup>
中的 project.csproj 中作为<Compile Remove>
,这样该文件就不会被编译,也不会与构建文件一起复制。 This is usefull for node_module files for example例如,这对于node_module文件很有用
<ItemGroup>
<Compile Remove="Controllers\StockController.cs" />
</ItemGroup>
you only open your *.csproj and delete it from.您只需打开 *.csproj 并将其删除。
I had this issue in VS 2019 Community with a class file and KING's solution of excluding the file and re-adding it didn't work for me.我在 VS 2019 社区中遇到了这个问题,其中包含一个类文件,而 KING 排除该文件并重新添加它的解决方案对我不起作用。 I was able to fix the issue by
我能够通过
Due to TypeScript, check that your file matches to pattern, specified in tsconfig.json file in "include" section.由于 TypeScript,请检查您的文件是否与“include”部分的 tsconfig.json 文件中指定的模式匹配。 If .ts file not inculded by tsconfig, then intellicense will show it as Miscellaneous.
如果 tsconfig 未包含 .ts 文件,则 intellicense 会将其显示为 Miscellaneous。
After trying all the other offered solution, what worked for me is:在尝试了所有其他提供的解决方案之后,对我有用的是:
.gitattributes
file..gitattributes
文件。*.xproj text eol=crlf
*.xproj text 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 感到困惑。
If it's not showing up in your Solution Explorer, try clicking the "Show All Files" button at the top of Solution Explorer.如果它没有显示在您的解决方案资源管理器中,请尝试单击解决方案资源管理器顶部的“显示所有文件”按钮。 If the files become visible and are located under the project you expect them to be in, but the file still has "Miscellaneous" listed as its project, then right click the files and select "Include in Project".
如果文件变得可见并且位于您希望它们所在的项目下,但该文件仍将“杂项”列为其项目,则右键单击文件并选择“包含在项目中”。 Otherwise try dragging them to the proper project.
否则尝试将它们拖到正确的项目中。
I just hit this issue in VS 2017 and this is what worked for me.我刚刚在 VS 2017 中遇到了这个问题,这对我有用。
If this is still an issue you might check through your Nuget packages.如果这仍然是一个问题,您可以检查您的 Nuget 包。 By default in VS 2017 some projects would include references to various compiler libraries from Microsoft.
默认情况下,在 VS 2017 中,某些项目将包含对 Microsoft 的各种编译器库的引用。 These almost certainly aren't needed.
这些几乎可以肯定是不需要的。 In my case removing them immediately resolved the miscellaneous files issue.
在我的情况下,删除它们立即解决了杂项文件问题。
I can't recall which Nugets exactly but I am pretty sure one of them was - Microsoft.CodeDom.Providers.DotNetCompilerPlatform我不记得究竟是哪个 Nugets,但我很确定其中一个是 - Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Somehow I solved this by going to properties (Right-click the file and select Properties).不知何故,我通过转到属性(右键单击文件并选择属性)解决了这个问题。 The Build Action was set to Content.
构建操作设置为内容。 Just change it to Compile and problem solved.
只需将其更改为编译即可解决问题。
perhaps after some refactoring,you have modified the name of the project under TFS and Rename the project using the Solution Explorer (ie right click the project and click rename) which does not match this project name on source Control Explorer.也许经过一些重构,您已经修改了 TFS 下的项目名称,并使用与源代码管理资源管理器上的项目名称不匹配的解决方案资源管理器重命名项目(即右键单击项目并单击重命名)。 in this way you will see "Miscellaneous Files" in the Solution Explorer that are not associated with TFS,The Miscellaneous Files folder represents the files as links.
这样,您将在解决方案资源管理器中看到与 TFS 无关的“杂项文件”,杂项文件文件夹将文件表示为链接。 for more detail My Response have been written here
有关更多详细信息, 我的回复已写在这里
This Worked for me:这对我有用:
If you not have compiler package miscellaneous files will created when build solution.如果您没有编译器包,则会在构建解决方案时创建其他文件。 So, Check nuget package Microsoft.Net.Compilers is installed or not.
因此,检查 nuget 包 Microsoft.Net.Compilers 是否安装。 Install if not, or do update on that package.
如果没有,请安装,或者对该软件包进行更新。 I did this and my issue solved.
我这样做了,我的问题解决了。
You might need to increase the Windows filepath length, to allow it greater than 256 characters for filepaths.您可能需要增加 Windows 文件路径长度,以允许文件路径的长度超过 256 个字符。
In my case, the several files were very deep in folders and caused the long filepaths issue.就我而言,这几个文件在文件夹中非常深,并导致了长文件路径问题。 Search online how to increase it (via Registry & regedit).
在线搜索如何增加它(通过注册表和注册表编辑器)。 You'll have to restart PC afterwards.
之后您必须重新启动PC。
也许你只能在另一个解决方案中打开错误项目,并在新的解决方案中添加你需要的项目
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.