开发者

How to enable 'Add Config Transforms' for old Visual Studio 2008 project?

I am working in the new Visual Studio 2010 RTM and I would like to use 开发者_开发问答web.config transforms.

My site is configured to use .NET 4.0 but it was formerly a Visual Studio 2008 web application project.

When I right-click on my web.config file I do not see the 'Add Config Transforms' option as I should. I also tried adding creating a new web.config but I still do not see the transform option.

Does anyone know how to enable web.config transforms for projects in Visual Studio 2010 that were originally created in Visual Studio 2008?


I was able to get this to work with my existing project.

I did it by opening my csproj file in notepad and comparing the child elements to those of a brand new ASP.NET MVC project for VS2010.

I then removed several elements that I didn't need and saved and reloaded my project. Then I was able to select 'Add Config Transforms.'

I do not know exactly which element was the culprit but I would guess it was either <ProductVersion>9.0.30729</ProductVersion> or <OldToolsVersion>3.5</OldToolsVersion</>.


I was able to get this to work in my converted project by opening up the .proj file and adding the following:

<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>

Then I copied my existing web.config twice into the web root and renamed them Web.Release.config and Web.Staging.config In VS I right mouse clicked and included them in the project

I then opened them up and added

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

to the configuration node so it looked like:

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

You have to have matching Release and Staging configuration names (using configuration manager). After this VS recognised them as web configuration transformation files

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜