Change AssemblyName of csproj file in Azure Pipeline via powershell

Viewed 382

trying to change the AssemblyName of an .Net project file inside Azure Pipeline. Reason is to have a special name of the process. Would like to use PowerShell for this. I tried this:

 - task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      [xml]$xml =(gc "src/WaWiXPO/WaWiXPO.csproj")
      Write-Host $xml.Project.PropertyGroup[0].AssemblyName
      $xml.Project.PropertyGroup[0].AssemblyName = "WaWiDEV"
      $xml.Save("WaWiXPO.csproj")

Locally it is working fine, but in the pipeline, it does no change. No error message. Any ideas?

1 Answers

From the looks of it, you need to pass the full path to the call to Save:

- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      $path = "src/WaWiXPO/WaWiXPO.csproj"
      [xml]$xml =(gc $path)
      Write-Host $xml.Project.PropertyGroup[0].AssemblyName
      $xml.Project.PropertyGroup[0].AssemblyName = "WaWiDEV"
      $xml.Save($path)
Related