microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.44k stars 2.6k forks source link

[BUG]: Task PowerShell version 2.228.0 runs perfectly and 2.230.0 fails: Unable to find type [System.Xml.Linq.XDocument] #19257

Open luislhg opened 8 months ago

luislhg commented 8 months ago

Task name

PowerShell

Task version

2.*

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows-2022

Task log

-- This is 2.230.0 output log, failing
Starting: Script: ConsoleSelfContained x64
==============================================================================
Task         : PowerShell
Description  : Run a PowerShell script on Linux, macOS, or Windows
Version      : 2.230.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Unable to find type [System.Xml.Linq.XDocument].
At D:\a\_temp\f049f606-ae70-42ac-abad-77dbaf06749d.ps1:15 char:36
+ ... System.Xml.Linq.XDocument]$xDoc = [System.Xml.Linq.XDocument]::Load($ ...
+                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Xml.Linq.XDocument:TypeName) [], ParentContainsErrorRecordExce 
   ption
    + FullyQualifiedErrorId : TypeNotFound

Generating script.
========================== Starting Command Output ===========================
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\f049f606-ae70-42ac-abad-77dbaf06749d.ps1'"
##[error]PowerShell exited with code '1'.
Finishing: Script: ConsoleSelfContained x64

Relevant log output

-- This is 2.228.0 output log, which works perfectly
Starting: Script: ConsoleSelfContained x64
==============================================================================
Task         : PowerShell
Description  : Run a PowerShell script on Linux, macOS, or Windows
Version      : 2.228.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\35cf2275-808b-45d5-914c-102f05da3078.ps1'"

SelfContained RuntimeIdentifiers OutputPath  
------------- ------------------ ----------  
true          win-x64            bin\Release\

Finishing: Script: ConsoleSelfContained x64

Aditional info

Hello I have an Azure Classic Pipeline that used to work and stopped working because of the PowerShell task. Neither the code or the Pipeline have been modified by me, the powershell script simply updated from 2.228 to 2.230 and now it no longer works.

I changed my script to manually add a reference to 'System.Xml.Linq' and it fixed this pipeline. But I wonder why out of no where PowerShell V2 just stopped having it and all pipelines will start to fail now?

It's running on Azure Pipelines, windows-2022.

-- Script
# Define the XML code to be added
$xmlCode = @"
<PropertyGroup>
    <SelfContained>true</SelfContained>
    <RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
    <OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
"@

# Load the .csproj file into an XDocument
$csprojPath = "$(System.DefaultWorkingDirectory)\Client\Client.csproj"
[System.Xml.Linq.XDocument]$xDoc = [System.Xml.Linq.XDocument]::Load($csprojPath)
# ... continues, error is in the line above.
github-actions[bot] commented 2 months ago

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

luislhg commented 2 months ago

Any updates on this?