cordova-windows icon indicating copy to clipboard operation
cordova-windows copied to clipboard

CI service to build, install and run Cordova Windows apps?

Open janpio opened this issue 5 years ago • 2 comments

Is there any CI service that can install and run Cordova Windows apps?


I tried these:

  • AppVeyor runs as Admin, which will not let you cordova run windows (and if you disable that check, you get Error: The package or bundle is not digitally signed or its signature is corrupted.)
  • Travis Windows fails with APPX0105: Cannot import the key file 'CordovaApp_TemporaryKey.pfx'. The key file may be password protected. To correct this, try to import the certificate manually into the current user’s personal certificate store.,
  • Azure Pipelines also runs as Admin, with that check disabled you get this:
    unning command: powershell -ExecutionPolicy RemoteSigned Import-Module "D:\a\1\s\platforms\windows\cordova\lib\WindowsStoreAppUtils.ps1"; Install-App "D:\a\1\s\platforms\windows\AppPackages\CordovaApp.Windows10_1.0.0.0_anycpu_debug_Test\Add-AppDevPackage.ps1"
    ound package: D:\a\1\s\platforms\windows\AppPackages\CordovaApp.Windows10_1.0.0.0_anycpu_debug_Test\CordovaApp.Windows10_1.0.0.0_anycpu_debug.appx
    ound certificate: D:\a\1\s\platforms\windows\AppPackages\CordovaApp.Windows10_1.0.0.0_anycpu_debug_Test\CordovaApp.Windows10_1.0.0.0_anycpu_debug.cer
    
    efore installing this app, you need to do the following:
    - Install the signing certificate
    
    On Windows this would also output Administrator credentials are required to continue. Please accept the UAC prompt and provide your administrator password if asked. and actually prompt you for Admin permissions.

janpio avatar Jul 06 '19 23:07 janpio

Same problem here with Travis. I posted a question and some more details over here: https://travis-ci.community/t/cannot-add-certificate-to-cert-currentuser-my/5976

rvanmil avatar Nov 15 '19 22:11 rvanmil

Good news, I got this working with GitHub Actions 😊

This is the (short version of the) workflow script I'm using

name: Build for Windows

on: [push]

jobs:
  build:

    runs-on: windows-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v1

    - name: Install Node.js 12
      uses: actions/setup-node@master
      with:
        node-version: '12.x'
        registry-url: 'https://npm.pkg.github.com'

    - name: Install Visual Studio 2017
      run: choco install visualstudio2017buildtools

    - name: Install Visual Studio 2017 Workloads
      shell: powershell
      run: ./vs2017.ps1

    - name: Import code signing certificate
      shell: powershell
      run: ./certificate.ps1

    - name: Install Cordova
      run: yarn global add cordova@9

    - name: Install dependencies
      env:
        NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
      run: yarn install

    - name: Build
      shell: bash
      run: yarn build

    - name: Cordova
      shell: bash
      env:
        MSBUILDDIR: '/C/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin'
        NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
      run: >
        cordova prepare windows &&
        cordova build windows --release --archs="x86 x64" --bundle --win --buildConfig=build.json

It runs two PowerShell scripts. One which installs VS2017 and the required dependencies (the GitHub Actions windows environment comes with VS2019 installed which doesn't work for cordova-windows):

Start-Process `
  -FilePath "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" `
  -Wait `
  -ArgumentList @( `
    "modify",
    "--installPath `"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools`"",
    "--add Microsoft.VisualStudio.Component.Windows10SDK",
    "--add Microsoft.VisualStudio.Component.Windows10SDK.15063.Desktop",
    "--add Microsoft.VisualStudio.Component.Windows10SDK.15063.UWP",
    "--add Microsoft.VisualStudio.Workload.WebBuildTools",
    "--add Microsoft.VisualStudio.Workload.UniversalBuildTools",
    "--norestart",
    "--quiet"
  )

And one which installs the code signing certificate:

$Pfxpath = './codesigning.pfx'
$Password = ConvertTo-SecureString -String 'secret' -AsPlainText -Force
Import-PfxCertificate -FilePath $Pfxpath -CertStoreLocation Cert:\CurrentUser\My -Password $Password

rvanmil avatar Nov 28 '19 22:11 rvanmil

We are archiving this repository following Apache Cordova's Deprecation Policy. We will not continue to work on this repository. Therefore all issues and pull requests are being closed. Thanks for your contribution.

timbru31 avatar Jan 09 '23 07:01 timbru31