0

My question is rather simple and straightforward.

How could I share a Shared project in c# between different solutions?

It would contain Enums that are reused across different solutions. I tried working with Nuget, but I am looking for an alternative solution.

mko
  • 6,638
  • 12
  • 67
  • 118
  • You can just include a reference to the [Project Assembly](https://blogs.msdn.microsoft.com/benjaminperkins/2017/04/13/how-to-make-a-simple-dll-as-an-assembly-reference-just-for-fun/). – Tobias Tengler Jul 07 '19 at 11:19
  • @TobiasTengler but shared project doesnt generate a dll. – mko Jul 07 '19 at 11:22
  • 1
    Shared Projects are designed to be used in multiple solutions. Just add the shared Project in your solution. If you want to have a dll for that project you can not use a shared project – Gargo Jul 07 '19 at 11:24
  • @mko could you maybe clarify what you mean by "shared project". Generating a class library and then including this class library in your other projects allows you to reuse your enums, etc. – Tobias Tengler Jul 07 '19 at 11:25
  • @Gargo so instead of adding a reference, you are suggesting I should add an existing project? – mko Jul 07 '19 at 11:26
  • 2
    @mko that's what shares projects are designed for. they have just code that is included into another project and compiled there – Gargo Jul 07 '19 at 11:27
  • @gargo what happens when a shared project is changed by someone that is "referencing" it? does it influence other solutions, – mko Jul 07 '19 at 11:29
  • 2
    See [here](https://stackoverflow.com/questions/24294924/how-do-i-add-a-reference-to-a-shared-code-project-shproj-from-another-project). – user0 Jul 07 '19 at 11:31
  • 1
    @mko of course it will. A shared project is nothing else as something like code examles that are included into other projects like files. The projects will compile the files from shared projects. If you change a file from a shared project, you have to rebuild all libraries that reference it – Gargo Jul 07 '19 at 11:31
  • I am testing it and it looks like I am not able to update/edit shared project from a solution. Is that a fact? – mko Jul 07 '19 at 11:33
  • @mko can you explain in more detail what you mean? – Gargo Jul 07 '19 at 11:34
  • @Gargo let me do some research, i will get back to you – mko Jul 07 '19 at 11:45
  • @Gargo the problem I cannot solve is when I reference shared project in multiple project of a same solution. When one method in project A references a method in project B, if parameters passed are of enum defined in Shared Project, I receive an error cannot convert from Enum.TypeA to Enum.TypeA? Is that somekind of a limitation with shared projects? – mko Jul 07 '19 at 15:24
  • @mko can you ilusstrate this in the question with some code? i have trouble to flollow that – Gargo Jul 07 '19 at 16:17
  • @Gargo here is the question https://stackoverflow.com/questions/56923701/shared-project-issue-when-referenced-and-used-accross-multiple-project/56923735?noredirect=1#comment100389674_56923735 – mko Jul 07 '19 at 16:27
  • @Gargo with code example – mko Jul 07 '19 at 16:33
  • @mko i see. Depends where the enum is defined. If it's defined in the shared project there should be no problem (and it should be defined there) – Gargo Jul 08 '19 at 07:30
  • @Gargo it is defined there, but unfortunatelly i cannot get passed that error – mko Jul 08 '19 at 07:50

0 Answers0