c# App.Config 文件在为测试部署构建时未转换

c# App.Config file not transforming when building for Test deployment

我在我的应用程序中使用慢速猎豹,这样我就可以拥有 app.config 文件,这些文件将以与 web.config 转换相同的方式进行转换。我在其他项目中使用过这个没有问题,但出于某种原因在我的一个项目中,cofing 文件没有改变。

我的 App.Test.config 中的示例如下:

<add key="timer" value="300" xdt:Locator="Match(key)" xdt:Transform="SetAttributes"/>

我的 App.config 文件中对应的行是

<add key="timer" value="15"/>

问题原来是我没有在转换中的 <Add> 标签之前包含 <AppSettings> 标签。因此,当转换开始时,它会在 <Configuration> 而不是 <Configuration> <AppSettings>

内寻找关键计时器