0

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.

Erijk
  • 380
  • 3
  • 8

2 Answers2

1

XDT stands for XML Data Transform, therefore JSON is not supported.

But you can use different JSON files per environment, as stated in the official docs:

// appsettings.json
{
  "MyKey": "My default Value",
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  }
}

// appsettings.Development.json
{
  "MyKey": "My Development Value"
}

// appsettings.Production.json
{
  "MyKey": "My Production Value"
}

Please note that this is bound to the new .NET (aka .NET Core, .NET ≥ 5).

mu88
  • 4,156
  • 1
  • 23
  • 47
  • thanks @mu88, I see now i actually don't need to use an external plugin like xdt (as you say it only works with xml), you can set dependencies (transforms) up in the .csproj file. see my answer below – Erijk May 18 '22 at 12:25
  • If this suffices your needs, please consider accepting it as an answer so that the question gets closed :) – mu88 May 30 '22 at 06:20
0

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>
Erijk
  • 380
  • 3
  • 8