Why is Visual Studio 2019 not able to see the C# files?

Rod Falanga 561 Reputation points
2021-08-22T20:42:49.567+00:00

I'm working on setting up a new desktop PC, running Windows 10 Professional. I've got about a dozen Git repos in my Azure DevOps Services (ADS). I've got Git installed. I went to one of my Git repos in ADS, copied the URL, then issued a git clone command giving the URL to the repo in my Posh-Git command line. It cloned my repo to my machine. The repo I cloned had several small apps in it, mostly simple command line apps. The name of the repo is "Small Apps 2".

When I open Visual Studio 2019 Community Edition, the navigate to one of the projects under "Small Apps 2", I then open the solution file. However, of the two solutions I've opened, VS 2019 cannot find/see any of the .cs files. However, if I search for the .cs files using PowerShell, no problem - they're all there.

So, what's going on? Why can't VS 2019 "see" the .cs files, but PowerShell, Windows 10 File Explorer, etc. can?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,701 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rod Falanga 561 Reputation points
    2021-08-22T23:01:35.74+00:00

    I tried renaming the "Small%$20Apps%202" folder to "Small Apps 2", using PowerShell Rename-Item. That worked, now VS 2019 recognizes the .cs files in the projects.

    Gotta admit, I didn't expect this to happen. Well, posting this fix for anyone else out there who might encounter this problem.

    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Sam of Simple Samples 5,516 Reputation points
    2021-08-22T21:19:59.147+00:00

    Did you install .Net desktop development? When you execute the Visual Studio Installer is .Net desktop development selected?

    You say one of the projects and you say solution file. For the purpose of communicating it helps to be accurate about which is which. With the solution open, are the projects shown? What happens if you right-click a project (in the solution in Solution Explorer) and select "Add" | "Existing item..."; can you add a C# file that way? I realize that re-building a project that way might not be adequate but it does seem strange that something happened to the C# files. Note that in the VS File menu there is also "New" | "Project from existing code".

    0 comments No comments

  2. Rod Falanga 561 Reputation points
    2021-08-22T21:46:29.997+00:00

    Yes, I've installed the .NET desktop development.

    When I open a solution file, it sees the project file within it. But none of the project files see any of the C# files.

    I'm wondering if the issue is the Git project in ADS has embedded whitespace. The Git project, in ADS, is named "Small Apps 2", but when I cloned the repo, it named it Small%$20Apps%202". Could that be what's causing my problem?

    0 comments No comments

  3. Yohannes URRUTIA CASTRO 1 Reputation point
    2021-10-16T19:49:13.827+00:00

    Hi I have the same problem with visual studio 2019 .
    I solved the problem with changing the default editor, it was set to html and should be to c# encoding editor . Hope this help some one else

    0 comments No comments

  4. Sam AdvanES 1 Reputation point
    2021-11-19T18:48:59.557+00:00

    I found a better fix for it.

    Right click on the file you'd like to open.
    -> Open with -> C# Editor with Encoding -> OK

    That should fix it!

    0 comments No comments