33
44param (
55 [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' )]
77 $architecture = ' current' ,
88 [switch ]$Clippy ,
99 [switch ]$SkipBuild ,
10- [ValidateSet (' msix' , ' msix-private' , ' msixbundle' , ' tgz' , ' zip' )]
10+ [ValidateSet (' msix' , ' msix-private' , ' msixbundle' , ' tgz' , ' zip' )]
1111 $packageType ,
1212 [switch ]$Test ,
1313 [switch ]$GetPackageVersion ,
1616 [switch ]$UseCratesIO ,
1717 [switch ]$UpdateLockFile ,
1818 [switch ]$Audit ,
19- [switch ]$UseCFSAuth
19+ [switch ]$UseCFSAuth ,
20+ [switch ]$SubmitWinGetManifest ,
21+ [string ]$GitToken
2022)
2123
2224if ($GetPackageVersion ) {
@@ -110,8 +112,7 @@ function Find-LinkExe {
110112 $linkexe = (Get-Location ).Path
111113 Write-Verbose - Verbose " Using $linkexe "
112114 $linkexe
113- }
114- finally {
115+ } finally {
115116 Pop-Location
116117 }
117118}
@@ -131,8 +132,7 @@ if ($null -ne $packageType) {
131132 if (! $IsWindows ) {
132133 curl https:// sh.rustup.rs - sSf | sh - s -- - y
133134 $env: PATH += " :$env: HOME /.cargo/bin"
134- }
135- else {
135+ } else {
136136 Invoke-WebRequest ' https://static.rust-lang.org/rustup/dist/i686-pc-windows-gnu/rustup-init.exe' - OutFile ' temp:/rustup-init.exe'
137137 Write-Verbose - Verbose " Use the default settings to ensure build works"
138138 & ' temp:/rustup-init.exe' - y
@@ -150,9 +150,9 @@ if (!$SkipBuild -and !$SkipLinkCheck -and $IsWindows -and !(Get-Command 'link.ex
150150 if (! (Test-Path $BuildToolsPath )) {
151151 Write-Verbose - Verbose " link.exe not found, installing C++ build tools"
152152 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' )
154154 if ($env: PROCESSOR_ARCHITECTURE -eq ' ARM64' ) {
155- $arg += ' --add' , ' Microsoft.VisualStudio.Component.VC.Tools.ARM64'
155+ $arg += ' --add' , ' Microsoft.VisualStudio.Component.VC.Tools.ARM64'
156156 }
157157 Start-Process - FilePath ' temp:/vs_buildtools.exe' - ArgumentList $arg - Wait
158158 Remove-Item temp:/ vs_installer.exe - ErrorAction Ignore
@@ -182,8 +182,7 @@ $flags = @($Release ? '-r' : $null)
182182if ($architecture -eq ' current' ) {
183183 $path = " .\target\$configuration "
184184 $target = Join-Path $PSScriptRoot ' bin' $configuration
185- }
186- else {
185+ } else {
187186 & $rustup target add $architecture
188187 $flags += ' --target'
189188 $flags += $architecture
@@ -223,8 +222,7 @@ if (!$SkipBuild) {
223222 $env: CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
224223 $env: CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = ' cargo:token'
225224 }
226- }
227- else {
225+ } else {
228226 Write-Warning " Azure CLI not found, proceeding with anonymous access."
229227 }
230228 }
@@ -277,8 +275,7 @@ if (!$SkipBuild) {
277275 if ($project -eq ' tree-sitter-dscexpression' ) {
278276 if ($UpdateLockFile ) {
279277 cargo generate- lockfile
280- }
281- else {
278+ } else {
282279 if ($Audit ) {
283280 if ($null -eq (Get-Command cargo- audit - ErrorAction Ignore)) {
284281 cargo install cargo- audit -- features= fix
@@ -291,26 +288,21 @@ if (!$SkipBuild) {
291288 }
292289 }
293290
294- if (Test-Path " ./Cargo.toml" )
295- {
291+ if (Test-Path " ./Cargo.toml" ) {
296292 if ($Clippy ) {
297293 if ($clippy_unclean_projects -contains $project ) {
298294 Write-Verbose - Verbose " Skipping clippy for $project "
299- }
300- elseif ($pedantic_unclean_projects -contains $project ) {
295+ } elseif ($pedantic_unclean_projects -contains $project ) {
301296 Write-Verbose - Verbose " Running clippy for $project "
302297 cargo clippy @flags -- - Dwarnings
303- }
304- else {
298+ } else {
305299 Write-Verbose - Verbose " Running clippy with pedantic for $project "
306300 cargo clippy @flags --% -- -Dwarnings -Dclippy::pedantic
307301 }
308- }
309- else {
302+ } else {
310303 if ($UpdateLockFile ) {
311304 cargo generate- lockfile
312- }
313- else {
305+ } else {
314306 if ($Audit ) {
315307 if ($null -eq (Get-Command cargo- audit - ErrorAction Ignore)) {
316308 cargo install cargo- audit -- features= fix
@@ -333,8 +325,7 @@ if (!$SkipBuild) {
333325
334326 if ($IsWindows ) {
335327 Copy-Item " $path /$binary .exe" $target - ErrorAction Ignore
336- }
337- else {
328+ } else {
338329 Copy-Item " $path /$binary " $target - ErrorAction Ignore
339330 }
340331
@@ -386,8 +377,7 @@ if (!$Clippy -and !$SkipBuild) {
386377 $dirSeparator = [System.IO.Path ]::DirectorySeparatorChar
387378 if ($Release ) {
388379 $oldTarget = $target.Replace ($dirSeparator + ' release' , $dirSeparator + ' debug' )
389- }
390- else {
380+ } else {
391381 $oldTarget = $target.Replace ($dirSeparator + ' debug' , $dirSeparator + ' release' )
392382 }
393383 $env: PATH = $env: PATH.Replace ($oldTarget , ' ' )
@@ -426,15 +416,14 @@ if ($Test) {
426416
427417 if ($IsWindows ) {
428418 # 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 )) {
432421 Install-PSResource - Name PSDesiredStateConfiguration - Version 2.0 .7 - Repository $repository - TrustRepository
433422 }
434423 }
435424
436- if (-not (Get-Module - ListAvailable - Name Pester))
437- { " Installing module Pester"
425+ if (-not (Get-Module - ListAvailable - Name Pester)) {
426+ " Installing module Pester"
438427 Install-PSResource Pester - WarningAction Ignore - Repository $repository - TrustRepository
439428 }
440429
@@ -447,8 +436,7 @@ if ($Test) {
447436 Write-Host - ForegroundColor Cyan " Testing $project ..."
448437 try {
449438 Push-Location " $PSScriptRoot /$project "
450- if (Test-Path " ./Cargo.toml" )
451- {
439+ if (Test-Path " ./Cargo.toml" ) {
452440 cargo test
453441
454442 if ($LASTEXITCODE -ne 0 ) {
@@ -477,8 +465,8 @@ if ($Test) {
477465 " Updated PSModulePath is:"
478466 $env: PSModulePath
479467
480- if (-not (Get-Module - ListAvailable - Name Pester))
481- { " Installing module Pester"
468+ if (-not (Get-Module - ListAvailable - Name Pester)) {
469+ " Installing module Pester"
482470 $InstallTargetDir = ($env: PSModulePath -split " ;" )[0 ]
483471 Find-PSResource - Name ' Pester' - Repository $repository | Save-PSResource - Path $InstallTargetDir - TrustRepository
484472 }
@@ -496,8 +484,7 @@ function Find-MakeAppx() {
496484 # try to find
497485 if (! $UseX64MakeAppx -and $architecture -eq ' aarch64-pc-windows-msvc' ) {
498486 $arch = ' arm64'
499- }
500- else {
487+ } else {
501488 $arch = ' x64'
502489 }
503490
@@ -542,8 +529,7 @@ if ($packageType -eq 'msixbundle') {
542529 Write-Verbose - Verbose " Preview version detected"
543530 if ($isPrivate ) {
544531 $productName += " -Private"
545- }
546- else {
532+ } else {
547533 $productName += " -Preview"
548534 }
549535 # save preview number
@@ -560,8 +546,7 @@ if ($packageType -eq 'msixbundle') {
560546
561547 if ($isPrivate ) {
562548 $displayName += " -Private"
563- }
564- else {
549+ } else {
565550 $displayName += " -Preview"
566551 }
567552 }
@@ -705,4 +690,41 @@ if ($packageType -eq 'msixbundle') {
705690 Write-Host - ForegroundColor Green " `n Gz file is created at $gzFile "
706691}
707692
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