How do I do Web.config Transformations with Visual Studio Website Projects?

后端 未结 6 981
旧时难觅i
旧时难觅i 2020-12-05 00:51

It doesn\'t seem to be possible to change the Build Configuration of Visual Studio 2010 Website Projects (as opposed to Visual Studio Web Applications), and changing the Bui

6条回答
  •  -上瘾入骨i
    2020-12-05 01:15

    I used a slightly alternative approach. Still a bit of a hack, but I think a lot more straightforward. This worked for me, but obviously there are a lot of different configurations available so I can't guarantee it'll work for everyone. This revolves around the way that a website is first packaged up in to your AppData folder before being published...

    1. Manually add a Web.Release.config file to the website and add the necessary transforms - obviously there's no 'Add Config Transform' option for websites, hence having to do this manually. Example Web.Release.config:

      
      
          
              
          
          
              
          
      
      
    2. Inside the website.publishproj file, ensure the configuration is set to Release:

      Release
      
    3. Add the following to the very bottom of website.publishproj (just before ):

      
        
        
      
      

提交回复
热议问题