【发布时间】:2021-05-22 08:43:17
【问题描述】:
因此,经过一番折腾和按摩,我的电梯和移位管道的大部分问题都得到了解决,除了 2 件突出的事情:
- 当作为 azure devops 管道运行时(当我在本地运行时它工作正常),我收到以下错误:
Publish-Module : The specified module 'xanderu.helpers' with version '0.3.2' was not published because no module with
that name and version was found in any module directory.
- 成功构建后,我希望我的模块从 azdo 管道推送到公共 Github 存储库(以便其他人可以使用我构建的内容)
这是驱动整个过程的源代码的链接: https://github.com/Xander-Rudolph/powershell
任何人对为什么发布模块在作为 AZDO 管道运行时无法找到我复制到文档文件夹中的模块有任何想法?
这正是它失败的地方(文件 .\Public\Publish-ToPSGallery.ps1):
$PublishModulePath = Join-Path $module.FullName /$moduleName
$UserModulePath = ($env:PSModulePath -split ";")[0]
...
copy-item $PublishModulePath $UserModulePath -force -Recurse
Publish-Module @moduleParams -RequiredVersion $thisVersion
Remove-Item (Join-Path $UserModulePath /$moduleName) -Force -Recurse
编辑:遵循@WaitingForGuacamole 的建议后,我现在更加困惑。这些文件实际上位于这两个地方,因此有关 Microsoft 配置的某些内容必须检查不同的路径...
2021-02-22T13:14:26.1798590Z copy from D:\a\1\s\modules\xanderu.helpers\xanderu.helpers to C:\Users\VssAdministrator\Documents\WindowsPowerShell\Modules...
2021-02-22T13:14:26.1907802Z Publish path contents:
2021-02-22T13:14:26.2053090Z
2021-02-22T13:14:26.2055406Z
2021-02-22T13:14:26.2057324Z Directory: D:\a\1\s\modules\xanderu.helpers\xanderu.helpers
2021-02-22T13:14:26.2057953Z
2021-02-22T13:14:26.2058831Z
2021-02-22T13:14:26.2062498Z Mode LastWriteTime Length Name
2021-02-22T13:14:26.2065623Z ---- ------------- ------ ----
2021-02-22T13:14:26.2090344Z d----- 2/22/2021 1:13 PM private
2021-02-22T13:14:26.2091497Z d----- 2/22/2021 1:13 PM public
2021-02-22T13:14:26.2213533Z -a---- 2/22/2021 1:13 PM 8344 xanderu.helpers.psd1
2021-02-22T13:14:26.2225536Z -a---- 2/22/2021 1:13 PM 3986 xanderu.helpers.psm1
2021-02-22T13:14:26.2236604Z
2021-02-22T13:14:26.2239849Z
2021-02-22T13:14:26.2240328Z Directory: D:\a\1\s\modules\xanderu.helpers\xanderu.helpers\private
2021-02-22T13:14:26.2240554Z
2021-02-22T13:14:26.2240651Z
2021-02-22T13:14:26.2242897Z Mode LastWriteTime Length Name
2021-02-22T13:14:26.2245357Z ---- ------------- ------ ----
2021-02-22T13:14:26.2249485Z -a---- 2/22/2021 1:13 PM 8681 New-ModuleTemplate.ps1
2021-02-22T13:14:26.2259995Z -a---- 2/22/2021 1:13 PM 2112 New-ScriptTemplate.ps1
2021-02-22T13:14:26.2268743Z
2021-02-22T13:14:26.2269195Z
2021-02-22T13:14:26.2270936Z Directory: D:\a\1\s\modules\xanderu.helpers\xanderu.helpers\public
2021-02-22T13:14:26.2271221Z
2021-02-22T13:14:26.2271676Z
2021-02-22T13:14:26.2275692Z Mode LastWriteTime Length Name
2021-02-22T13:14:26.2277782Z ---- ------------- ------ ----
2021-02-22T13:14:26.2281863Z -a---- 2/22/2021 1:13 PM 3386 New-PowershellTemplate.ps1
2021-02-22T13:14:26.2294701Z -a---- 2/22/2021 1:13 PM 15800 Publish-ToPSGallery.ps1
2021-02-22T13:14:26.2304889Z User path contents:
2021-02-22T13:14:26.2319844Z
2021-02-22T13:14:26.2320556Z
2021-02-22T13:14:26.2322076Z Directory: C:\Users\VssAdministrator\Documents\WindowsPowerShell\Modules
2021-02-22T13:14:26.2322549Z
2021-02-22T13:14:26.2323876Z
2021-02-22T13:14:26.2328059Z Mode LastWriteTime Length Name
2021-02-22T13:14:26.2331429Z ---- ------------- ------ ----
2021-02-22T13:14:26.2340492Z d----- 2/22/2021 1:14 PM private
2021-02-22T13:14:26.2350981Z d----- 2/22/2021 1:14 PM public
2021-02-22T13:14:26.2356420Z -a---- 2/22/2021 1:13 PM 8344 xanderu.helpers.psd1
2021-02-22T13:14:26.2369615Z -a---- 2/22/2021 1:13 PM 3986 xanderu.helpers.psm1
2021-02-22T13:14:26.2378132Z
2021-02-22T13:14:26.2378762Z
2021-02-22T13:14:26.2380262Z Directory: C:\Users\VssAdministrator\Documents\WindowsPowerShell\Modules\private
2021-02-22T13:14:26.2380559Z
2021-02-22T13:14:26.2380712Z
2021-02-22T13:14:26.2387210Z Mode LastWriteTime Length Name
2021-02-22T13:14:26.2389867Z ---- ------------- ------ ----
2021-02-22T13:14:26.2394106Z -a---- 2/22/2021 1:13 PM 8681 New-ModuleTemplate.ps1
2021-02-22T13:14:26.2406799Z -a---- 2/22/2021 1:13 PM 2112 New-ScriptTemplate.ps1
2021-02-22T13:14:26.2470087Z
2021-02-22T13:14:26.2470773Z
2021-02-22T13:14:26.2472253Z Directory: C:\Users\VssAdministrator\Documents\WindowsPowerShell\Modules\public
2021-02-22T13:14:26.2472928Z
2021-02-22T13:14:26.2473097Z
2021-02-22T13:14:26.2479170Z Mode LastWriteTime Length Name
2021-02-22T13:14:26.2482022Z ---- ------------- ------ ----
2021-02-22T13:14:26.2486251Z -a---- 2/22/2021 1:13 PM 3386 New-PowershellTemplate.ps1
2021-02-22T13:14:26.2499805Z -a---- 2/22/2021 1:13 PM 15800 Publish-ToPSGallery.ps1
2021-02-22T13:14:26.8343310Z Publish-Module : The specified module 'xanderu.helpers' with version '0.3.3' was not published because no module with
2021-02-22T13:14:26.8344032Z that name and version was found in any module directory.
2021-02-22T13:14:26.8344599Z At C:\Program Files\WindowsPowerShell\Modules\xanderu.helpers\0.3.2\public\Publish-ToPSGallery.ps1:137 char:13
2021-02-22T13:14:26.8345194Z + Publish-Module @moduleParams -RequiredVersion $thisVersio ...
2021-02-22T13:14:26.8345691Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-02-22T13:14:26.8346249Z + CategoryInfo : InvalidArgument: (xanderu.helpers:String) [Publish-Module], ArgumentException
2021-02-22T13:14:26.8346842Z + FullyQualifiedErrorId : ModuleNotAvailableLocallyToPublish,Publish-Module
2021-02-22T13:14:26.8347201Z
编辑 2: 我将路径设置为 C:\Program Files\Windowspowershell 路径,这似乎绕过了这个问题,但是它引发了关于无效权限的 nuget 403 错误......这里仍然有一些时髦的东西......(参见模块版本 0.4 .2)
【问题讨论】:
-
使用Microsoft-hosted agents 很难调查此问题。我建议您使用self-hosted Windows-agent 来构建您的项目,该项目将在本地机器上运行并且应该可以正常工作。您还可以将管道变量 system.debug 设置为 true,然后将构建排队以获取包含详细构建信息的调试日志。
-
Wallezzi,感谢您提供这些文档的链接,但我确实已经有了该设置。 403 错误与我自己的愚蠢有关...更改了 PSGallery 密钥并忘记更新管道 var。我想确保此脚本适用于 microsoft 主机,因为该模块专门用于将 AZDO 管道用作提升和移位 powershell CI/CD 管道(因此无需自定义,如运行时代理)
标签: powershell azure-devops nuget