[英]Unable to use Powershell Module on Azure DevOps Repo
I have a powershell script that runs fine in my local but it wont run on the Azure DevOps Pipeline by Committing the script in the repo.我有一个 powershell 脚本,它在我的本地运行良好,但它不会在 Azure DevOps 管道上运行,方法是在仓库中提交脚本。 The script include multiple.psm1 Modules and it seems like devOps cant find the module.
该脚本包含多个.psm1 模块,似乎 devOps 无法找到该模块。 I tried committing the module files on the repo and Calling it via Import-Module but its still the same error
我尝试在 repo 上提交模块文件并通过 Import-Module 调用它,但它仍然是相同的错误
It's difficult for me to answer the questions.我很难回答这些问题。 It would be nice to have more screenshots, paths, details and environment, but I can tell you how I would do it.
有更多的截图、路径、细节和环境会很好,但我可以告诉你我会怎么做。
1) The example is based on ASP.NET project where I added ps1 script with psm1 module to the main project path. 1) 该示例基于 ASP.NET 项目,其中我将带有 psm1 模块的 ps1 脚本添加到主项目路径。 2) I pushed everything to the Azure Devops repo.
2) 我将所有内容推送到 Azure Devops 存储库。 3) I used Inline script to run the ps1 script:
3)我使用内联脚本来运行 ps1 脚本:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: '$(BUILD.REPOSITORY.LOCALPATH)\$(SYSTEM.TEAMPROJECT)\testScript.ps1'
4) In the script I used local path 4)在脚本中我使用了本地路径
Import-Module -Name ./testModule.psm1 -Verbose -ArgumentList 'Argument1'
And it worked.它奏效了。
PS. PS。
You can use powershell inline script to look at your azure devops variables您可以使用 powershell 内联脚本来查看您的 azure devops 变量
- task: PowerShell@2
inputs:
targetType: 'inline'
script: 'get-childitem -path env:*'
Using this information you can use powershell inline script to look for your PS1/PSM1 files:使用此信息,您可以使用 powershell 内联脚本来查找您的 PS1/PSM1 文件:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: 'ls $(BUILD.REPOSITORY.LOCALPATH)\$(SYSTEM.TEAMPROJECT)'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.