3
3
4
4
param (
5
5
[switch ]$Release ,
6
- [ValidateSet (' current' , ' aarch64-pc-windows-msvc' , ' x86_64-pc-windows-msvc' , ' aarch64-apple-darwin' , ' x86_64-apple-darwin' , ' aarch64-unknown-linux-gnu' , ' aarch64-unknown-linux-musl' , ' x86_64-unknown-linux-gnu' , ' x86_64-unknown-linux-musl' )]
6
+ [ValidateSet (' current' , ' aarch64-pc-windows-msvc' , ' x86_64-pc-windows-msvc' , ' aarch64-apple-darwin' , ' x86_64-apple-darwin' , ' aarch64-unknown-linux-gnu' , ' aarch64-unknown-linux-musl' , ' x86_64-unknown-linux-gnu' , ' x86_64-unknown-linux-musl' )]
7
7
$architecture = ' current' ,
8
8
[switch ]$Clippy ,
9
9
[switch ]$SkipBuild ,
10
- [ValidateSet (' msix' , ' msix-private' , ' msixbundle' , ' tgz' , ' zip' )]
10
+ [ValidateSet (' msix' , ' msix-private' , ' msixbundle' , ' tgz' , ' zip' )]
11
11
$packageType ,
12
12
[switch ]$Test ,
13
13
[switch ]$GetPackageVersion ,
16
16
[switch ]$UseCratesIO ,
17
17
[switch ]$UpdateLockFile ,
18
18
[switch ]$Audit ,
19
- [switch ]$UseCFSAuth
19
+ [switch ]$UseCFSAuth ,
20
+ [switch ]$SubmitWinGetManifest ,
21
+ [string ]$GitToken
20
22
)
21
23
22
24
if ($GetPackageVersion ) {
@@ -107,8 +109,7 @@ function Find-LinkExe {
107
109
$linkexe = (Get-Location ).Path
108
110
Write-Verbose - Verbose " Using $linkexe "
109
111
$linkexe
110
- }
111
- finally {
112
+ } finally {
112
113
Pop-Location
113
114
}
114
115
}
@@ -128,8 +129,7 @@ if ($null -ne $packageType) {
128
129
if (! $IsWindows ) {
129
130
curl https:// sh.rustup.rs - sSf | sh - s -- - y
130
131
$env: PATH += " :$env: HOME /.cargo/bin"
131
- }
132
- else {
132
+ } else {
133
133
Invoke-WebRequest ' https://static.rust-lang.org/rustup/dist/i686-pc-windows-gnu/rustup-init.exe' - OutFile ' temp:/rustup-init.exe'
134
134
Write-Verbose - Verbose " Use the default settings to ensure build works"
135
135
& ' temp:/rustup-init.exe' - y
@@ -147,9 +147,9 @@ if (!$SkipBuild -and !$SkipLinkCheck -and $IsWindows -and !(Get-Command 'link.ex
147
147
if (! (Test-Path $BuildToolsPath )) {
148
148
Write-Verbose - Verbose " link.exe not found, installing C++ build tools"
149
149
Invoke-WebRequest ' https://aka.ms/vs/17/release/vs_BuildTools.exe' - OutFile ' temp:/vs_buildtools.exe'
150
- $arg = @ (' --passive' , ' --add' , ' Microsoft.VisualStudio.Workload.VCTools' , ' --includerecommended' )
150
+ $arg = @ (' --passive' , ' --add' , ' Microsoft.VisualStudio.Workload.VCTools' , ' --includerecommended' )
151
151
if ($env: PROCESSOR_ARCHITECTURE -eq ' ARM64' ) {
152
- $arg += ' --add' , ' Microsoft.VisualStudio.Component.VC.Tools.ARM64'
152
+ $arg += ' --add' , ' Microsoft.VisualStudio.Component.VC.Tools.ARM64'
153
153
}
154
154
Start-Process - FilePath ' temp:/vs_buildtools.exe' - ArgumentList $arg - Wait
155
155
Remove-Item temp:/ vs_installer.exe - ErrorAction Ignore
@@ -179,8 +179,7 @@ $flags = @($Release ? '-r' : $null)
179
179
if ($architecture -eq ' current' ) {
180
180
$path = " .\target\$configuration "
181
181
$target = Join-Path $PSScriptRoot ' bin' $configuration
182
- }
183
- else {
182
+ } else {
184
183
& $rustup target add $architecture
185
184
$flags += ' --target'
186
185
$flags += $architecture
@@ -220,8 +219,7 @@ if (!$SkipBuild) {
220
219
$env: CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
221
220
$env: CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = ' cargo:token'
222
221
}
223
- }
224
- else {
222
+ } else {
225
223
Write-Warning " Azure CLI not found, proceeding with anonymous access."
226
224
}
227
225
}
@@ -274,8 +272,7 @@ if (!$SkipBuild) {
274
272
if ($project -eq ' tree-sitter-dscexpression' ) {
275
273
if ($UpdateLockFile ) {
276
274
cargo generate- lockfile
277
- }
278
- else {
275
+ } else {
279
276
if ($Audit ) {
280
277
if ($null -eq (Get-Command cargo- audit - ErrorAction Ignore)) {
281
278
cargo install cargo- audit -- features= fix
@@ -288,26 +285,21 @@ if (!$SkipBuild) {
288
285
}
289
286
}
290
287
291
- if (Test-Path " ./Cargo.toml" )
292
- {
288
+ if (Test-Path " ./Cargo.toml" ) {
293
289
if ($Clippy ) {
294
290
if ($clippy_unclean_projects -contains $project ) {
295
291
Write-Verbose - Verbose " Skipping clippy for $project "
296
- }
297
- elseif ($pedantic_unclean_projects -contains $project ) {
292
+ } elseif ($pedantic_unclean_projects -contains $project ) {
298
293
Write-Verbose - Verbose " Running clippy for $project "
299
294
cargo clippy @flags -- - Dwarnings
300
- }
301
- else {
295
+ } else {
302
296
Write-Verbose - Verbose " Running clippy with pedantic for $project "
303
297
cargo clippy @flags --% -- -Dwarnings -Dclippy::pedantic
304
298
}
305
- }
306
- else {
299
+ } else {
307
300
if ($UpdateLockFile ) {
308
301
cargo generate- lockfile
309
- }
310
- else {
302
+ } else {
311
303
if ($Audit ) {
312
304
if ($null -eq (Get-Command cargo- audit - ErrorAction Ignore)) {
313
305
cargo install cargo- audit -- features= fix
@@ -330,8 +322,7 @@ if (!$SkipBuild) {
330
322
331
323
if ($IsWindows ) {
332
324
Copy-Item " $path /$binary .exe" $target - ErrorAction Ignore
333
- }
334
- else {
325
+ } else {
335
326
Copy-Item " $path /$binary " $target - ErrorAction Ignore
336
327
}
337
328
@@ -383,8 +374,7 @@ if (!$Clippy -and !$SkipBuild) {
383
374
$dirSeparator = [System.IO.Path ]::DirectorySeparatorChar
384
375
if ($Release ) {
385
376
$oldTarget = $target.Replace ($dirSeparator + ' release' , $dirSeparator + ' debug' )
386
- }
387
- else {
377
+ } else {
388
378
$oldTarget = $target.Replace ($dirSeparator + ' debug' , $dirSeparator + ' release' )
389
379
}
390
380
$env: PATH = $env: PATH.Replace ($oldTarget , ' ' )
@@ -423,15 +413,14 @@ if ($Test) {
423
413
424
414
if ($IsWindows ) {
425
415
# PSDesiredStateConfiguration module is needed for Microsoft.Windows/WindowsPowerShell adapter
426
- $FullyQualifiedName = @ {ModuleName = " PSDesiredStateConfiguration" ;ModuleVersion = " 2.0.7" }
427
- if (-not (Get-Module - ListAvailable - FullyQualifiedName $FullyQualifiedName ))
428
- {
416
+ $FullyQualifiedName = @ {ModuleName = " PSDesiredStateConfiguration" ; ModuleVersion = " 2.0.7" }
417
+ if (-not (Get-Module - ListAvailable - FullyQualifiedName $FullyQualifiedName )) {
429
418
Install-PSResource - Name PSDesiredStateConfiguration - Version 2.0 .7 - Repository $repository - TrustRepository
430
419
}
431
420
}
432
421
433
- if (-not (Get-Module - ListAvailable - Name Pester))
434
- { " Installing module Pester"
422
+ if (-not (Get-Module - ListAvailable - Name Pester)) {
423
+ " Installing module Pester"
435
424
Install-PSResource Pester - WarningAction Ignore - Repository $repository - TrustRepository
436
425
}
437
426
@@ -444,8 +433,7 @@ if ($Test) {
444
433
Write-Host - ForegroundColor Cyan " Testing $project ..."
445
434
try {
446
435
Push-Location " $PSScriptRoot /$project "
447
- if (Test-Path " ./Cargo.toml" )
448
- {
436
+ if (Test-Path " ./Cargo.toml" ) {
449
437
cargo test
450
438
451
439
if ($LASTEXITCODE -ne 0 ) {
@@ -474,8 +462,8 @@ if ($Test) {
474
462
" Updated PSModulePath is:"
475
463
$env: PSModulePath
476
464
477
- if (-not (Get-Module - ListAvailable - Name Pester))
478
- { " Installing module Pester"
465
+ if (-not (Get-Module - ListAvailable - Name Pester)) {
466
+ " Installing module Pester"
479
467
$InstallTargetDir = ($env: PSModulePath -split " ;" )[0 ]
480
468
Find-PSResource - Name ' Pester' - Repository $repository | Save-PSResource - Path $InstallTargetDir - TrustRepository
481
469
}
@@ -493,8 +481,7 @@ function Find-MakeAppx() {
493
481
# try to find
494
482
if (! $UseX64MakeAppx -and $architecture -eq ' aarch64-pc-windows-msvc' ) {
495
483
$arch = ' arm64'
496
- }
497
- else {
484
+ } else {
498
485
$arch = ' x64'
499
486
}
500
487
@@ -539,8 +526,7 @@ if ($packageType -eq 'msixbundle') {
539
526
Write-Verbose - Verbose " Preview version detected"
540
527
if ($isPrivate ) {
541
528
$productName += " -Private"
542
- }
543
- else {
529
+ } else {
544
530
$productName += " -Preview"
545
531
}
546
532
# save preview number
@@ -552,8 +538,7 @@ if ($packageType -eq 'msixbundle') {
552
538
553
539
if ($isPrivate ) {
554
540
$displayName += " -Private"
555
- }
556
- else {
541
+ } else {
557
542
$displayName += " -Preview"
558
543
}
559
544
}
@@ -697,4 +682,41 @@ if ($packageType -eq 'msixbundle') {
697
682
Write-Host - ForegroundColor Green " `n Gz file is created at $gzFile "
698
683
}
699
684
700
- $env: RUST_BACKTRACE = 1
685
+ function Submit-DSCWinGetAssets {
686
+ param (
687
+ [string ]$GitToken
688
+ )
689
+
690
+ $project = ' PowerShell/DSC'
691
+ # TODO: Package identifier might change in the future
692
+ $packageId = ' Microsoft.DSC.Preview'
693
+ $restParameters = @ {
694
+ SslProtocol = ' Tls13'
695
+ Headers = @ {' X-GitHub-Api-Version' = ' 2022-11-28' }
696
+ }
697
+
698
+ $assets = (Invoke-RestMethod - uri " https://api.github.com/repos/$Project /releases" - Headers $restParameters )[0 ].assets # Get the latest version
699
+ # Grab the download URLs for supported WinGet
700
+ $downloadUrls = $assets.Where ({ $_.content_type -in @ (' application/zip' , ' application/octet-stream' ) }).browser_download_url
701
+
702
+ if (-not (Get-Command wingetcreate - ErrorAction SilentlyContinue)) {
703
+ Invoke-RestMethod https:// aka.ms/ wingetcreate/ latest - OutFile wingetcreate.exe
704
+ }
705
+
706
+ # TODO: Version number might change in the future
707
+ $url = $downloadUrls [0 ]
708
+ if ($url -match ' v(\d+\.\d+\.\d+)-preview\.(\d+)' ) {
709
+ $firstPart = $matches [1 ].Remove(3 ) # Remove the last digit
710
+ $lastPart = $matches [2 ] + " .0"
711
+ $version = " $firstPart .$lastPart "
712
+ }
713
+
714
+
715
+ & wingetcreate.exe update $packageId -- version $version -- urls $downloadUrls -- submit -- token $GitToken
716
+ }
717
+
718
+ if ($SubmitWinGetManifest ) {
719
+ Submit-DSCWinGetAssets - GitToken $GitToken
720
+ }
721
+
722
+ $env: RUST_BACKTRACE = 1
0 commit comments