2

I've been thinking on how to import a project B into a project A, which both are GitHub repositories.

Project B is a library I reuse over many projects, I do add stuff in it, directly from project X, Y or Z.

Project B is simple, it's a directory with C# files and an assembly definition, i.e. a Unity class library. It's like a Shared Project in Visual Studio in the sense that it is minimalist and self-contained.

I've been trying to look for alternatives such as git submodules and so on, but in the end, nothing beats the ease and flexibility of deploying that library to another project through a symbolic link.

Pros:

  • not getting a pre-built library (and impossible to augment, obviously)
  • code can be changed directly
  • IDE sees no difference, these are just files even though they're somewhere else
  • I do not have to mix commits in the library with those of the project

Cons:

  • I have to commit library to its repository
  • Some stuff can get broken if I do API changes

But in reality when I look at these cons, I don't think it outweighs the pros and these would happen even when trying a different approach.

This is how I set things up:

  • dev folder
    • library
    • project
      • library symlink

I use Link Shell Extension which eases the creation of symlinks in Windows Explorer.

Question:

Is it a good approach for being able to import external code in a project yet being able to modify it ?

Else, could you suggest some alternatives ?

5
  • which both are GitHub repositories - this is root of your question, why they are in the different repositories if one depend on another? – Fabio Feb 21 '20 at 20:45
  • They don't both depend on each other. – aybe Feb 21 '20 at 21:45
  • 2
    I think there's something to be said for a bit of discipline when it comes to editing shared libraries. Are you sure you want to make it as easy as possible? Shared libraries are usually released on a slower (and more thoughtful) cadence. – John Wu Feb 22 '20 at 9:23
  • Are the changes you make to the library code ever shared with other projects, or are they project specific changes? – Greg Burghardt Feb 24 '20 at 18:30
  • Thing is I work alone on a project that gets ever bigger. While juggling with different repos in CVS is inevitable and OK, also juggling with multiple instances of VS ends up being really cumbersome > I have less time for 'bureaucratic' stuff that in the end brings little improvements > If some project breaks it would be exactly the same even if I did it more seriously. The time spent on other VS instances as well as rebuilding and deploying libraries is literally as waste for a one man team. Right now, library is next to project and readily editable which IMO outweighs the supposed cons. – aybe Feb 26 '20 at 21:03
4

This is typically done with nuget packages in .NET, working with that ecosystem is probably the best step up from referencing projects directly, with the benefit that you can update your library without breaking your existing code that uses it via version pinning.

3
  • I have thought about nuget and even though contentfiles could be used, there is still the roundtrip about producing the package and of course, the ability to edit code inline is lost. Also, Unity does not support nuget packages, at least not officially. – aybe Feb 21 '20 at 2:08
  • I don't know much about Unity land, but if it were me I would do the work to get stuff working with packages since it's very much a standard and there's a lot of useful things out there. The loss of the ability to edit code from your libs inline would take some getting used to, but it's pretty likely you'll end up taking a more granular approach to shared libs as time goes on tbh. Barring that though, honestly if symlinks work for what you do and how you like to work, do it. (i'll bet that the second con you list will start to bug you a lot more than it does now in due time) – jdd Feb 21 '20 at 3:26
  • That's true, I agree. – aybe Feb 21 '20 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.