XDT转换-转换转换 [英] XDT Transforms - Transforming the transform

查看:186
本文介绍了XDT转换-转换转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个nuget软件包,其中安装该软件包的部分结果是修改我的web.release.config.

I am creating a nuget package where part of the result of installing the package is to modify my web.release.config.

使用web.release.config.install.xdt将元素插入此文件没有问题,但是我需要在要插入的元素上保留xdt:Transform和xdt:Locator属性,因为这些转换需要在构建要部署的应用程序时运行.

I have no problem inserting elements into this file with my web.release.config.install.xdt, but I need to keep the xdt:Transform and xdt:Locator attributes on the elements I am inserting because these transforms will need to be run when the application is built for deployment.

例如,在安装nuget软件包时,我希望看到:

So for instance when installing the nuget package I would like to see:

<add key="serilog:using" value="Serilog.Sinks.Seq" xdt:Transform="InsertIfMissing" xdt:Locator="Match(key)" />

显示在web.release.config中,其中包括xdt:Transform和xdt:Locator属性.

show up in the web.release.config including the xdt:Transform and xdt:Locator attributes.

有可能这样做吗?

推荐答案

我不相信msbuild或SlowCheetah都支持您尝试执行的操作.大多数NuGet程序包所有者对他们的客户实施了解得不够多,无法将其值设置为特定于环境的配置.此外,转换工具在构建时是为满足不同需求而设计的,因此没有考虑使用NuGet编写这些工具.很抱歉这个坏消息.

I don't believe what you are trying to do is supported by either msbuild or SlowCheetah. Most NuGet package owners dont know enough about their customers implementation to set values into environment specific configs. Additionally the transform tools where not written with NuGet in mind as they was built to serve a different need. Sorry for the bad news.

您也许可以使用init.ps1 powershell脚本来完成此操作(NuGet会在解决方案中首次安装该软件包时运行此脚本),但是它并不干净.

You may be able to use an init.ps1 powershell script to get this done (NuGet will run this script the first time the package is installed in the solution) but it will be less than clean.

这篇关于XDT转换-转换转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆