gpt4 book ai didi

c# - web.config 转换未应用于发布或构建安装包

转载 作者:可可西里 更新时间:2023-11-01 08:03:38 25 4
gpt4 key购买 nike

今天我开始使用 VS 2010 中的 web.config 转换。首先,我尝试了很多关于这个主题的博客文章中的相同的 hello world 示例 - 更新一个连接字符串。

我创建了如下所示的最小示例(类似于 this blog 中的示例)。问题是,每当我对 .csproj 文件执行右键单击 ->“发布”或右键单击 ->“构建部署包”时,我都没有得到正确的输出。我得到的不是转换后的 web.config,而是 no web.config,而是包含两个转换文件。

我做错了什么?非常感谢收到任何帮助!

网络配置:

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="ConnectionString"
connectionString="server=(local); initial catalog=myDB;
user=xxxx;password=xxxx" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>

网络调试配置:

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="ConnectionString"
connectionString="server=DebugServer; initial catalog=myDB;
user=xxxx;password=xxxx"
providerName="System.Data.SqlClient"
xdt:Transform="SetAttributes"
xdt:Locator="Match(name)"/>
</connectionStrings>
</configuration>

Web.release.config:

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="ConnectionString"
connectionString="server=ReleaseServer; initial catalog=myDB;
user=xxxx;password=xxxx"
providerName="System.Data.SqlClient"
xdt:Transform="SetAttributes"
xdt:Locator="Match(name)"/>
</connectionStrings>
</configuration>

最佳答案

不可避免地,有了这些东西,答案实际上就在眼前。 xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"的存在在<configuration> web.config 的节点意味着我的转换不匹配。删除它解决了问题。

关于c# - web.config 转换未应用于发布或构建安装包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3054389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com