'Reference code files from external folder

I try to reference a collection of c# code to a console project in visual studio.

  1. I want to keep the referenced code outside the console project folder.

  2. I want the code to automatically update when it gets changed in the external position.

  3. The referenced codes folder structure should stay intact. (~100 files)

Is there a way of referencing/linking the code without updating everytime? "Include in Project" only works if the code is inside a solution folder.



Solution 1:[1]

I organise my git repos in a flat structure:

  • core
  • shared1
  • website1
  • website2

Where websites 1 and 2 both reference core and shared1.

When I add project references to core and shared1 from websites 1 and 2, they remain intact because they are both in the same relative location from the point of view of the websites.

Additionally, I organise my solution to mirror the external repo configuration, e.g.

  • core (solution folder)
    • corelibrary.csproj
  • shared1 (solution folder)
    • sharedlibrary.csproj
  • website1services.csproj
  • website1.csproj

Solution 2:[2]

I found a good solution, but I am curious if there is a better one. I am on Windows and using a simbolic link

cmd /c mklink /d /j _LinkedCode ..\..\..\_Code

then I can use "Include in Project" in visual studio

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kurt Hamilton
Solution 2 Mechandrius