-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathupdate-nuget.cmd
More file actions
310 lines (249 loc) · 7.58 KB
/
update-nuget.cmd
File metadata and controls
310 lines (249 loc) · 7.58 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
@echo off
:: Krypton Extended Toolkit - NuGet Package Update Tool
title NuGet Package Manager
cls
echo ========================================================================
echo Krypton Extended Toolkit - NuGet Package Manager
echo ========================================================================
echo:
:mainmenu
echo 1. Check for outdated packages
echo 2. Update all NuGet packages (restore with force)
echo 3. Clear NuGet cache
echo 4. List all packages
echo 5. Install dotnet-outdated tool (recommended)
echo 6. Update specific package
echo 7. Restore packages (normal)
echo 8. Show NuGet sources
echo 9. Return to main menu
echo:
set /p choice="Enter your choice (1-9): "
if "%choice%"=="1" goto checkoutdated
if "%choice%"=="2" goto updateall
if "%choice%"=="3" goto clearcache
if "%choice%"=="4" goto listpackages
if "%choice%"=="5" goto installtool
if "%choice%"=="6" goto updatespecific
if "%choice%"=="7" goto restore
if "%choice%"=="8" goto showsources
if "%choice%"=="9" goto exit
echo Invalid choice. Please try again.
pause
cls
goto mainmenu
:: ===================================================================================================
:checkoutdated
cls
echo ========================================================================
echo Checking for Outdated Packages
echo ========================================================================
echo:
echo Checking if dotnet-outdated tool is installed...
dotnet tool list --global | findstr /C:"dotnet-outdated" >nul 2>&1
if %ERRORLEVEL% == 0 (
echo ✅ dotnet-outdated tool is installed
echo:
echo Checking for outdated packages in solution...
echo:
dotnet outdated "Source\Krypton Toolkit\Krypton Toolkit Suite Extended 2022 - VS2022.sln"
) else (
echo ❌ dotnet-outdated tool is not installed
echo:
echo Would you like to install it now? (Y/N)
set /p install="Choice: "
if /i "%install%"=="Y" (
echo:
echo Installing dotnet-outdated tool...
dotnet tool install --global dotnet-outdated-tool
echo:
echo Tool installed! Running check...
echo:
dotnet outdated "Source\Krypton Toolkit\Krypton Toolkit Suite Extended 2022 - VS2022.sln"
) else (
echo:
echo Using basic package list instead...
echo:
dotnet list "Source\Krypton Toolkit\Krypton Toolkit Suite Extended 2022 - VS2022.sln" package --outdated
)
)
echo:
pause
cls
goto mainmenu
:: ===================================================================================================
:updateall
cls
echo ========================================================================
echo Update All NuGet Packages
echo ========================================================================
echo:
echo WARNING: This will force update all NuGet packages!
echo:
echo Are you sure you want to continue? (Y/N)
set /p confirm="Choice: "
if /i not "%confirm%"=="Y" (
echo Operation cancelled.
pause
cls
goto mainmenu
)
echo:
echo Updating all packages...
echo:
echo Step 1: Clearing local NuGet cache...
dotnet nuget locals all --clear
echo:
echo Step 2: Restoring packages with force flag...
dotnet restore "Source\Krypton Toolkit\Krypton Toolkit Suite Extended 2022 - VS2022.sln" --force
echo:
echo ✅ All packages have been updated!
echo:
pause
cls
goto mainmenu
:: ===================================================================================================
:clearcache
cls
echo ========================================================================
echo Clear NuGet Cache
echo ========================================================================
echo:
echo Clearing all NuGet caches...
echo:
dotnet nuget locals all --clear
echo:
echo ✅ NuGet cache cleared successfully!
echo:
echo Cache locations that were cleared:
echo - http-cache
echo - global-packages
echo - temp
echo - plugins-cache
echo:
pause
cls
goto mainmenu
:: ===================================================================================================
:listpackages
cls
echo ========================================================================
echo List All Packages
echo ========================================================================
echo:
echo Listing all packages in the solution...
echo:
dotnet list "Source\Krypton Toolkit\Krypton Toolkit Suite Extended 2022 - VS2022.sln" package
echo:
pause
cls
goto mainmenu
:: ===================================================================================================
:installtool
cls
echo ========================================================================
echo Install dotnet-outdated Tool
echo ========================================================================
echo:
echo Checking current installation...
dotnet tool list --global | findstr /C:"dotnet-outdated"
echo:
echo Installing/Updating dotnet-outdated-tool...
echo:
dotnet tool install --global dotnet-outdated-tool
if %ERRORLEVEL% == 0 (
echo:
echo ✅ Tool installed successfully!
) else (
echo:
echo Tool might already be installed. Attempting update...
dotnet tool update --global dotnet-outdated-tool
)
echo:
pause
cls
goto mainmenu
:: ===================================================================================================
:updatespecific
cls
echo ========================================================================
echo Update Specific Package
echo ========================================================================
echo:
echo This feature requires you to know:
echo 1. The project file path
echo 2. The package name
echo:
echo Example projects:
echo - Source\Krypton Toolkit\Krypton.Toolkit.Suite.Extended.Core\Krypton.Toolkit.Suite.Extended.Core 2022.csproj
echo - Source\Krypton Toolkit\Krypton.Toolkit.Suite.Extended.Controls\Krypton.Toolkit.Suite.Extended.Controls 2022.csproj
echo:
set /p projectpath="Enter project path (or 'back' to return): "
if /i "%projectpath%"=="back" (
cls
goto mainmenu
)
if not exist "%projectpath%" (
echo:
echo ❌ Project file not found: %projectpath%
echo:
pause
cls
goto mainmenu
)
echo:
set /p packagename="Enter package name to update: "
echo:
echo Updating %packagename% in project...
echo:
dotnet add "%projectpath%" package %packagename%
echo:
pause
cls
goto mainmenu
:: ===================================================================================================
:restore
cls
echo ========================================================================
echo Restore NuGet Packages
echo ========================================================================
echo:
echo Restoring all NuGet packages (normal restore)...
echo:
dotnet restore "Source\Krypton Toolkit\Krypton Toolkit Suite Extended 2022 - VS2022.sln"
if %ERRORLEVEL% == 0 (
echo:
echo ✅ Packages restored successfully!
) else (
echo:
echo ❌ Restore failed! Check the error messages above.
)
echo:
pause
cls
goto mainmenu
:: ===================================================================================================
:showsources
cls
echo ========================================================================
echo NuGet Package Sources
echo ========================================================================
echo:
echo Current NuGet sources:
echo:
dotnet nuget list source
echo:
echo To add a new source:
echo dotnet nuget add source [URL] --name [NAME]
echo:
echo To remove a source:
echo dotnet nuget remove source [NAME]
echo:
pause
cls
goto mainmenu
:: ===================================================================================================
:exit
echo:
echo Returning to main build system...
echo:
exit /b 0