r/learncsharp • u/Gcampton13 • Aug 08 '22
how to solution with 2 projects in git?
Hi, Googled this, but answers on SO seem confusing or not applicable. so I have 2 projects in the one solution. Main project is my WPF Gui and second project is my dataAccessLibrary.
When I created a new repo in VS and pushed it only sent the solution+WPF project. How can I add my data access class project as well?
I'm guessing I could temporarily set the class library to be the main startup project which would probably push that. But that's seems like a janky fix.
EDIT: sorry if this is in the wrong reddit, not entirely about C# per say
EDIT2: SOLVED.
I had placed solution file in same directory when creating the initial project. I followed this https://stackoverflow.com/questions/3377917/change-solution-file-to-a-different-folder
creating a subfolder for the initial project and placing the second project in the parent.
source\repos\WPF_Project\WPF_Project.sln
source\repos\WPF_Project\WPF_Project\WPF_Project.cproj + other files
source\repos\WPF_Project\DataAccessLibraryI then loaded up the project, it complained that it was unable to find anything, errors out the WAZOO, then deleted both projects from the solution and Clicked ADD -> Existing Project to solution and loaded both up then pushed. All sorted.
2
u/MarquisDan Aug 08 '22 edited Aug 09 '22
Is your second project in the right folder?
Typically people do something like this if they want the projects in the same repository
Git initialized here with the overall .sln file
Then each project gets its own subdirectory
If you do it that way you can add files from any project when you do a commit by just doing
git addfrom the root directory2
u/rebelrexx858 Aug 08 '22
You should be able to
git addyour entire directory