Windows PowerShell 版权所有 (C) Microsoft Corporation。保留所有权利。 尝试新的跨平台 PowerShell https://aka.ms/pscore6 PS C:\Users\*******> sudo powershell Windows PowerShell 尝试新的跨平台 PowerShell https://aka.ms/pscore6 PS C:\Users\*******> nuget install chocolatey Feeds used: https://api.nuget.org/v3/index.json 正在将包 "chocolatey" 安装到 "C:\Users\*******"。 Attempting to gather dependency information for package 'chocolatey.2.3.0' with respect to project 'C:\Users\*******', targeting 'Any,Version=v0.0' Gathering dependency information took 19 ms Attempting to resolve dependencies for package 'chocolatey.2.3.0' with DependencyBehavior 'Lowest' Resolving dependency information took 0 ms Resolving actions to install package 'chocolatey.2.3.0' Resolved actions to install package 'chocolatey.2.3.0' Retrieving package 'chocolatey 2.3.0' from 'nuget.org'. GET https://api.nuget.org/v3-flatcontainer/chocolatey/2.3.0/chocolatey.2.3.0.nupkg OK https://api.nuget.org/v3-flatcontainer/chocolatey/2.3.0/chocolatey.2.3.0.nupkg 364ms Installed chocolatey 2.3.0 from https://api.nuget.org/v3/index.json to C:\Users\*******\.nuget\packages\chocolatey\2.3.0 with content hash jANdwBzeZWxNDlt7FDVbPo5F9uVM3XA9gXocVH+u5u7/UpmzHab22thb4WZBcHjreyVsb8uJXpTsRwSfU/rLNg==. Adding package 'chocolatey.2.3.0' to folder 'C:\Users\*******' Executing nuget actions took 3.43 sec # 进入nuget输出软件包下载位置, PS C:\Users\*******> cd C:\Users\*******\.nuget\packages\chocolatey\2.3.0 PS C:\Users\*******\.nuget\packages\chocolatey\2.3.0> ls Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2024/9/3 10:39 tools -a---- 2024/9/3 10:39 182 .nupkg.metadata -a---- 2024/6/5 14:20 12951 .signature.p7s -a---- 2024/9/3 10:39 5350990 chocolatey.2.3.0.nupkg -a---- 2024/9/3 10:39 88 chocolatey.2.3.0.nupkg.sha512 -a---- 2024/6/5 20:09 4163 chocolatey.nuspec # # 存在tools目录 PS C:\Users\*******\.nuget\packages\chocolatey\2.3.0> cd .\tools\ PS C:\Users\*******\.nuget\packages\chocolatey\2.3.0\tools> ls 目录: C:\Users\*******\.nuget\packages\chocolatey\2.3.0\tools Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 2024/6/5 20:09 17183 chocolateyInstall.ps1 -a---- 2024/6/5 20:09 52446 chocolateysetup.psm1 -a---- 2024/6/5 20:09 15709 init.ps1 # 执行安装, 第一次失败 # 错误信息提示执行策略问题, 并参考给出在在线链接, 调整档当前用户执行策略 PS C:\Users\*******\.nuget\packages\chocolatey\2.3.0\tools> .\chocolateyInstall.ps1 .\chocolateyInstall.ps1 : 无法加载文件 C:\Users\*******\.nuget\packages\chocolatey\2.3.0\tools\chocolateyInstall.ps1, 因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Pol icies。 所在位置 行:1 字符: 1 + .\chocolateyInstall.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [],PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess PS C:\Users\*******\.nuget\packages\chocolatey\2.3.0\tools> Get-ExecutionPolicy -List Scope ExecutionPolicy ----- --------------- MachinePolicy Undefined UserPolicy Undefined Process Undefined CurrentUser Undefined LocalMachine Undefined # 调整当前用户执行策略 PS C:\Users\*******\.nuget\packages\chocolatey\2.3.0\tools> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser PS C:\Users\*******\.nuget\packages\chocolatey\2.3.0\tools> Get-ExecutionPolicy -List Scope ExecutionPolicy ----- --------------- MachinePolicy Undefined UserPolicy Undefined Process Undefined CurrentUser RemoteSigned LocalMachine Undefined # 第二次执行安装 PS C:\Users\*******\.nuget\packages\chocolatey\2.3.0\tools> ./chocolateyInstall.ps1 Creating ChocolateyInstall as an environment variable (targeting 'Machine') Setting ChocolateyInstall to 'C:\ProgramData\chocolatey' WARNING: It's very likely you will need to close and reopen your shell before you can use choco. Restricting write permissions to Administrators We are setting up the Chocolatey package repository. The packages themselves go to 'C:\ProgramData\chocolatey\lib' (i.e. C:\ProgramData\chocolatey\lib\yourPackageName). A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin' and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'. Creating Chocolatey CLI folders if they do not already exist. chocolatey.nupkg file not installed in lib. Attempting to locate it from bootstrapper. PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding... 警告: Not setting tab completion: Profile file does not exist at 'C:\Users\*******\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'. Chocolatey CLI (choco.exe) is now ready. You can call choco from anywhere, command line or powershell by typing choco. Run choco /? for a list of functions. You may need to shut down and restart powershell and/or consoles first prior to using choco. # 验证安装 PS C:\Users\*******\.nuget\packages\chocolatey\2.3.0\tools> cd ~ PS C:\Users\*******> choco -v 2.3.0