Web.Config transforms outside of Microsoft MSBuild?

后端 未结 8 2099
情书的邮戳
情书的邮戳 2020-11-29 18:13

Is it possible to use Microsoft\'s XML document transform, for preparing web.configs, outside of MSBuild? I would like to use PowerShell to do these transform without having

8条回答
  •  攒了一身酷
    2020-11-29 18:32

    The logic of the transformation is contained inside of the TransformXml task itself. If you want to call it from code you would have to use the MSBuild API with a mock engine and execute it. I have some code for this if you want.

    In your case since you mentioned PowerShell the best thing for you to do is to just create a wrapper MSBuild file to invoke the TransformXml task. I say this because PowerShell is configured to run under .NET 2.0, but the TransformXml task requires .NET 4.0. In order to call it from a dummy MSBuild file you can check my blog at http://sedodream.com/2010/04/26/ConfigTransformationsOutsideOfWebAppBuilds.aspx, but I've also pasted a sample from that link below.

    
        
    
        
            
        
    
    

    For mono, this should work (tested on mono 6.4, macos, 2019) :

    
      
      
        Web.config
        Web.Live.config
        Output.Web.config
      
      
        
        
        
        
        
      
    
    

    which you can run with just msbuild or supply parameters with

    msbuild /p:TransformSource=... /p:Transformer=...
    

提交回复
热议问题