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 ) {
@@ -110,8 +112,7 @@ function Find-LinkExe {
110
112
$linkexe = (Get-Location ).Path
111
113
Write-Verbose - Verbose " Using $linkexe "
112
114
$linkexe
113
- }
114
- finally {
115
+ } finally {
115
116
Pop-Location
116
117
}
117
118
}
@@ -131,8 +132,7 @@ if ($null -ne $packageType) {
131
132
if (! $IsWindows ) {
132
133
curl https:// sh.rustup.rs - sSf | sh - s -- - y
133
134
$env: PATH += " :$env: HOME /.cargo/bin"
134
- }
135
- else {
135
+ } else {
136
136
Invoke-WebRequest ' https://static.rust-lang.org/rustup/dist/i686-pc-windows-gnu/rustup-init.exe' - OutFile ' temp:/rustup-init.exe'
137
137
Write-Verbose - Verbose " Use the default settings to ensure build works"
138
138
& ' temp:/rustup-init.exe' - y
@@ -150,9 +150,9 @@ if (!$SkipBuild -and !$SkipLinkCheck -and $IsWindows -and !(Get-Command 'link.ex
150
150
if (! (Test-Path $BuildToolsPath )) {
151
151
Write-Verbose - Verbose " link.exe not found, installing C++ build tools"
152
152
Invoke-WebRequest ' https://aka.ms/vs/17/release/vs_BuildTools.exe' - OutFile ' temp:/vs_buildtools.exe'
153
- $arg = @ (' --passive' , ' --add' , ' Microsoft.VisualStudio.Workload.VCTools' , ' --includerecommended' )
153
+ $arg = @ (' --passive' , ' --add' , ' Microsoft.VisualStudio.Workload.VCTools' , ' --includerecommended' )
154
154
if ($env: PROCESSOR_ARCHITECTURE -eq ' ARM64' ) {
155
- $arg += ' --add' , ' Microsoft.VisualStudio.Component.VC.Tools.ARM64'
155
+ $arg += ' --add' , ' Microsoft.VisualStudio.Component.VC.Tools.ARM64'
156
156
}
157
157
Start-Process - FilePath ' temp:/vs_buildtools.exe' - ArgumentList $arg - Wait
158
158
Remove-Item temp:/ vs_installer.exe - ErrorAction Ignore
@@ -182,8 +182,7 @@ $flags = @($Release ? '-r' : $null)
182
182
if ($architecture -eq ' current' ) {
183
183
$path = " .\target\$configuration "
184
184
$target = Join-Path $PSScriptRoot ' bin' $configuration
185
- }
186
- else {
185
+ } else {
187
186
& $rustup target add $architecture
188
187
$flags += ' --target'
189
188
$flags += $architecture
@@ -223,8 +222,7 @@ if (!$SkipBuild) {
223
222
$env: CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
224
223
$env: CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = ' cargo:token'
225
224
}
226
- }
227
- else {
225
+ } else {
228
226
Write-Warning " Azure CLI not found, proceeding with anonymous access."
229
227
}
230
228
}
@@ -277,8 +275,7 @@ if (!$SkipBuild) {
277
275
if ($project -eq ' tree-sitter-dscexpression' ) {
278
276
if ($UpdateLockFile ) {
279
277
cargo generate- lockfile
280
- }
281
- else {
278
+ } else {
282
279
if ($Audit ) {
283
280
if ($null -eq (Get-Command cargo- audit - ErrorAction Ignore)) {
284
281
cargo install cargo- audit -- features= fix
@@ -291,26 +288,21 @@ if (!$SkipBuild) {
291
288
}
292
289
}
293
290
294
- if (Test-Path " ./Cargo.toml" )
295
- {
291
+ if (Test-Path " ./Cargo.toml" ) {
296
292
if ($Clippy ) {
297
293
if ($clippy_unclean_projects -contains $project ) {
298
294
Write-Verbose - Verbose " Skipping clippy for $project "
299
- }
300
- elseif ($pedantic_unclean_projects -contains $project ) {
295
+ } elseif ($pedantic_unclean_projects -contains $project ) {
301
296
Write-Verbose - Verbose " Running clippy for $project "
302
297
cargo clippy @flags -- - Dwarnings
303
- }
304
- else {
298
+ } else {
305
299
Write-Verbose - Verbose " Running clippy with pedantic for $project "
306
300
cargo clippy @flags --% -- -Dwarnings -Dclippy::pedantic
307
301
}
308
- }
309
- else {
302
+ } else {
310
303
if ($UpdateLockFile ) {
311
304
cargo generate- lockfile
312
- }
313
- else {
305
+ } else {
314
306
if ($Audit ) {
315
307
if ($null -eq (Get-Command cargo- audit - ErrorAction Ignore)) {
316
308
cargo install cargo- audit -- features= fix
@@ -333,8 +325,7 @@ if (!$SkipBuild) {
333
325
334
326
if ($IsWindows ) {
335
327
Copy-Item " $path /$binary .exe" $target - ErrorAction Ignore
336
- }
337
- else {
328
+ } else {
338
329
Copy-Item " $path /$binary " $target - ErrorAction Ignore
339
330
}
340
331
@@ -386,8 +377,7 @@ if (!$Clippy -and !$SkipBuild) {
386
377
$dirSeparator = [System.IO.Path ]::DirectorySeparatorChar
387
378
if ($Release ) {
388
379
$oldTarget = $target.Replace ($dirSeparator + ' release' , $dirSeparator + ' debug' )
389
- }
390
- else {
380
+ } else {
391
381
$oldTarget = $target.Replace ($dirSeparator + ' debug' , $dirSeparator + ' release' )
392
382
}
393
383
$env: PATH = $env: PATH.Replace ($oldTarget , ' ' )
@@ -426,15 +416,14 @@ if ($Test) {
426
416
427
417
if ($IsWindows ) {
428
418
# PSDesiredStateConfiguration module is needed for Microsoft.Windows/WindowsPowerShell adapter
429
- $FullyQualifiedName = @ {ModuleName = " PSDesiredStateConfiguration" ;ModuleVersion = " 2.0.7" }
430
- if (-not (Get-Module - ListAvailable - FullyQualifiedName $FullyQualifiedName ))
431
- {
419
+ $FullyQualifiedName = @ {ModuleName = " PSDesiredStateConfiguration" ; ModuleVersion = " 2.0.7" }
420
+ if (-not (Get-Module - ListAvailable - FullyQualifiedName $FullyQualifiedName )) {
432
421
Install-PSResource - Name PSDesiredStateConfiguration - Version 2.0 .7 - Repository $repository - TrustRepository
433
422
}
434
423
}
435
424
436
- if (-not (Get-Module - ListAvailable - Name Pester))
437
- { " Installing module Pester"
425
+ if (-not (Get-Module - ListAvailable - Name Pester)) {
426
+ " Installing module Pester"
438
427
Install-PSResource Pester - WarningAction Ignore - Repository $repository - TrustRepository
439
428
}
440
429
@@ -447,8 +436,7 @@ if ($Test) {
447
436
Write-Host - ForegroundColor Cyan " Testing $project ..."
448
437
try {
449
438
Push-Location " $PSScriptRoot /$project "
450
- if (Test-Path " ./Cargo.toml" )
451
- {
439
+ if (Test-Path " ./Cargo.toml" ) {
452
440
cargo test
453
441
454
442
if ($LASTEXITCODE -ne 0 ) {
@@ -477,8 +465,8 @@ if ($Test) {
477
465
" Updated PSModulePath is:"
478
466
$env: PSModulePath
479
467
480
- if (-not (Get-Module - ListAvailable - Name Pester))
481
- { " Installing module Pester"
468
+ if (-not (Get-Module - ListAvailable - Name Pester)) {
469
+ " Installing module Pester"
482
470
$InstallTargetDir = ($env: PSModulePath -split " ;" )[0 ]
483
471
Find-PSResource - Name ' Pester' - Repository $repository | Save-PSResource - Path $InstallTargetDir - TrustRepository
484
472
}
@@ -496,8 +484,7 @@ function Find-MakeAppx() {
496
484
# try to find
497
485
if (! $UseX64MakeAppx -and $architecture -eq ' aarch64-pc-windows-msvc' ) {
498
486
$arch = ' arm64'
499
- }
500
- else {
487
+ } else {
501
488
$arch = ' x64'
502
489
}
503
490
@@ -542,8 +529,7 @@ if ($packageType -eq 'msixbundle') {
542
529
Write-Verbose - Verbose " Preview version detected"
543
530
if ($isPrivate ) {
544
531
$productName += " -Private"
545
- }
546
- else {
532
+ } else {
547
533
$productName += " -Preview"
548
534
}
549
535
# save preview number
@@ -560,8 +546,7 @@ if ($packageType -eq 'msixbundle') {
560
546
561
547
if ($isPrivate ) {
562
548
$displayName += " -Private"
563
- }
564
- else {
549
+ } else {
565
550
$displayName += " -Preview"
566
551
}
567
552
}
@@ -705,4 +690,41 @@ if ($packageType -eq 'msixbundle') {
705
690
Write-Host - ForegroundColor Green " `n Gz file is created at $gzFile "
706
691
}
707
692
708
- $env: RUST_BACKTRACE = 1
693
+ function Submit-DSCWinGetAssets {
694
+ param (
695
+ [string ]$GitToken
696
+ )
697
+
698
+ $project = ' PowerShell/DSC'
699
+ # TODO: Package identifier might change in the future
700
+ $packageId = ' Microsoft.DSC.Preview'
701
+ $restParameters = @ {
702
+ SslProtocol = ' Tls13'
703
+ Headers = @ {' X-GitHub-Api-Version' = ' 2022-11-28' }
704
+ }
705
+
706
+ $assets = (Invoke-RestMethod - uri " https://api.github.com/repos/$Project /releases" - Headers $restParameters )[0 ].assets # Get the latest version
707
+ # Grab the download URLs for supported WinGet
708
+ $downloadUrls = $assets.Where ({ $_.content_type -in @ (' application/zip' , ' application/octet-stream' ) }).browser_download_url
709
+
710
+ if (-not (Get-Command wingetcreate - ErrorAction SilentlyContinue)) {
711
+ Invoke-RestMethod https:// aka.ms/ wingetcreate/ latest - OutFile wingetcreate.exe
712
+ }
713
+
714
+ # TODO: Version number might change in the future
715
+ $url = $downloadUrls [0 ]
716
+ if ($url -match ' v(\d+\.\d+\.\d+)-preview\.(\d+)' ) {
717
+ $firstPart = $matches [1 ].Remove(3 ) # Remove the last digit
718
+ $lastPart = $matches [2 ] + " .0"
719
+ $version = " $firstPart .$lastPart "
720
+ }
721
+
722
+
723
+ & wingetcreate.exe update $packageId -- version $version -- urls $downloadUrls -- submit -- token $GitToken
724
+ }
725
+
726
+ if ($SubmitWinGetManifest ) {
727
+ Submit-DSCWinGetAssets - GitToken $GitToken
728
+ }
729
+
730
+ $env: RUST_BACKTRACE = 1
0 commit comments