transformappsettingsriderxdtconfig.json

How to transform .json files in Rider


In order to have different configurations available for testing of different mobile OS's, I'm trying to create transform files in Rider on (config/appsettings).json files.

On the rider website there's a blog showing how to do exactly that for .config files: XDT configuration transformations in Rider

Visual Studio has an extension which allows .json transformations called SlowCheetah: SlowCheetah - Visual Studio Marketplace

So far I haven't been able to do this in Rider on .json files.


Solution

  • Ok, a heads up on my own question ;)

    I figured I can alter the .csproj project file to create (but not generate) transform files:

    <ItemGroup>
        <None Update="Config\Config.Android.json">
          <IsTransformFile>true</IsTransformFile>
          <DependentUpon>Config.json</DependentUpon>
        </None>
        <None Update="Config\Config.IOS.json">
          <IsTransformFile>true</IsTransformFile>
          <DependentUpon>Config.json</DependentUpon>
        </None>
        <None Update="Config\Config.json">
            <TransformOnBuild>true</TransformOnBuild>
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </None>
    </ItemGroup>
    <ItemGroup>
        <None Update="appsettings.json">
            <TransformOnBuild>true</TransformOnBuild>
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </None>
        <None Update="appsettings.IOS.json">
            <IsTransformFile>true</IsTransformFile>
            <DependentUpon>appsettings.json</DependentUpon>
        </None>
        <None Update="appsettings.Android.json">
            <IsTransformFile>true</IsTransformFile>
            <DependentUpon>appsettings.json</DependentUpon>
        </None>
    </ItemGroup>