ChinnaR
ChinnaR

Reputation: 837

aws code pipeline buildspec chocolatey choco command is not recognised

My end goal is to install wixtoolset as part of AWS Code Pipeline to build a project. As part of my buildspec file, I installed Chocolatey but the subsequent command to install wixtoolset through choco command isn't working. It's throwing an error saying 'choco is not recognised as the name of the cmdlet' On a local machine it works fine if we close the powershell and open a new instance. But What commands should I run to refresh the powershell without closing it so that choco command is recognised

version: 0.2

env:
  variables:
    DOTNET_FRAMEWORK: 4.7.2
phases:
  install:
    commands:
      - Install-PackageProvider -Name NuGet -RequiredVersion 2.8.5.201 -Force
      - Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) 
      - choco install wixtoolset -y
      - refreshenv
  build:
    commands:
      - msbuild WindowsFormsActions.sln /t:Clean,Build /p:Configuration=Release /p:TargetFrameworkVersion=v$env:DOTNET_FRAMEWORK /p:PackageAsSingleFile=false  
      - msbuild ActionsSetup\ActionsSetup.wixproj /t:Clean,Build /p:Configuration=Release /p:TargetFrameworkVersion=v$env:DOTNET_FRAMEWORK /p:PackageAsSingleFile=false
artifacts:
  files:
    - '**/*'

With no luck, I tried quite a few commands after the installation of Chocolatey like

  1. Import-Module "$env:ProgramData\chocolatey\helpers\chocolateyInstaller.psm1"; Update-SessionEnvironment

2)$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")

  1. $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")

All I need is to install Chocolately and run wix toolset using choco command. To be precise, just need wix toolset installed through any means

Upvotes: 1

Views: 158

Answers (0)

Related Questions