Suppose I build my project these ways.
dotnet publish -r win-x86
dotnet publish -r linux-musl-x64
Is there a way in my .csproj
file to automatically include a native DLL based on the chosen RID?
You just need a Condition
on the element you want to control in the csproj file. For example:
<PackageReference Include="MyLibrary.Linux" Version="1.0.0"
Condition="'$(RuntimeIdentifier)'=='linux-x64'" />
<PackageReference Include="MyLibrary.Windows" Version="1.0.0"
Condition="'$(RuntimeIdentifier)'=='win-x64'" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With