Codementor Events

The Case of the Missing .sln files from Visual Studio

Published May 10, 2024
The Case of the Missing .sln files from Visual Studio

For some time now, I have noticed that .sln files go missing when I push them to GitHub. Hmm…let’s solve this minor mystery.

Since Microsoft switched over to dot net core, they have been making some radical changes to how dot net works from the perspective of developers. For instance, it is now possible to do everything related to dot net on Mac using VS code (or similar stuff like Rider).

That’s pretty cool.

Then again, I am old school. I have been using visual studio since my engineering days (way back in 2002), and so, that is just stuck in my memory. Of course, I have begun using VS Code on both windows and Mac for dot net projects. Sometimes, I am forced to do so because the client is using VS Code.

So, I have to.

Still, when working on projects where I have the freedom to choose my own tools, I still fire up one of my many windows devices, and start using Visual Studio. Now, I noticed this scenario. The ‘.sln’ files go missing after I push them to repository.

At first, I was puzzled. Perhaps, I did something to get rid of it. However, why would I manually delete .sln? Then, of course, the mystery is always to do with the .gitignore file.

Especially this specific section in any standard .gitignore file.

# === Rules for MSVS artifacts ===
# === Rules for MSVS artifacts ===
Debug/
Debug/
Release/
Release/
*.sln
*.suo

Aha! So, that is what is happening. You see that '.sln' is being ignored. So, when I push to github, the sln files go away. So, in my current repositories, I have removed that line from the .gitignore.

Now, what to do if .sln is gone and now you want to start using solutions again?

That’s easy.

  1. Open Visual Studio (on windows, of course)
  2. File > New Project > “Blank Solution”
  3. Now, you have a blank solution. Now, go to your folder which has your project (or projects), and just add the manually.
  4. Don’t forget to set the startup project (either a single one or multiple) before you start coding.

And, that’s all there is to it.


this is a copy of the original post on my coding blog

Discover and read more posts from Vijayasimha BR
get started