AWS CodePipeline中安装Chocolatey后无法识别choco命令,无法安装WiX Toolset的问题求助
AWS CodePipeline中安装Chocolatey后无法识别choco命令,无法安装WiX Toolset的问题求助
各位大佬好,我现在遇到一个棘手的问题:我的最终目标是在AWS CodePipeline里安装WiX Toolset来构建项目,于是在buildspec文件里先安装了Chocolatey,但紧接着执行choco install wixtoolset -y的时候却报错,提示'choco is not recognised as the name of the cmdlet'。
在本地机器上,装完Chocolatey后重启PowerShell就能正常用choco命令,但在CodePipeline里没法重启会话,所以想请教一下,有没有什么命令能在不关闭PowerShell的情况下刷新环境,让choco命令被识别?
我当前的buildspec.yml内容如下:
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: - '**/*'
我已经尝试过在Chocolatey安装后执行以下几种命令,但都没效果:
Import-Module "$env:ProgramData\chocolatey\helpers\chocolateyInstaller.psm1";Update-SessionEnvironment- 手动更新Path:
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
其实我核心需求很简单:只要能安装上WiX Toolset就行,不一定非要用Chocolatey的方式,只要能在CodePipeline的构建阶段正常使用WiX就行,麻烦各位大佬给支支招!
备注:内容来源于stack exchange,提问作者ChinnaR
相关产品推荐
相关产品推荐

