Visual Studio Team Services操作的Powershell需要一个交互式窗口站

时间:2016-04-09 19:42:56

标签: powershell continuous-integration azure-devops nativescript

我正在尝试使用持续集成系统来构建Nativescript应用程序。请参阅页面上的this注释,Windows PowerShell脚本:

  

start-process -FilePath PowerShell.exe -Verb Runas -Wait -ArgumentList“-NoProfile -ExecutionPolicy Bypass -Command iex((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))”< / p>

应该设置nativescript环境。但是,当我在PowerShell构建步骤中将其作为inline script运行时,构建将失败并显示此输出:

Starting task: Powershell Script
******************************************************************************
. 'C:\Users\buildguest\AppData\Local\Temp\c0d7012a-0ed3-4dcd-976b-aa0ce6f6012b.ps1' 
Executing the following powershell script. (workingFolder = C:\a\1\s)
C:\Users\buildguest\AppData\Local\Temp\c0d7012a-0ed3-4dcd-976b-aa0ce6f6012b.ps1 
start-process : This command cannot be run due to the error: This operation requires an interactive window station.
At C:\Users\buildguest\AppData\Local\Temp\c0d7012a-0ed3-4dcd-976b-aa0ce6f6012b.ps1:1 char:1
+ start-process -FilePath PowerShell.exe -Verb Runas -Wait -ArgumentList "-NoProfi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
Process completed with exit code 0 and had 1 error(s) written to the error stream.
******************************************************************************
Finishing task: PowerShell
******************************************************************************
Task PowerShell failed. This caused the job to fail. Look at the logs for the task for more details.

我认为这意味着只有本地机器有GUI时脚本才会运行?对于远程托管构建服务器,情况显然不是这样。如果我的假设是正确的,有没有办法解决这个问题,或者删除GUI的依赖性?

更新

Here是我尝试从此脚本中删除所有用户互动,但我仍然得到相同的结果......

更新

******************************************************************************
Starting task: Run C:\NPM\Modules\tns.cmd
******************************************************************************
Executing the following command-line. (workingFolder = C:\a\1\s)
C:\NPM\Modules\tns.cmd build android
Error message highlight pattern: 
Warning message highlight pattern: 
[31;1mNo project found at or above 'C:\a\1\s' and neither was a --path specified.[0m
# build android
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé Usage   Γöé Synopsis                                                                                                                                                                                                                             Γöé
Γöé General Γöé $ tns build android [--compileSdk <API Level>] [--key-store-path <File Path> --key-store-password <Password> --key-store-alias <Name> --key-store-alias-password <Password>] [--release] [--static-bindings] [--copy-to <File Path>] Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Builds the project for Android and produces an APK that you can manually deploy on device or in the native emulator.
### Options
    * --compileSdk - Sets the Android SDK that will be used to build the project.
    * --release - If set, produces a release build. Otherwise, produces a debug build. When set, you must also specify the --key-store-* options.
    * --key-store-path - Specifies the file path to the keystore file (P12) which you want to use to code sign your APK. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.
    * --key-store-password - Provides the password for the keystore file specified with --key-store-path. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.
    * --key-store-alias - Provides the alias for the keystore file specified with --key-store-path. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.
    * --key-store-alias-password - Provides the password for the alias specified with --key-store-alias-password. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.
    * --static-bindings - This is an experimental feature. If set, generates static bindings from your JavaScript code to corresponding native Android APIs during build. This static bindings speed up app loading.**
    * --copy-to - Specifies the file path where the built .apk will be copied. If it points to a non-existent directory, it will be created. If the specified value is directory, the original file name will be used.
** By default, NativeScript runtime for Android uses runtime binding generator. When you extend a Java class and overwrite a lot of methods, this could be a potentially slow operation.
### Attributes
<API Level> is a valid Android API level. For example: 22, 23.
Sending exception report (press Ctrl+C to stop).....
******************************************************************************
Finishing task: CmdLine
******************************************************************************
Task CmdLine failed. This caused the job to fail. Look at the logs for the task for more details.
******************************************************************************
  

注意:如果您想要相对于repo的路径,可以使用$(Build.SourcesDirectory)\。

2 个答案:

答案 0 :(得分:2)

像Alistair所说,问题可能是由于这个障碍造成的:

# Self-elevate
$isElevated = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")
if (-not $isElevated) {
    start-process -FilePath PowerShell.exe -Verb Runas -Wait -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))"
    exit 0
}

我认为您无法在构建计算机上安装Chocolatey / Java / Android SDK,因为我怀疑您拥有该计算机的管理员权限。但是从我看到的Team Services已经支持Android构建,所以我怀疑它已经安装了Java和Android SDK。您是否曾尝试通过npm install -g nativescript安装nativescript,然后尝试构建项目?

<强>更新

C:\NPM\Modules\tns.cmd和“工具”放入“参数”build android --path $(Build.SourcesDirectory)

答案 1 :(得分:0)

根据Peter Staev的帖子,我已成功在VS Team Services上创建了一个构建定义。它只需要3个步骤:

  1. npm install -g nativescript
  2. npm install(在高级选项下设置工作目录)
  3. 使用工具添加命令行任务:
  4.   

    C:\ NPM \模块\ tns.cmd

    和论点:

      

    构建android --release --key-store-path&#34; PATH \ your.keystore&#34; --key-store-password $(keystore.password) - key-store-alias ALIAS --key-store-alias-password $(alias.password)

    (您可以使用变量来保护您的密码)