Keith Williams
Keith Williams

Reputation: 2357

Visual Studio - project shows up as "Miscellaneous Files"

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'.

Screenshot of the problem

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.

Both of these are annoying, but the problem is that

Assembly info is blank

I have tried:

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

Upvotes: 51

Views: 86328

Answers (20)

Morgeth888
Morgeth888

Reputation: 251

I've had this problem and it was a user error. Turns out I had multiple copies of the code on my machine and was running a version under project2 while having project1 open in VS. So the debugger worked but loaded version under project2 and confused the heck out of me.

TLDR; Make sure the version running is from the same folders/files you have open in VS.

Upvotes: 0

Xindaar
Xindaar

Reputation: 331

Here is the Solution:

  • Go to Tools menu > Options > (expand) Environment > Documents (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.

Upvotes: 23

Kari
Kari

Reputation: 1370

You might need to increase the Windows filepath length, to allow it greater than 256 characters for filepaths.

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.

Upvotes: 0

sharmilapurusoth
sharmilapurusoth

Reputation: 1

If you not have compiler package miscellaneous files will created when build solution. So, Check nuget package Microsoft.Net.Compilers is installed or not. Install if not, or do update on that package. I did this and my issue solved.

Upvotes: 0

Dhruv Gandhi
Dhruv Gandhi

Reputation: 21

This Worked for me:

  • Check the namespace is given properly.
  • Go to Files > Close solution and then reopen the solution.

Upvotes: 2

aseman arabsorkhi
aseman arabsorkhi

Reputation: 362

perhaps after some refactoring,you have modified the name of the project under TFS and Rename the project using the Solution Explorer (i.e. right click the project and click rename) which does not match this project name on source Control Explorer. 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. for more detail My Response have been written here

Upvotes: 0

MarnBeast
MarnBeast

Reputation: 403

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. I was able to fix the issue by

  • renaming the problematic cs file
  • right clicking the project and choosing Add > Class...
  • adding the new class file with the same name as the old one
  • copying the contents of the old renamed file and pasting it into the new one, overwriting the default contents
  • deleting the old renamed file

Upvotes: 1

Wajdi Chamakhi
Wajdi Chamakhi

Reputation: 426

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. This is usefull for node_module files for example

  <ItemGroup>
    <Compile Remove="Controllers\StockController.cs" />
  </ItemGroup>

you only open your *.csproj and delete it from.

Upvotes: 1

Tomaž Zupan
Tomaž Zupan

Reputation: 31

I had this problem in VS2019 after upgrade from 2017. Clean and rebuild of solution fixed it.

  1. Build -> Batch build -> Select all -> Clean
  2. Build -> Batch build -> Select all -> Build

Upvotes: 3

Joseph Kwan
Joseph Kwan

Reputation: 1

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.

Upvotes: 0

say_wha
say_wha

Reputation: 1

If this is still an issue you might check through your Nuget packages. By default in VS 2017 some projects would include references to various compiler libraries from 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

Upvotes: 0

user11406962
user11406962

Reputation: 1

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.

Upvotes: 0

Maksym Manziuk
Maksym Manziuk

Reputation: 151

Check that link https://www.reddit.com/r/VisualStudio/comments/b8vbj8/help_netf461_project_opened_in_vs2019_all_files/

  1. Right click on "References" in the Solution Explorer
  2. Select "Manage NuGet Packages"
  3. Under the "Installed" tab search fro "Microsoft.Net.Compilers"
  4. Select "Microsoft.Net.Compilers"
  5. On the side window of "Microsoft.Net.Compilers" click the update button

    • VS2015 is compatible with .NET Compiler 1.x.x
    • VS2017 is compatible with .NET Compiler 2.x.x
    • VS2019 is compatible with .NET Compiler 3.x.x

So, just update Microsoft.Net.Compilers according to you vs's version

Upvotes: 13

KING
KING

Reputation: 980

How I solved my issue:

  1. Go to the file which appears as Miscellaneous Files inside Solution Explorer.
  2. Right-Click file and select Exclude from project.
  3. 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.

Upvotes: 49

我零0七
我零0七

Reputation: 493

maybe you can only open the error project in another solution and add the project you need in the new solution

Upvotes: -1

Jesse Chisholm
Jesse Chisholm

Reputation: 4026

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

  • Editing the .gitattributes file.
  • adding *.xproj text eol=crlf

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

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

Upvotes: 0

Chandra Rana
Chandra Rana

Reputation: 91

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

Upvotes: 9

Pavel
Pavel

Reputation: 2564

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.

Upvotes: 0

Gendolph
Gendolph

Reputation: 473

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.

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.

Upvotes: 27

JJP
JJP

Reputation: 1499

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.

Upvotes: 4

Related Questions