help with shared code between 2 projects

is there a way to have shared code between 2 entirely separate .csprojs? for something like usings or the like
6 Replies
jcotton42
jcotton4210mo ago
wdym for usings?
⃟⃟⃟⃟⃟ 웃
⃟⃟⃟⃟⃟ 웃OP10mo ago
i like to store all my usings in 1 class like this; i was wondering if there way any way to have these usings be shared between 2 projects, instead of each project having their own file for it
No description
Moods
Moods10mo ago
You can look into shproj s ? Afaik that’s sorta the only way to have something that solves your issue But idk it seems like a workaround to just copy-paste
⃟⃟⃟⃟⃟ 웃
⃟⃟⃟⃟⃟ 웃OP10mo ago
not rlly even an issue, was just wondering if there was a better way to do it rather than having to copypaste yeah
reflectronic
reflectronic10mo ago
you can add these global usings in the csproj
<ItemGroup>
<Using Include="Newtonsoft.Json" />
<Using Include="System.Text" />
<!-- add all the ones you want -->
</ItemGroup>
<ItemGroup>
<Using Include="Newtonsoft.Json" />
<Using Include="System.Text" />
<!-- add all the ones you want -->
</ItemGroup>
to share it for all your projects, you can put this inside a Directory.Build.props file, which will apply it automatically to your projects https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-by-directory?view=vs-2022
⃟⃟⃟⃟⃟ 웃
⃟⃟⃟⃟⃟ 웃OP10mo ago
tyvm
Want results from more Discord servers?
Add your server