Forum Discussion
MikeW2405
Nov 24, 2021Copper Contributor
How to include/exclude platform dependent code
Im wondering what the strategy is for inclusion/exclusion of code depending on TargetFramework? Or is there one? Eg, in ...\Core\src\Handlers\Application\ApplicationHandler.cs, it uses both file inc...
vodevil1985
Nov 25, 2021Copper Contributor
You can use multi targeting like approch, you set build env variables like TARGET_PLATFORM and in your csproj you make something like that
<ItemGroup Condition="'$(TARGET_PLATFORM)' == 'Linux'">
<Compile Include="*.linux.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TARGET_PLATFORM)' == 'Linux'">
<Compile Include="*.linux.cs" />
</ItemGroup>
- MikeW2405Nov 25, 2021Copper Contributor
vodevil1985, i know this. however my query was you have too ways of including/excluding code, what is the best to use? What you have said or #if defined.