'Howto pass argument depending on target framework?

My .csproj file uses multi target:

<TargetFrameworks>net6.0;net472</TargetFrameworks>

and I need the

'/p:DefineConstants="TRACE; X64; NETFRAMEWORK;"'

to only be applied when it's building for net472 and if it's not, I want to define other constants. How can I do this? I use MSBuild if it matters (because I have to support the 4.7.2 version).

Code snippet:

- task: MSBuild@1
  inputs:
    solution: 'Tests/**/*.csproj'
    platform: 'AnyCPU'
    configuration: 'Debug'
    msbuildArguments: # TODO: How?


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source