0

I have a .Net solution with multiple projects, for example, project A, B and C.

B and C are dependencies of A. That means without A, B and C could be compiled as well.

There are some special configurations in project A, so I want to exclude project A when uploading to Github repository.

If I just set the project folder name in .gitignore then I will get error while compiling the solution from Git. What should I do?

Maiko Tan
  • 16
  • 3
  • Does this answer your question? [Ignoring directories in Git repositories on Windows](https://stackoverflow.com/questions/343646/ignoring-directories-in-git-repositories-on-windows) – Enrico Campidoglio Aug 26 '20 at 14:15
  • Sorry, nope. I do know how to ignore directories in a git repo, but I want to know how to solve the potential problems that @felipe-oriani said below. – Maiko Tan Aug 27 '20 at 00:30
  • You might get better answers if you added the actual reason for having the project but not adding it to the repo – Emond Aug 27 '20 at 11:36
  • Yes, I have updated the question. Thanks. – Maiko Tan Aug 27 '20 at 12:35

1 Answers1

0

You can organize the projects in one folder each one and ignore the folder. On the .gitignore file:

/Project.Web/*

Considering the directory Project.Web is ion the root of the repository, everything under the Project.Web path would be ignored.

Potential Problems:

  1. If your solution file .sln references a project that may be not exists on the structure

  2. You could not be able to compile until you remove it from the sln.

  3. It also could be a reference to other projects in the same solution which also could avoid to compile.

If you just want to make possible the compilation, generate the dependent assembly you want to ignore and switch the reference from the project in solution to the generated assembly. It will make the compilation possible and you will not be exposing your code.

Felipe Oriani
  • 37,948
  • 19
  • 131
  • 194