Dennisaa

SpecFlowAppConfig02

Oct 10th, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $xmlFile = "C:\temp\app.config"
  2. $xml = [xml] (Get-Content $xmlFile)
  3. $specFlowstepAssemblyFound = $xml.configuration.specFlow.stepAssemblies.Count
  4.  
  5. if ($specFlowstepAssemblyFound -eq 0) {
  6. # No Specflow stepAssemblies found, so create them...
  7.     $xml.SelectNodes('//configuration/specFlow') | % {
  8.         $stepAssembly1 = $xml.CreateNode('element','stepAssembly','')
  9.         $stepAssembly2 = $xml.CreateNode('element','stepAssembly','')
  10.         $stepAssembly1.SetAttribute('assembly','Dennis.Speech.Framework')
  11.         $stepAssembly2.SetAttribute('assembly','Dennis.Speech.Core')
  12.  
  13.         $stepAssemblies = $xml.CreateNode('element','stepAssemblies','')
  14.  
  15.         $stepAssemblies.AppendChild($stepAssembly1)
  16.         $stepAssemblies.AppendChild($stepAssembly2)
  17.  
  18.         $_.AppendChild($stepAssemblies)
  19.     }
  20.     $xml.Save($xmlFile)
  21. }
Advertisement
Add Comment
Please, Sign In to add comment