Comment by VikingCoder

9 months ago

Please help me figure out the best way to share code between Github repositories...

I love C#, and I acknowledge Github as the king of source control.

I make a new Repository a couple times a week, and use Visual Studio Code to clone it, and open a terminal and "dotnet new gitignore" and then use dotnet to make new projects all over the place...

On multiple machines, even. On a VM on my NAS. On my Windows machine. On my Windows laptop. On a VPS.

And I'm happy.

But how in the holy hell am I supposed to share code from one repository to another?

I want to make VikingCoderLib as a C# library (classlib), and drop in all of my favorite Extensions for generics and strings, and etc.

And then make another classlib for some of my Protocol Buffer utilities. And another classlib for setting up a terminal.js console for an app. And...

What's the best way to do that?

Submodules?

They really seem to suck. I can't easily make changes here, and use them there, without it being a huge pain in the rear.

Am I doing this wrong? Am I missing something?

I don't mind submodules much. I mean when I first used them I thought it was sucked, but now I use it all the time for personal projects. I like to make small Lua libs or fork existing Lua libs and include those in a lib directory in my LÖVE / LÖVR projects. Works fine for me.

Perhaps the only thing that sucks a bit about submodules, might be if you work with multiple people and some reference of a submodule is updated and you need to go into the submodule directory to update the reference locally. But I think that's the only thing, no big deal. I don't think you deal with this issue much when you work by yourself on a solo project, on a single machine.

How does any other language do this? I bounce between submodules and monorepo for hobby projects and both approaches have some issues. I'm not a git expert so working with monorepos are a little easier to work with for me.

Make your own packages for your extensions and pull that packages into your projects that need to reference those extensions.

  • And set up my own nuget repo?

    I want my code to be private...?

    • Yes you would set up your own nuget feed and publish as part of your build. You can set up the nuget feed on your own machine, use something like Teamcity or GitHub packages.

Monorepo?

  • I hate that you're almost certainly right.

    It feels like there should be a good way to have a dotnet classlib in one repository, and use it from others, but it just doesn't feel like they fit together the way they should.