如何在骑手中转换.json文件

发布于 2025-01-30 00:51:24 字数 494 浏览 3 评论 0原文

为了具有可用于测试不同移动操作系统的不同配置,我正在尝试在Rider(config/appsettings).json文件中创建变换文件。

在Rider网站上,有一个博客,显示如何为.config文件做到这一点: XDT配置转换

具有一个扩展名,允许.json转换称为slowcheetah:

到目前为止,我无法在.json文件上的骑手中执行此操作。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天邊彩虹 2025-02-06 00:51:25

XDT代表 XML数据转换,因此不支持JSON。

但是,您可以每个环境使用不同的JSON文件,如官方文档

// 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"
}

请注意,这与新.NET绑定(aka .net core,.net≥5)。

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).

ゃ人海孤独症 2025-02-06 00:51:25

好的,在我自己的问题上提起诉讼;)

我认为我可以更改.csproj项目文件以创建(但不是生成)变换文件:

<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>

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>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文