0

I have a relatively comprehensive solution that contains about 20 projects. One of the projects is "Utils", which I would like to have shared for other solutions. Unfortunately, if I added this project to another solution as a linked project, then this project didn't upload me to Git for this solution, so then teamwork is not possible. Therefore, I am looking for a solution to achieve that I can share the source codes of this project between the individual solutions. I use VS2019 and as a Git repository xxx.visualstudio.com. Thanks for the advice.

vesi
  • 53
  • 1
  • 4
  • 1
    "is it possible"? yes. is it recommendable? no. there's no perfect solution for your problem. our company solution is to host a private nuget-server and providing such dependencies as package. – Franz Gleichmann Jan 20 '21 at 11:33
  • Consider using a package manager or some sort of dependency manager. Don't use git for this. – evolutionxbox Jan 20 '21 at 11:36
  • Of course, I thought of doing it as a nuget package first, but I want other programmers to have access to the source code and to be able to add other functions in this project. If I went the nuget package, then anyone who would like to add something would have to publish a new package and I want to avoid that. – vesi Jan 20 '21 at 11:43
  • 1
    If doing a nuget package is not a solution for you because it add too much friction (even if you could also give access to the util repository) , the solution for you is to use submodules : https://git-scm.com/book/en/v2/Git-Tools-Submodules – Philippe Jan 20 '21 at 12:39

1 Answers1

1

If doing a nuget package is not a solution for you because it add too much friction (even if you could also give access to the util repository), and that you want to be able to update the "Utils" source directly from the sln file, then the solution for you is to use Git submodules.

From the documentation:

It often happens that while working on one project, you need to use another project from within it. Perhaps it’s a library that a third party developed or that you’re developing separately and using in multiple parent projects. A common issue arises in these scenarios: you want to be able to treat the two projects as separate yet still be able to use one from within the other.

You will have to create a repository for the "Utils" code and include it in the other(s) repositories as submodules.

But Visual Studio still no support it...

It's not crippling because you could still use it from the command line or from an external git GUI that support it (like GitExtensions for example).

Philippe
  • 28,207
  • 6
  • 54
  • 78