'What is the right macro for platform?
I'm trying to write a pre-build event script that must be able to adapt the the build platform (Windows / Mac / Azure DevOps image) in my case.
So far I have found the $(Platform) macro but it returns me AnyCPU
What I need is Darwin or Win32/Win64, and I can't find it in the documentation. Is there such a thing ?
Thanks in advance.
EDIT :
For Azure DevOps there is Agent.OS and Agent.OSArchitecture
Solution 1:[1]
I found a solution. It was as easy as moving from a build event to a MS Build copy file task.
Inside this task, you can have a condition on the OS.
For Windows:
<Target Name="CopyWindowsRTELogConfigFile" BeforeTargets="PreBuildEvent" Condition="'$(OS)' == 'Windows_NT'">
<ItemGroup>
<RTELogWindowsConfigurationJson Include="$(ProjectDir)Configuration\Windows_NT\$(ConfigurationName)\specific.rtelog.appsettings.json" />
</ItemGroup>
<Copy SourceFiles="@(RTELogWindowsConfigurationJson)" DestinationFolder="$(ProjectDir)" />
</Target>
And Mac:
<Target Name="CopyDarwinRTELogConfigFile" BeforeTargets="PreBuildEvent" Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))'">
<ItemGroup>
<RTELogWindowsConfigurationJson Include="$(ProjectDir)Configuration\Darwin\$(ConfigurationName)\specific.rtelog.appsettings.json" />
</ItemGroup>
<Copy SourceFiles="@(RTELogWindowsConfigurationJson)" DestinationFolder="$(ProjectDir)" />
</Target>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Olivier MATROT |