添加三个 NuGet 安装脚本(批处理和 PowerShell),支持直接下载和通过 Chocolatey 安装 修改 CI 工作流,优先使用 Chocolatey 安装 NuGet 并更新 PATH 路径
39 lines
970 B
Batchfile
39 lines
970 B
Batchfile
@echo off
|
|
REM Simple NuGet installer for Windows
|
|
|
|
echo Installing NuGet...
|
|
|
|
REM Check if NuGet exists
|
|
where nuget >nul 2>nul
|
|
if %errorlevel% == 0 (
|
|
echo NuGet already installed
|
|
nuget help | findstr "NuGet"
|
|
pause
|
|
exit /b 0
|
|
)
|
|
|
|
REM Download NuGet using PowerShell
|
|
echo Downloading NuGet CLI...
|
|
powershell -Command "(New-Object Net.WebClient).DownloadFile('http://dist.nuget.org/win-x86-commandline/v6.7.0/nuget.exe', 'C:\nuget.exe')"
|
|
|
|
if %errorlevel% neq 0 (
|
|
echo Download failed, trying alternative...
|
|
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/v6.7.0/nuget.exe', 'C:\nuget.exe')"
|
|
)
|
|
|
|
REM Add to PATH
|
|
set PATH=C:\;%PATH%
|
|
setx PATH "C:\;%PATH%"
|
|
|
|
REM Verify installation
|
|
echo Verifying NuGet installation...
|
|
C:\nuget.exe help | findstr "NuGet"
|
|
|
|
if %errorlevel% equ 0 (
|
|
echo SUCCESS: NuGet installed successfully
|
|
) else (
|
|
echo ERROR: NuGet installation failed
|
|
exit /b 1
|
|
)
|
|
|
|
pause |