Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share c# class source code between several projects

I have written a class that will handle internal logging in my application. Now I want to use this class in another new and totally separate project.

I could simply copy the file to the new project folder, but I would like to only have one copy of it to maintain so that all changes in it will apply to both projects over time.

I can use the "add existing file", but where do I put the file so that the next developer knows that it is required. I have once had a "shared" folder for this but one time that folder was not brought into the next development computer.

What is the best way to organize this so that it makes most sense for new maintainers and minimizes the risk for broken links in projects.

like image 564
hultqvist Avatar asked Apr 19 '10 11:04

hultqvist


People also ask

Is Citigroup part of Citibank?

Citibank is the consumer division of financial services multinational Citigroup. Citibank was founded in 1812 as the City Bank of New York, and later became First National City Bank of New York.


2 Answers

You could create a library project that has this class this way all you have to do is add a reference to that project.

If that is no option you could use "Right click -> add existing item -> Add as link" this way you only have one copy of the code but it can exist in multiple projects.

like image 110
Peter Avatar answered Oct 01 '22 17:10

Peter


A class library to share is the best solution.

But you can add a file to a VS project as a link rather than copying. To do this use the drop down on the Add button of the add existing item dialogue.

like image 43
Richard Avatar answered Oct 01 '22 19:10

Richard