添加三个 NuGet 安装脚本(批处理和 PowerShell),支持直接下载和通过 Chocolatey 安装 修改 CI 工作流,优先使用 Chocolatey 安装 NuGet 并更新 PATH 路径
35 lines
1.1 KiB
Batchfile
35 lines
1.1 KiB
Batchfile
@echo off
|
|
REM Fix NuGet installation using Chocolatey
|
|
|
|
echo Installing NuGet via Chocolatey...
|
|
|
|
REM Check if Chocolatey is available
|
|
where choco >nul 2>nul
|
|
if %errorlevel% neq 0 (
|
|
echo Chocolatey not found, installing Chocolatey first...
|
|
powershell -Command "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'))"
|
|
)
|
|
|
|
echo Installing NuGet via Chocolatey...
|
|
choco install nuget.commandline -y
|
|
|
|
if %errorlevel% equ 0 (
|
|
echo SUCCESS: NuGet installed via Chocolatey
|
|
echo Updating PATH...
|
|
set PATH=C:\ProgramData\chocolatey\bin;%PATH%
|
|
setx PATH "C:\ProgramData\chocolatey\bin;%PATH%"
|
|
|
|
echo Verifying installation...
|
|
nuget help | findstr "NuGet"
|
|
|
|
if %errorlevel% equ 0 (
|
|
echo NuGet is working correctly!
|
|
) else (
|
|
echo WARNING: NuGet installed but not accessible
|
|
)
|
|
) else (
|
|
echo ERROR: NuGet installation failed
|
|
exit /b 1
|
|
)
|
|
|
|
pause |