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

后端 未结 6 982
旧时难觅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条回答
  •  攒了一身酷
    2020-12-05 01:10

    I'd prefer not to use entire an Web Application Project solution out of box. My solution is to use the XmlTransform task defined in Microsoft.Web.Publishing.Tasks.dll directly (this task is the core of WebConfigTransformation) This way it is flexible enough and does exactly what you expect it to do. For example here is the WebSiteTransformator.csproj I'm using for transforming web.config.

    Here also is an example of flexibility that is impossible to reach with original WebConfigTransformation: it takes web.Template.config, applies web.$(Configuration).config over it and writes web.config. This allows us to add web.config itself into ignore list in source control. It is still valid csproj to be referenced by website:

    
    
      
        AnyCPU
        2.0
        Library
        v4.0
        $(TEMP)\TransformWebConfig\bin
        $(TEMP)\TransformWebConfig\obj\
        $(BaseIntermediateOutputPath)$(Configuration)\
        $(SolutionDir)\MyWebSite\
      
      
        
      
      
      
      
        
      
    
    

提交回复
热议问题