C#C
C#17mo ago
Otozinclus

Include files only on a specific platform

Hey! The project I am working on, uses FFmpeg, but because there is no official release of FFmpeg for Windows on Arm, I need to add an unofficial build of FFmpeg for WoA into the build folder in order for it to work. I did that by adding following code to the .csproj file and it works:

<ItemGroup>
<Content Include="ffmpeg.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

<Content Include="ffprobe.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

However, this is totally unnecessary for any other platform but Windows Arm64, therefore my goal is that these files only get added to the build, if the user is building for WoA.

I tried that by adding a condition after the ItemGroup:

<ItemGroup Condition="'$(RuntimeIdentifier)' == 'win-arm64'">

Sadly, this does not work. It does build the project, but without these files, despite building on WoA. I then tried the opposite, excluding every other platform with != and that way it builds for WoA, but also for every other platform.

If anyone could explain why this happens, I would be very glad!
Was this page helpful?