@@ -11,29 +11,10 @@ $global:BUILD_VERSION = $buildVersion
11
11
$global :ERROR_CODE = 0
12
12
$global :FAILED_PROJECTS = @ ()
13
13
14
- function Install-Packages {
15
- param (
16
- [string ]$folderName ,
17
- [string []]$packages ,
18
- [string ]$buildVersion
19
- )
20
-
21
- Write-Output " `n Installing packages in folder: $folderName "
22
-
23
- # Loop through each package and install it individually
24
- foreach ($package in $packages ) {
25
- $packageVersion = Get-ValidNpmVersion - PackageName $package - Version $buildVersion
26
- $packageWithVersion = " $package @$packageVersion "
27
- Write-Output " Installing $packageWithVersion ..."
28
-
29
- npm install -- save -- save-exact -- no- fund -- loglevel= error -- force $packageWithVersion
30
- if (-not $? ) {
31
- Write-Error " `n ERROR: Failed to install $packageWithVersion in $folderName "
32
- throw " Installation failed for $packageWithVersion in $folderName "
33
- }
34
- }
35
-
36
- Write-Output " `n All packages installed successfully in $folderName "
14
+ function Test-NpmVersionExists {
15
+ param ([string ]$Pkg , [string ]$Ver )
16
+ npm view " $Pkg @$Ver " > $null 2>&1
17
+ return ($LASTEXITCODE -eq 0 )
37
18
}
38
19
39
20
function Get-ValidNpmVersion {
@@ -42,12 +23,6 @@ function Get-ValidNpmVersion {
42
23
[string ]$Version
43
24
)
44
25
45
- function Test-NpmVersionExists {
46
- param ([string ]$Pkg , [string ]$Ver )
47
- npm view " $Pkg @$Ver " > $null 2>&1
48
- return ($LASTEXITCODE -eq 0 )
49
- }
50
-
51
26
Write-Host " Checking $PackageName @$Version ..."
52
27
if (Test-NpmVersionExists - Pkg $PackageName - Ver $Version ) {
53
28
Write-Host " $PackageName @$Version exists."
@@ -72,12 +47,36 @@ function Get-ValidNpmVersion {
72
47
return $null
73
48
}
74
49
50
+ function Install-Packages {
51
+ param (
52
+ [string ]$folderName ,
53
+ [string []]$packages ,
54
+ [string ]$buildVersion
55
+ )
56
+
57
+ Write-Output " `n Installing packages in folder: $folderName "
58
+
59
+ foreach ($package in $packages ) {
60
+ $packageVersion = Get-ValidNpmVersion - PackageName $package - Version $buildVersion
61
+ $packageWithVersion = " $package @$packageVersion "
62
+ Write-Output " Installing $packageWithVersion ..."
63
+
64
+ npm install -- save -- save-exact -- no- fund -- loglevel= error -- force $packageWithVersion
65
+ if (-not $? ) {
66
+ Write-Error " `n ERROR: Failed to install $packageWithVersion in $folderName "
67
+ throw " Installation failed for $packageWithVersion in $folderName "
68
+ }
69
+ }
70
+
71
+ Write-Output " `n All packages installed successfully in $folderName "
72
+ }
73
+
75
74
function Build-Project {
76
75
param (
77
76
[string ]$folderName
78
77
)
79
78
Write-Output " `n Building the project in folder: $folderName "
80
-
79
+
81
80
npm run build
82
81
if (-not $? ) {
83
82
Write-Error " `n ERROR: Failed to build the project in $folderName "
@@ -99,7 +98,7 @@ function Process-JavaScriptProjects {
99
98
100
99
$jQueryEntry = @ {
101
100
Name = " jQuery" ;
102
- Packages = if ([version ]$buildVersion -ge [version ]23.1 ) { # `devextreme-dist` appeared in 23.1
101
+ Packages = if ([version ]$buildVersion -ge [version ]23.1 ) {
103
102
@ (" devextreme" , " devextreme-dist" )
104
103
} else {
105
104
@ (" devextreme" )
@@ -144,56 +143,140 @@ function Process-JavaScriptProjects {
144
143
Write-Output " `n --== JavaScript Projects Processing Completed ==--"
145
144
}
146
145
147
- function Process-DotNetProjects {
146
+ function Resolve-NuGetVersionWithFallback {
148
147
param (
149
- [string ]$RootDirectory = " ."
148
+ [string ]$PackageName ,
149
+ [string ]$RequestedVersion
150
150
)
151
151
152
- Write-Output " `n --== Starting .NET project processing in directory: $RootDirectory ==--"
152
+ function Test-PackageAvailable {
153
+ param ([string ]$name , [string ]$ver )
154
+ dotnet add package $name -- version $ver > $null 2>&1
155
+ return ($LASTEXITCODE -eq 0 )
156
+ }
157
+
158
+ if (Test-PackageAvailable - name $PackageName - ver $RequestedVersion ) {
159
+ Write-Host " $PackageName @$RequestedVersion is available."
160
+ return $RequestedVersion
161
+ }
162
+
163
+ Write-Host " $PackageName @$RequestedVersion not found. Checking for -beta and -alpha versions..."
153
164
154
- $slnFiles = Get-ChildItem - Path $RootDirectory - Filter * .sln - Recurse - Depth 1
165
+ $suffixes = @ (" beta" , " alpha" )
166
+ foreach ($suffix in $suffixes ) {
167
+ $fallbackVersion = " $RequestedVersion -$suffix "
168
+ if (Test-PackageAvailable - name $PackageName - ver $fallbackVersion ) {
169
+ Write-Host " Found $PackageName @$fallbackVersion "
170
+ return $fallbackVersion
171
+ }
172
+ }
155
173
156
- if ($slnFiles.Count -eq 0 ) {
157
- Write-Output " `n No solution files (.sln) found in the specified directory at level 1."
174
+ Write-Warning " No matching versions found for $PackageName @$RequestedVersion "
175
+ return $null
176
+ }
177
+
178
+ function Process-AspNetCoreProject {
179
+ param (
180
+ [Parameter (Mandatory = $true )]
181
+ [string ]$buildVersion
182
+ )
183
+
184
+ $folderPath = Get-ChildItem - Directory |
185
+ Where-Object { $_.Name -match ' (?i)^ASP\.NET\s*Core$' } |
186
+ Select-Object - First 1 - ExpandProperty FullName
187
+
188
+ if (-not $folderPath ) {
189
+ Write-Error " Directory matching 'ASP.NET Core' not found."
158
190
return
159
191
}
160
192
161
- foreach ($slnFile in $slnFiles ) {
162
- Write-Output " `n Found solution file: $ ( $slnFile.FullName ) "
163
-
164
- try {
165
- Write-Output " `n Building solution: $ ( $slnFile.FullName ) "
166
- dotnet build $slnFile.FullName - c Release
193
+ Write-Host " Found project directory: $folderPath "
194
+ Push-Location $folderPath
195
+
196
+ try {
197
+ $resolvedNugetVersion = Resolve-NuGetVersionWithFallback - PackageName " DevExtreme.AspNet.Core" - RequestedVersion $buildVersion
198
+ if (-not $resolvedNugetVersion ) {
199
+ throw " No valid version found for DevExtreme.AspNet.Core"
200
+ }
167
201
168
- if ($? ) {
169
- Write-Output " `n Build succeeded for $ ( $slnFile.FullName ) ."
170
- } else {
171
- throw " Build failed for $ ( $slnFile.FullName ) ."
202
+ Write-Host " Installing DevExtreme.AspNet.Core@$resolvedNugetVersion ..."
203
+ dotnet add package DevExtreme.AspNet.Core -- version $resolvedNugetVersion
204
+
205
+ $packageJsonPath = Get-ChildItem - Path $folderPath - Filter " package.json" - Recurse - File - ErrorAction SilentlyContinue |
206
+ Select-Object - First 1 - ExpandProperty FullName
207
+
208
+ if ($packageJsonPath ) {
209
+ Write-Host " Found package.json: $packageJsonPath "
210
+
211
+ try {
212
+ $packageJson = Get-Content - Path $packageJsonPath - Raw | ConvertFrom-Json
213
+ $updated = $false
214
+
215
+ if ($packageJson.dependencies.devextreme ) {
216
+ $validDevextremeVersion = Get-ValidNpmVersion - PackageName " devextreme" - Version $buildVersion
217
+ if ($validDevextremeVersion ) {
218
+ $packageJson.dependencies.devextreme = $validDevextremeVersion
219
+ $updated = $true
220
+ }
221
+ }
222
+
223
+ if ($packageJson.dependencies .' devextreme-dist' ) {
224
+ $validDevextremeDistVersion = Get-ValidNpmVersion - PackageName " devextreme-dist" - Version $buildVersion
225
+ if ($validDevextremeDistVersion ) {
226
+ $packageJson.dependencies .' devextreme-dist' = $validDevextremeDistVersion
227
+ $updated = $true
228
+ }
229
+ }
230
+
231
+ if ($updated ) {
232
+ $packageJson | ConvertTo-Json - Depth 10 | Set-Content - Path $packageJsonPath - Encoding UTF8
233
+ Write-Host " Updated package.json with valid versions."
234
+ } else {
235
+ Write-Host " No matching dependencies found in package.json to update."
236
+ }
237
+
238
+ Write-Host " Installing NPM dependencies..."
239
+ npm install -- save -- save-exact -- no- fund -- loglevel= error
240
+ if (-not $? ) {
241
+ throw " Failed to install npm dependencies"
242
+ }
243
+ } catch {
244
+ Write-Error " Failed to update package.json: $_ "
172
245
}
173
- } catch {
174
- Write-Error " `n ERROR: $_ "
175
- $global :LASTEXITCODE = 1
176
- $global :ERROR_CODE = 1
177
- $global :FAILED_PROJECTS += " ASP.NET"
246
+ } else {
247
+ Write-Warning " No package.json file found in '$folderPath '."
178
248
}
179
- }
180
249
181
- Write-Output " `n Completed .NET project processing."
250
+ Write-Host " Running dotnet build..."
251
+ dotnet build
252
+ if ($LASTEXITCODE -eq 0 ) {
253
+ Write-Host " Build succeeded."
254
+ } else {
255
+ throw
256
+ }
257
+ } catch {
258
+ Write-Error " An error occurred: $_ "
259
+ $global :LASTEXITCODE = 1
260
+ $global :ERROR_CODE = 1
261
+ $global :FAILED_PROJECTS += " ASP.NET Core"
262
+ } finally {
263
+ Pop-Location
264
+ }
182
265
}
183
266
184
267
function Write-BuildInfo {
185
- $BUILD_VERSION = if ($global :BUILD_VERSION -ne $null -and $global :BUILD_VERSION -ne " " ) {
186
- $global :BUILD_VERSION
187
- } else {
188
- " (empty)"
268
+ $BUILD_VERSION = if ($global :BUILD_VERSION -ne $null -and $global :BUILD_VERSION -ne " " ) {
269
+ $global :BUILD_VERSION
270
+ } else {
271
+ " (empty)"
189
272
}
190
273
191
274
Write-Output " Build Version: $BUILD_VERSION "
192
275
}
193
276
194
277
Write-BuildInfo
195
278
Process - JavaScriptProjects - buildVersion $global :BUILD_VERSION
196
- Process - DotNetProjects
279
+ Process - AspNetCoreProject - buildVersion $ global :BUILD_VERSION
197
280
198
281
Write-Output " `n Finished testing version: $global :BUILD_VERSION . Error code: $global :ERROR_CODE "
199
282
if ($global :ERROR_CODE -ne 0 -and $global :FAILED_PROJECTS.Count -gt 0 ) {
0 commit comments