pcnate
pcnate

Reputation: 1774

Chocolatey fails to install Inno Setup on Azure Pipeline

I am trying to install Inno Setup 5 on the built in VS2017 agent on Azure Devops for one of my build pipelines but I am getting the following two lines in the stdout but it exits with a code of 1 and there is nothing in the log files. My question(s):

Here are the two lines from stdout that I think are most important

    innosetup not installed. An error occurred during installation:
    The process cannot access the file '...\.chocolateyPending' because it is being used by another process.

Here is my build pipeline on Azure Devops:

enter image description here

My installer script is written in javascript and executed via npm script after installing dependencies

const utils = require('./utils');
const fs = require('fs');
const path = require('path');
const spawn = require('child_process').spawn;

const command = 'cmd /c choco install innosetup --yes --force --no-progress -ia \'/VERYSILENT\'';
const logDirectory = path.join( 'C:', 'ProgramData', 'chocolatey', 'logs' );

function install() {
  return new Promise( resolve => {

    const cmd = command.split(' ').filter( ( x, i ) => i === 0 ).join('');
    const args = command.split(' ').filter( ( x, i ) => i !== 0 );

    var sqlcmd = spawn( cmd, args );
    sqlcmd.stdout.on( 'data', data => {
      console.log( data.toString().replace( /\r\n$/gmi, '' ) );
    } )
    sqlcmd.stderr.on( 'data', data => {
      console.error( 'error', data.toString() );
      process.exit( 1 );
    } )
    sqlcmd.on( 'exit', code => {
      resolve( code );
    } )

  });
}

( async () => {

  utils.header( 'installing Inno Setup' );
  const installExitCode = await install();

  utils.header( 'Log directory:', logDirectory );
  console.log( '  *', fs.readdirSync( logDirectory ).join( '\r\n  * ' ) );
  utils.header( 'chocolatey.log' );
  fs.createReadStream( path.join( logDirectory, 'chocolatey.log' ) ).pipe( process.stdout );
  utils.header( 'choco.summary.log' );
  fs.createReadStream( path.join( logDirectory, 'choco.summary.log' ) ).pipe( process.stdout );

  if ( installExitCode !== 0 ) {
    console.log( 'installer exited with error code:', installExitCode );
    process.exit( installExitCode );
  }

})();

Here is the stdout I am getting from the failed Azure Devops build:

2019-01-22T18:34:19.0336866Z ########################################
2019-01-22T18:34:19.0337014Z 
2019-01-22T18:34:19.0337191Z   installing Inno Setup
2019-01-22T18:34:19.0337335Z 
2019-01-22T18:34:19.0337513Z Chocolatey v0.10.11
2019-01-22T18:34:19.0337798Z Installing the following packages:
2019-01-22T18:34:19.0338258Z innosetup
2019-01-22T18:34:19.0338554Z By installing you accept licenses for the packages.
2019-01-22T18:34:19.0338705Z 
2019-01-22T18:34:19.0338856Z InnoSetup v5.6.1 (forced) [Approved]
2019-01-22T18:34:19.0339051Z innosetup package files install completed. Performing other installation steps.
2019-01-22T18:34:19.0339266Z innosetup not installed. An error occurred during installation:
2019-01-22T18:34:19.0339462Z  Item has already been added. Key in dictionary: 'NPM_CONFIG_CACHE'  Key being added: 'npm_config_cache'
2019-01-22T18:34:19.0339703Z The process cannot access the file 'C:\ProgramData\chocolatey\lib\InnoSetup\.chocolateyPending' because it is being used by another process.
2019-01-22T18:34:19.0339890Z 
2019-01-22T18:34:19.0340054Z ########################################
2019-01-22T18:34:19.0340204Z 
2019-01-22T18:34:19.0340364Z   Log directory: C:\ProgramData\chocolatey\logs
2019-01-22T18:34:19.0340513Z 
2019-01-22T18:34:19.0340775Z   * choco.summary.log
2019-01-22T18:34:19.0342937Z   * chocolatey.log
2019-01-22T18:34:19.0343090Z 
2019-01-22T18:34:19.0343282Z ########################################
2019-01-22T18:34:19.0343425Z 
2019-01-22T18:34:19.0343598Z   chocolatey.log
2019-01-22T18:34:19.0343738Z 
2019-01-22T18:34:19.0344018Z 
2019-01-22T18:34:19.0344255Z ########################################
2019-01-22T18:34:19.0344406Z 
2019-01-22T18:34:19.0344582Z   choco.summary.log
2019-01-22T18:34:19.0344722Z 
2019-01-22T18:34:19.0344902Z installer exited with error code: 1

Upvotes: 3

Views: 2073

Answers (1)

Gary Ewan Park
Gary Ewan Park

Reputation: 18981

To answer some of your direct questions...

Does Inno Support being installed in this way?

Yes, innosetup does support being installed this way. You can see that on the packages page here. That green bulb at the top of the page is an indication that this package version correctly installed via the automated processes that Chocolatey has, verifying that a package installed correctly.

Does chocolatey require being run on machine with a logged in GUI?

No, this is not necessary in most cases. There are some Chocolatey packages that don't install silently, and the mechanism used to install these "may" require the installation to be running in an actual User process, but the majority of packages don't need this.

What am I doing wrong?

I have a suspicion that "something" isn't working correctly when running through npm, and being installed within a Promise. Looking at the log, there seems to be this entry:

2019-01-22T18:34:19.0339462Z Item has already been added. Key in dictionary: 'NPM_CONFIG_CACHE' Key being added: 'npm_config_cache'

In the middle of the Chocolatey log, which doesn't make sense to me.

My best advice would be to use the standalone Chocolatey Task on this extension (NOTE: Full disclosure, I am the author of this extension), or, attempt to do the installation outside of npm, perhaps directly with a PowerShell Task.

Upvotes: 2

Related Questions