1
votes

Background I have been experimenting with unity, hololens and managing them with git, and something curious happened to me. So far every time I create a unity project I got a visual studio solution and a project file. Every time. But once I introduce git to manage them, these files are ignored (they are in the .gitignore file that for example github generates for unity projects).

So what I did was the following:

  1. I created a unity project
  2. I added git to it
  3. After an initial commit, I pushed into github
  4. The github archive -as expected- ignored any visual studio solution or project file(Only assets and project settings there)
  5. To experiment, I downloaded the project from github
  6. I opened that with Unity.

As expected Unity rebuild many of the folders that had been ignored by the .gitignore file but it did not rebuild the solution file

This was the first time I have seen a unity project without a solution file. Nevertheless I built it and it worked well (it was for hololens)

However it bug me still, so as written in this answer I found a way to recover the visual studio solution file (and the project file)

The question

What for is the visual studio solution file (and the project) for a Unity project. It certainly didn't need it And the question that was not answered in the linked question: why does this happen??

1

1 Answers

0
votes

A Visual Studio Project is basically anything you create in Visual Studio. A web app, a website, a plugin, a service, a console app, a desktop program, etcetera. It contains all your content, scripts, and logic.

A Visual Studio Solution is essentially a container/folder for the project. It is handy when multiple projects are stored in one solution, and makes management of the projects easier. All the projects live within the same solution, but can also work independently (as long as they are not referencing each other).

Think of the solution as Visual Studio's way to relate and store all files and projects.

I might have a website with three different layers that I want in one location. The Data layer, the Front End, and an Email service. All of these will be stored in one solution, with the structure as follows:

MySite.sln
| MySite.Data.csproj
| MySite.Web.csproj
| MySite.Email.csproj

Or, for a game it might be:

MyGame.sln
| MyGame.ClientLogic.csproj
| MyGame.ServerLogic.csproj

This makes working on the project easy, as they are all stored in a single location under one solution.