Logo

dev-resources.site

for different kinds of informations.

VSBuild task fails on self-hosted Azure Pipelines Agent

Published at
9/21/2023
Categories
azuredevopspipelines
azurepipelines
azuredevops
Author
jessehouwing
Author
12 person written this
jessehouwing
open
VSBuild task fails on self-hosted Azure Pipelines Agent

VSBuild task fails on self-hosted Azure Pipelines Agent

Today I got this baffling error while trying to run one of the few pipelines I own that requires a self-hosted agent.

2023-09-18T13:24:55.1897667Z ##[section]Starting: VSBuild
2023-09-18T13:24:55.2042232Z ==============================================================================
2023-09-18T13:24:55.2042611Z Task : Visual Studio build
2023-09-18T13:24:55.2042705Z Description : Build with MSBuild and set the Visual Studio version property
2023-09-18T13:24:55.2042827Z Version : 1.214.0
2023-09-18T13:24:55.2042907Z Author : Microsoft Corporation
2023-09-18T13:24:55.2042985Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build
2023-09-18T13:24:55.2043127Z ==============================================================================
2023-09-18T13:24:56.8956825Z ##[error]The following error occurred while loading the extended type data file: Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member AuditToString is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member AccessToString is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Sddl is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Access is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Group is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Owner is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Path is already present.

2023-09-18T13:24:57.0291684Z ##[error]The 'ConvertTo-SecureString' command was found in the module 'Microsoft.PowerShell.Security', but the module could not be loaded. For more information, run 'Import-Module Microsoft.PowerShell.Security'.
2023-09-18T13:24:57.0552980Z ##[section]Finishing: VSBuild
Enter fullscreen mode Exit fullscreen mode

I don't run this pipeline often and had re-imaged my laptop since the last run in March 2023... And was stumped by the error message. Googling a bit led me to a pretty old GitHub issue which explains the problem might happen in you run a PowerShell script in a PowerShell 5.1 terminal a Windows Command Prompt in a PowerShell Core terminal.

But I wasn't, was I?!

After some more head scratching, I figured it out. I was running my Azure Pipelines agent Interactively and had launched it from a PowerShell 7 terminal. terminating the agent, opening a Windows Command prompt, and relaunching the agent fixed things.

[BUG]: launching self-hosted agent from powershell core prompt causes powershell-based tasks to fail #4438

What happened?

I provisioned a new self-hosted agent and ran it interactively using ./run.cmd from a pwsh prompt in my system. All jobs containing a powershell based task fail with obscure error messages:

See: https://jessehouwing.net/vsbuild-task-fails-on-self-hosted-azure-pipelines-agent/

Turns out this is caused by launching the agent from a powershell core prompt. Stopping the agent and starting it from PowerShell 5.1 or from a Windows Shell solves the issue. Would be nice if the agent detected this and would fail to start with a proper error message.

Versions

Azure DevOps Service Windows 11 version 22H2 (0S Build 22621.2283) Azure Pipelines Agent 3.225.0 VSBuild task: 1.214.0

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

  • [X] Self-Hosted
  • [ ] Microsoft Hosted
  • [ ] VMSS Pool
  • [ ] Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows 11 version 22H2 (0S Build 22621.2283)

Version controll system

Git

Relevant log output

2023-09-18T13:24:55.1897667Z ##[section]Starting: VSBuild
2023-09-18T13:24:55.2042232Z ==============================================================================
2023-09-18T13:24:55.2042611Z Task         : Visual Studio build
2023-09-18T13:24:55.2042705Z Description  : Build with MSBuild and set the Visual Studio version property
2023-09-18T13:24:55.2042827Z Version      : 1.214.0
2023-09-18T13:24:55.2042907Z Author       : Microsoft Corporation
2023-09-18T13:24:55.2042985Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build
2023-09-18T13:24:55.2043127Z ==============================================================================
2023-09-18T13:24:56.8956825Z ##[error]The following error occurred while loading the extended type data file: Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member AuditToString is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member AccessToString is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Sddl is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Access is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Group is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Owner is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Path is already present.

2023-09-18T13:24:57.0291684Z ##[error]The 'ConvertTo-SecureString' command was found in the module 'Microsoft.PowerShell.Security', but the module could not be loaded. For more information, run 'Import-Module Microsoft.PowerShell.Security'.
2023-09-18T13:24:57.0552980Z ##[section]Finishing: VSBuild
Enter fullscreen mode Exit fullscreen mode

Workaround:

Set the agent knob AZP_AGENT_CLEANUP_PSMODULES_IN_POWERSHELL on the agent prior to launching the agent:

$env:AZP_AGENT_CLEANUP_PSMODULES_IN_POWERSHELL="true"
.\run.cmd
Enter fullscreen mode Exit fullscreen mode

You can also add this as a variable to your pipeline.

azuredevops Article's
30 articles in total
Favicon
Creating SBOM with sbom-tool and CycloneDX on Azure DevOps
Favicon
Public IP Address in Azure | Understanding Public IP Address in Azure VM
Favicon
Terraform - Mastering Idempotency Violations - Handling Resource Conflicts and Failures in Azure
Favicon
Azure Devops Converting Classic Pipelines to Yaml Based Pipeline
Favicon
Register Azure DevOps Agents with Service Principal Secret !
Favicon
The Ultimate Guide to Azure DevOps: Key Benefits for Software Development Projects
Favicon
Azure DevOps Zero to Hero Series
Favicon
Azure DevOps Series - Azure Boards
Favicon
cp: cannot stat 'bhfonlineshop': No such file or directory. Azure devops pipeline error
Favicon
How to Maintain Issue Hierarchy Between Jira and Azure DevOps
Favicon
Azure DevOps | Using Terraform
Favicon
Azure DevOps | Installing Postman and Newman using npm
Favicon
Azure DevOps | Running JMeter Test Collection using JMeter Docker Image
Favicon
Azure DevOps | Running a Postman Collection using Newman Docker Image
Favicon
Azure DevOps | Deploy Postman Tests in Azure DevOps Test Plans
Favicon
Exploring Microsoft Azure AI Capabilities Using React, Github Actions, Azure Static Apps and Azure AI
Favicon
Azure DevOps Zero-to-Hero
Favicon
Azure pipelines - Passing variables across stages
Favicon
Terraform - Keep dependencies up to date with Dependabot (Azure DevOps version)
Favicon
Automate Azure VM Password Rotation with PowerShell and Azure DevOps
Favicon
Investigating az-cli performance on the hosted Azure Pipelines and GitHub Runners
Favicon
Azure DevOps Pipeline deployments to Azure App Services with Access Restrictions
Favicon
Step by step for build , test and deploy using azuredevops pipeline
Favicon
Step by Step instruction hosting on aks cluster for begineers
Favicon
Deploying to Azure from Azure DevOps without secrets
Favicon
VSBuild task fails on self-hosted Azure Pipelines Agent
Favicon
Azure devops pipeline for dotnet with cicd
Favicon
Bicep modules with PSRule – Testing, documentation, CI Pipeline & examples
Favicon
Conectando o VS Community ao Azure DevOps
Favicon
Como clonar um projeto no Azure DevOps

Featured ones: