C
C#8mo ago
VeQox

✅ using from another csproj

Currently i have 2 projects, an api app and a worker service app And both use the same models. Is there a way to put the models in a libary project and the 2 other projects include them? Without me needing to write the models twice per project?
7 Replies
Buddy
Buddy8mo ago
Yes
VeQox
VeQox8mo ago
And how would i do that, been searching online but cant find anything on that topic (mightve searched for the wrong things)
Buddy
Buddy8mo ago
If you use Visual Studio Community then just right-click the solution and just create a new project. Add all the libraries you need and then start implementing the models, then right-click the projects and press add reference then just add it from shared project reference
Buddy
Buddy8mo ago
No description
VeQox
VeQox8mo ago
and if i dont use vsstudio when
ZacharyPatten
ZacharyPatten8mo ago
1. use source control if you are not already doing so 2. create a C# library project 3. copy your shared code into the library and remove the duplicates currently in each project 4. add a project reference from your current projects to the new library project if you are not using visual studio, then you can just edit the .csproj files to add project references. just add
<ItemGroup>
<ProjectReference Include="..." />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..." />
</ItemGroup>
where ... is the relative pat to the .csproj of your library project you need to put that inside the <Project>...</Project> node in the .csproj
VeQox
VeQox8mo ago
k this worked pog ❤️
Want results from more Discord servers?
Add your server
More Posts