Как использовать внешний модуль powershell в VSTS - PullRequest
0 голосов
/ 16 мая 2018

У меня есть следующее определение сборки, которое устанавливает chocolatey, а затем устанавливает шикарный git.

Однако при попытке использовать шикарные командлеты git у меня возникают проблемы.

enter image description here

Логи ниже

2018-05-16T07:26:47.0699610Z ##[section]Starting: Install poshgit
2018-05-16T07:26:47.0702724Z ==============================================================================
2018-05-16T07:26:47.0702850Z Task         : Chocolatey - Install Package
2018-05-16T07:26:47.0702946Z Description  : Installs a package using Chocolatey
2018-05-16T07:26:47.0703048Z Version      : 1.1.0
2018-05-16T07:26:47.0703131Z Author       : Jungerius IT
2018-05-16T07:26:47.0703211Z Help         : 
2018-05-16T07:26:47.0703300Z ==============================================================================
2018-05-16T07:26:47.0710435Z Preparing task execution handler.
2018-05-16T07:26:47.2325295Z Executing the powershell script: D:\a\_tasks\ChocoInstallPackage_5a0c2b6f-5503-4ec8-9d79-8d78f31eb1fb\1.1.0\installpackage.ps1
2018-05-16T07:26:49.3669410Z Running Chocolatey version 0.10.10
2018-05-16T07:26:49.3729906Z Adding --confirm to arguments passed to Chocolatey
2018-05-16T07:26:49.4071786Z Installing package poshgit from the Chocolatey package repository...
2018-05-16T07:26:49.9739470Z Chocolatey v0.10.10
2018-05-16T07:26:55.1127680Z Installing the following packages:
2018-05-16T07:26:55.1136686Z poshgit
2018-05-16T07:26:55.1141725Z By installing you accept licenses for the packages.
2018-05-16T07:26:59.1785671Z 
2018-05-16T07:26:59.1786787Z Progress: Downloading poshgit 0.7.3... 11%
2018-05-16T07:26:59.1787047Z Progress: Downloading poshgit 0.7.3... 35%
2018-05-16T07:26:59.1788387Z Progress: Downloading poshgit 0.7.3... 59%
2018-05-16T07:26:59.1790268Z Progress: Downloading poshgit 0.7.3... 83%
2018-05-16T07:26:59.1791434Z Progress: Downloading poshgit 0.7.3... 100%
2018-05-16T07:28:08.7812838Z 
2018-05-16T07:28:08.7813768Z poshgit v0.7.3 [Approved]
2018-05-16T07:28:08.7927753Z poshgit package files install completed. Performing other installation steps.
2018-05-16T07:28:17.2440355Z Downloading poshgit 
2018-05-16T07:28:17.2440890Z   from 'https://github.com/dahlbyk/posh-git/zipball/v0.7.3'
2018-05-16T07:28:17.7319554Z 
2018-05-16T07:28:17.7364572Z Progress: 18% - Saving 13.38 KB of 72.93 KB
2018-05-16T07:28:17.7364998Z Progress: 35% - Saving 25.92 KB of 72.93 KB
2018-05-16T07:28:17.7582093Z Progress: 52% - Saving 38.46 KB of 72.93 KB
2018-05-16T07:28:17.7606506Z Progress: 71% - Saving 51.84 KB of 72.93 KB
2018-05-16T07:28:17.7606825Z Progress: 87% - Saving 63.96 KB of 72.93 KB
2018-05-16T07:28:17.7607100Z Progress: 100% - Completed download of
> C:\Users\VssAdministrator\AppData\Local\Temp\poshgit\0.7.3\dahlbyk-posh-git-v0.7.3-0-g6eb84bd.zip
> (72.93 KB).
2018-05-16T07:28:17.7607357Z Download of dahlbyk-posh-git-v0.7.3-0-g6eb84bd.zip (72.93 KB) completed.
2018-05-16T07:28:20.8109868Z Extracting C:\Users\VssAdministrator\AppData\Local\Temp\poshgit\0.7.3\dahlbyk-posh-git-v0.7.3-0-g6eb84bd.zip
> to C:\tools\poshgit...
2018-05-16T07:28:25.3526959Z WARNING: posh-git repository structure is incompatible with %PSModulePath%.
2018-05-16T07:28:25.3532668Z WARNING: Importing with absolute path instead.
2018-05-16T07:28:25.5758578Z Environment Vars (like PATH) have changed. Close/reopen your shell to
2018-05-16T07:28:25.5759289Z  see the changes (or in powershell/cmd.exe just type `refreshenv`).
2018-05-16T07:28:25.7308461Z  The install of poshgit was successful.
2018-05-16T07:28:25.7312122Z   Software installed to 'C:\tools\poshgit'
2018-05-16T07:28:25.8100731Z 
2018-05-16T07:28:25.8101191Z Chocolatey installed 1/1 packages. 
2018-05-16T07:28:25.8101437Z  See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
2018-05-16T07:28:25.9812796Z ##[section]Finishing: Install poshgit

2018-05-16T07:28:25.9824530Z ##[section]Starting: PowerShell Script
2018-05-16T07:28:25.9829009Z ==============================================================================
2018-05-16T07:28:25.9829182Z Task         : PowerShell
2018-05-16T07:28:25.9829296Z Description  : Run a PowerShell script
2018-05-16T07:28:25.9829406Z Version      : 1.2.3
2018-05-16T07:28:25.9829514Z Author       : Microsoft Corporation
2018-05-16T07:28:25.9829663Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613736)
2018-05-16T07:28:25.9829805Z ==============================================================================
2018-05-16T07:28:26.0156399Z ##[command]. 'C:\Users\VssAdministrator\AppData\Local\Temp\a67e8c43-1d42-422a-84d9-14ecb3e43bb4.ps1'
> 
2018-05-16T07:28:26.7024074Z ##[error]Add-PoshGitToProfile : The term 'Add-PoshGitToProfile' is not recognized as the name of a cmdlet,
> function, script 
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct 
and try again.
At C:\Users\VssAdministrator\AppData\Local\Temp\a67e8c43-1d42-422a-84d9-14ecb3e43bb4.ps1:1
> char:1
+ Add-PoshGitToProfile
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Add-PoshGitToProfile:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


2018-05-16T07:28:27.1139427Z ##[error]Process completed with exit code 0 and had 1 error(s) written to the error stream.
2018-05-16T07:28:27.1153320Z ##[section]Finishing: PowerShell Script

1 Ответ

0 голосов
/ 16 мая 2018

Таким образом, проблема заключается в том, что вам нужно явно Import-Module на шаге сценария PowerShell.

Хотя, похоже, ваш предыдущий шаг сделал это - это был другой сеанс, и импорт действителен только в этой области сеанса.

Кроме; если вы посмотрите предупреждающие сообщения на предыдущем шаге, вы увидите это:

2018-05-16T07: 28: 25.3526959Z ПРЕДУПРЕЖДЕНИЕ: структура репозитория posh-git несовместима с% PSModulePath%.

2018-05-16T07: 28: 25.3532668Z ВНИМАНИЕ: Импортируется с абсолютным путем вместо

Итак, как говорится; импортируйте, используя абсолютный путь , поскольку только имя модуля не будет работать, поскольку модуль неправильно сформирован.

...