-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdist.nuget.bat
More file actions
50 lines (43 loc) · 1.42 KB
/
dist.nuget.bat
File metadata and controls
50 lines (43 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@echo off
setlocal
set "PROJECT=src\DotNetSphinx\DotNetSphinx.csproj"
set "OUT_DIR=%~dp0nupkg"
set "GITVERSION_DLL=%USERPROFILE%\.nuget\packages\gitversion.msbuild\6.4.0\tools\net8.0\gitversion.dll"
set "TOOLS_DIR=%~dp0tools\nuget"
set "NUGET_EXE=%TOOLS_DIR%\nuget.exe"
for /f "usebackq tokens=*" %%v in (`dotnet --roll-forward Major "%GITVERSION_DLL%" "%~dp0src\DotNetSphinx" /showvariable SemVer`) do set "VERSION=%%v"
if not defined VERSION (
echo Failed to determine package version from GitVersion.
exit /b 1
)
echo Packing %PROJECT% with version %VERSION%...
dotnet pack "%PROJECT%" -c Release /p:PackageVersion=%VERSION% -o "%OUT_DIR%"
if errorlevel 1 (
echo dotnet pack failed.
exit /b 2
)
echo Signing packages...
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0sign.ps1" "%OUT_DIR%"
if errorlevel 1 (
echo Package signing failed.
exit /b 3
)
if not exist "%TOOLS_DIR%" mkdir "%TOOLS_DIR%"
if not exist "%NUGET_EXE%" (
echo Downloading nuget.exe...
powershell -NoProfile -Command "Invoke-WebRequest -Uri 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe' -OutFile '%NUGET_EXE%'" >nul 2>&1
if errorlevel 1 (
echo Failed to download nuget.exe.
exit /b 4
)
)
for %%F in ("%OUT_DIR%\*.nupkg") do (
echo Pushing %%~nxf ...
"%NUGET_EXE%" push "%%F" -Source https://www.nuget.org/api/v2/package
if errorlevel 1 (
echo nuget push failed for %%~nxf.
exit /b 5
)
)
echo Done.
endlocal