Set web.config transform in Asp.NET Core

后端 未结 8 1606
遥遥无期
遥遥无期 2021-01-04 10:54

I\'ve just came across with problem of web.config transformation in asp.net core.

There are two files: base web.config and web.prod-zone-a.config. My aim is to use t

相关标签:
8条回答
  • 2021-01-04 11:47

    may be i don't clear question. For mine case web.config override all settings in web.Release.config file.

    Fix for me, i just add reference for transformation xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" to configuration file.

    so, .config file should start:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    

    After some time, the best solutions is using dotnet-transform-xdt tool

    0 讨论(0)
  • 2021-01-04 11:53

    With the latest version of dotnet cli (2.1.400 or greater), you can just set this msbuild property $(EnvironmentName) and publish tooling will take care of adding ASPNETCORE_ENVIRONMENT environmentVariable to the web.config with the specified environment name.

    Also, XDT support is available starting 2.2.100-preview1.

    Sample: https://github.com/vijayrkn/webconfigtransform/blob/master/README.md

    0 讨论(0)
提交回复
热议问题