VS2010 调试/release.config 不工作 [英] VS2010 debug/release.config not working

查看:19
本文介绍了VS2010 调试/release.config 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 web.debug.configweb.release.config 文件有点问题.

I'm having a bit of trouble with my web.debug.config and web.release.config files.

更具体地说,我的网页将只使用默认的 web.config 文件,而完全忽略 debugrelease 文件.这不仅发生在我在本地运行项目时,而且在我将其发布到 IIS 服务器时也会发生.

To be more specific, my webpage will only use the default web.config file, and completely ignore the debug and release files. This happens not only when I run the project locally, but also when I publish it to an IIS server.

我使用的是 Visual Studio 2010 Ultimate(无 Service Pack).

I am using Visual Studio 2010 Ultimate (no Service Pack).

这里是配置文件:

web.config:

<?xml version="1.0"?>

<configuration>
    <connectionStrings>
        <add name="MyConn" connectionString="SomeConnectionString"
            providerName="System.Data.SqlClient"/>
    </connectionStrings>
</configuration>

web.debug.configweb.release.config:

web.debug.config and web.release.config:

<?xml version="1.0"?>

<configuration xmlns:xtd="http://schemas.microsoft.com/XML-Document-Transform">
    <connectionStrings>
        <add name="MyConn" connectionString="SomeOtherConnectionString"
            providerName="System.Data.SqlClient"
            xtd:Transform="Replace"
            xtd:Locator="Match(name)"/>
    </connectionStrings>
</configuration>

正如我之前提到的,该网站使用来自 web.config 文件的连接字符串,而不是来自 web.release.config 的连接字符串.

As I mentioned before, the website uses the connection string from the web.config file, and not from the web.release.config.

另一个有趣的一点是,在我发布项目的物理文件夹中,所有三个 config 文件都存在;每个都与它们在 VS 解决方案中出现的完全相同.

Another interesting point is that in the physical folder to which I published the project, all three config files exist; each exactly the same as they appear in the VS solution.

有什么建议吗?

推荐答案

我发现我做错了什么.

我使用的是网站项目,而不是网络应用程序.

(两者的区别在于项目实际上并不包含.proj文件.多么讽刺.)

(The difference between the two is that a Project doesn't actually contain a .proj file. How ironic.)

现在我已经意识到了真正的问题,事实证明我不是第一个遇到它的人......这是指向上一篇文章的链接,其中包含一个变通的解决方案:

Now that I've realized the actual problem, it turns out that I'm not the first with it... Here's a link to a previous post with a workaround solution:

我如何做网站.config 转换与 Visual Studio 网站项目?

这篇关于VS2010 调试/release.config 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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