3

我在新的 Visual Studio 2010 RTM 中工作,我想使用 web.config 转换。

我的站点配置为使用 .NET 4.0,但它以前是 Visual Studio 2008 Web 应用程序项目。

当我右键单击我的 web.config 文件时,我没有看到我应该看到的“添加配置转换”选项。我也尝试添加创建一个新的 web.config 但我仍然没有看到转换选项。

有谁知道如何为最初在 Visual Studio 2008 中创建的 Visual Studio 2010 中的项目启用 web.config 转换?

4

2 回答 2

2

我能够让它与我现有的项目一起使用。

我通过在记事本中打开我的 csproj 文件并将子元素与 VS2010 的全新 ASP.NET MVC 项目的子元素进行比较来做到这一点。

然后我删除了几个我不需要的元素并保存并重新加载了我的项目。然后我可以选择“添加配置转换”。

我不知道究竟是哪个元素是罪魁祸首,但我猜它是<ProductVersion>9.0.30729</ProductVersion>or <OldToolsVersion>3.5</OldToolsVersion</>

于 2010-04-18T02:17:59.530 回答
1

通过打开 .proj 文件并添加以下内容,我能够让它在我转换的项目中工作:

<ItemGroup>
    <Content Include="Web.Staging.config">
      <DependentUpon>Web.config</DependentUpon>
      <SubType>Designer</SubType>
    </Content>
    <Content Include="Web.Release.config">
      <DependentUpon>Web.config</DependentUpon>
      <SubType>Designer</SubType>
    </Content>
  </ItemGroup>

然后我将现有的 web.config 两次复制到 web 根目录中并将它们重命名为 Web.Release.config 和 Web.Staging.config 在 VS 中我右键单击并将它们包含在项目中

然后我打开它们并添加

xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"

到配置节点,所以它看起来像:

<configuration  xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

您必须具有匹配的 Release 和 Staging 配置名称(使用配置管理器)。在此 VS 将它们识别为 Web 配置转换文件之后

于 2011-01-12T15:38:09.460 回答