更新时间:2022-11-05 11:06:38
运行Develop publish配置文件时为何删除<appSettings/>
元素的答案是因为两个转换按以下顺序运行.
The answer to why the <appSettings/>
element is being removed when the Develop publish profile is run is because two transformations are run in the following order.
发生的是,第一个转换删除了<appSettings/>
元素.第二个转换尝试在该元素中设置键值,但找不到它,因此它默默地失败了.
What is happening is the the first transformation removes the <appSettings/>
element. The second transformation attempts to set the key value in that element, but cannot find it, so it silently fails.
我能够通过搜索控制台输出来确认这一点.运行Develop转换时,有一条警告,指出找不到所需的元素.
I was able to confirm this by searching through the console output. When the Develop transformation was run there was a warning that the desired element could not be found.
Example (shortened for clarity)
> TransformXml: Applying Transform File: C:\...\MyProject\Web.Develop.config
> C:\...\MyProject\Web.Develop.config(6,4): Warning : No element in the source document matches '/configuration/appSettings'
> TransformXml: Not executing SetAttributes (transform line 9, 10)
特定于配置文件的web.config转换和转换预览赛义德·易卜拉欣·哈希米(Sayed Ibrahim Hashimi)撰写的文章对确定这一问题非常有帮助.
The Profile specific web.config transforms and transform preview article by Sayed Ibrahim Hashimi was very helpful in identifying this was the issue.
就构建配置,发布配置文件和web.config转换之间的关系而言,我目前的理解是
As far as the relationship between the build configuration, publish profiles, and web.config transform go my current understanding is this.
关键是可以运行两个 web.config转换.
The key here being that two web.config transformations may be run.