Description of the issue
My tasks were working fine in the Azure DevOps hosted agent.
I just installed the self-hosted agent locally on Windows 11 x64. I already have PSRule 2.2.0 and PSRule.Rules.Azure 1.17.1 installed.
The self-hosted agent runs as the NETWORK SERVICE user.
It looks like it might be trying to uninstall or reinstall the modules, and it's erroring out.
Configuration
Yaml configuration of the extension.
- task: ps-rule-install@2
displayName: Install PSRule.Rules.Azure PS module
condition: and(succeeded(), eq('${{parameters.runPSRuleTests}}', true))
inputs:
module: PSRule.Rules.Azure
latest: false
prerelease: false
Expected behaviour
Expected it to work as it did in a hosted agent.
Error output
Starting: Install PSRule.Rules.Azure PS module
==============================================================================
Task : Install PSRule module
Description : Install a PowerShell module containing rules.
Version : 1.0.2207007
Author : Bernie White
Help : https://github.com/Microsoft/PSRule-pipelines/blob/main/docs/tasks.md#ps-rule-install
==============================================================================
[info] Using PreRelease: False
[info] Checking PowerShellGet
[info] Checking module: PSRule.Rules.Azure
[info] Installing module: PSRule.Rules.Azure
##[warning]The version '2.2.0' of module 'PSRule' is currently in use. Retry the operation after closing the applications.
##[warning]The version '1.17.1' of module 'PSRule.Rules.Azure' is currently in use. Retry the operation after closing the applications.
##[error]No match was found for the specified search criteria and module names 'PSRule.Rules.Azure'.
Finishing: Install PSRule.Rules.Azure PS module
Task in use and version:
Additional context
I tried commenting out the ps-rule-install
task, as I already have the modules installed locally.
The next task, ps-rule-assert
, failed in a similar manner as it too attempted to install the modules.
I next attempted to uninstall the modules from my machine to see if I could progress. I was blocked again with a similar message that they were in use.
I closed all terminals and powershell sessions and stopped VSCode (in which I have the PSRule extension installed). This seemed to allow me to uninstall the modules and run the job again.
This time I'm getting the following:
Starting: Run PSRule validation tests on Azure template files
==============================================================================
Task : PSRule analysis
Description : Run analysis with PSRule.
Version : 2.0.2207007
Author : Bernie White
Help : https://github.com/Microsoft/PSRule-pipelines/blob/main/docs/tasks.md#ps-rule-assert
==============================================================================
[info] Source 'C:\agent\_work\1\s\.ps-rule\' does not exist.
Checking PSRule
[info] Using repository: PSGallery
##[error]The 'Get-InstalledModule' command was found in the module 'PowerShellGet', but the module could not be loaded. For more information, run 'Import-Module PowerShellGet'.
Finishing: Run PSRule validation tests on Azure template file