how to replace string in file using msbuild?

后端 未结 8 2098
庸人自扰
庸人自扰 2020-12-01 09:05

I want to replace a string such \"how r u\" in file test.xml with a string \"i am fine\" in another file xy.xml.using regular expression in ms build.

ie i have to r

8条回答
  •  时光说笑
    2020-12-01 09:35

    The answer from @csharptest.net is good, but it doesn't work on DotNetCore. I would have added this as a comment, but I don't have enough reputation.

    On DotNetCore you have to update:

    • Task Factory to "RoslynCodeTaskFactory"
    • Task Assembly to "$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"
    • Remove the reference to "System.Core"
    • The consuming Target has to specify the "AfterTargets" attribute as "Build"

    Everything else should be the same:

    
      ...
    
      
        
          
          
          
          
        
        
          
          
          
          
            
          
        
      
    
      
        
      
    
    

提交回复
热议问题