I have a .NET Framework (4.8) C# Class Library project in Visual Studio 2019. The solution is structured as follows:
-- Root Folder
-- .git
-- .vs
-- *.cs
-- bin
-- Project.sln
-- Project.csproj
I have the solution in a remote Azure DevOps (git) repository. The solution is also referencing another project in a different folder. I want to have these projects in the same solution so that they will both push changes to my remote repository. I want the structure to be as follows:
-- Root Folder
-- .git
-- .vs
-- Project.sln
-- Project 1 Folder
-- .vs
-- *.cs
-- bin
-- Project1.csproj
-- Project 2 Folder
-- .vs
-- *.cs
-- bin
-- Project2.csproj
I don't want to have to create a new solution because I will then have to create a new remote repository, and I already have multiple past branches that I use for reference. I've already tried to move the projects into folders manually, but the folders did not appear in the solution explorer even though I selected to show all files. Can this be done?
I'm not sure I understand the relationship between the solution and the remote repository. That being said, it may not matter...
First re-org your projects: once you've moved your projects into the folder structure you want, from within Visual Studio, remove the project(s) from your solution, and then re-add them from their new locations. Note using VS for this is probably easier than trying to manually update all the paths in the .sln file.
Now update your source code in Git: After you're happy with the result, all the files you moved will appear as modified and/or renamed (or possibly added and deleted). Stage all the changes you want to keep and then commit.
Tip for Git beginners: if you aren't entirely sure what you're doing or you're new to Git, if you are ever in a position where you'd cry if you lost your work, make a copy of it outside of your Git repo for sanity purposes; you can always delete it later once you're sure you have your code properly committed.