1

I am working on a visual studio c# project where we have references to several dlls. But we do not want to include the dlls in the github repository. This is because everyone who works on the project already have all the dlls in a directory on their computer, but that directory is different for everyone. So is there any way to have git not sync the assembly references while still syncing the rest of the .csproj file?

I tried to use git filters but I couldn't get them to work.

  • Is this a solution https://stackoverflow.com/questions/10779343/gitignore-nuget-exclude-packages-include-packages-repositories-config ? – Renat Aug 20 '19 at 15:26
  • @Renat No, I want to ignore the references, not the dlls themselves. Everyone who works on the project has the dlls on their computer, but in different directories. – Elin Forsum Aug 20 '19 at 15:37
  • 2
    That's not possible (and seems a little hacky). A better solution would be to create a nuget package with all these dlls and add it as a reference. It's not too difficult to do. – Philippe Aug 20 '19 at 15:44
  • @Philippe In this situation that's not a possible and would require more work than just manually editing the paths each time you pull. The reason for this strange setup is that the project is a mod to another game, and we need references to the dlls from that game. But we do not want to include the dlls from that game in the repository because we don't have the rights to, and having the references point to the game install directory has a lot of upsides. – Elin Forsum Aug 20 '19 at 15:48
  • how about `**/foo.dll` where `foo.dll` is the name of your `dll` file? BTW, are the .dll files inside the project folder? – user1984 Aug 20 '19 at 16:03
  • Ahh, I see you want to exclude part of the contents of a file. – user1984 Aug 20 '19 at 16:05
  • @Alireza Yes, but only the assembly references. So I guess that's everything between a – Elin Forsum Aug 20 '19 at 16:13
  • I think it's pretty doable with a *content filter driver* https://stackoverflow.com/questions/6557467/can-git-ignore-a-specific-line/6557522#6557522 If you give me some more context, what you've done and why your approach isn't working I'd be happy to help. – user1984 Aug 20 '19 at 16:23
  • but keep in mind that this approach may be a little intensive for your purposes. – user1984 Aug 20 '19 at 16:24
  • I think you will have much more added value to standardized on a relative path (that everyone should follow) and include all the dlls with a glob pattern (ex: `..\..\game_install\folder\**\*.dll`) like suggested by @Alireza. Perhaps even migrating to the sdk csproj file format to a better glob pattern support. – Philippe Aug 20 '19 at 22:21
  • Have you looked into the gitignore file here: https://github.com/github/gitignore/blob/master/VisualStudio.gitignore? – phishfordead Aug 23 '19 at 19:08

1 Answers1

0

I ended up solving it like this: I added a new folder to our project called UsedDlls and added a .gitignore inside of that:

*
!.gitignore

Copied all of the dlls we needed into that folder, and set all dll references to point into that folder.

So now we just copy the dlls we need into that directory when we need them. This way we dont save the dlls in the project itself and we dont need to fix the assembly references every time we pull.

Its not exactly the best solution since this means you have to copy the dlls manually every so often but it works and its a lot better than before.