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 ) {
@@ -107,8 +109,7 @@ function Find-LinkExe {
107109 $linkexe = (Get-Location ).Path
108110 Write-Verbose - Verbose " Using $linkexe "
109111 $linkexe
110- }
111- finally {
112+ } finally {
112113 Pop-Location
113114 }
114115}
@@ -128,8 +129,7 @@ if ($null -ne $packageType) {
128129 if (! $IsWindows ) {
129130 curl https:// sh.rustup.rs - sSf | sh - s -- - y
130131 $env: PATH += " :$env: HOME /.cargo/bin"
131- }
132- else {
132+ } else {
133133 Invoke-WebRequest ' https://static.rust-lang.org/rustup/dist/i686-pc-windows-gnu/rustup-init.exe' - OutFile ' temp:/rustup-init.exe'
134134 Write-Verbose - Verbose " Use the default settings to ensure build works"
135135 & ' temp:/rustup-init.exe' - y
@@ -147,9 +147,9 @@ if (!$SkipBuild -and !$SkipLinkCheck -and $IsWindows -and !(Get-Command 'link.ex
147147 if (! (Test-Path $BuildToolsPath )) {
148148 Write-Verbose - Verbose " link.exe not found, installing C++ build tools"
149149 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' )
151151 if ($env: PROCESSOR_ARCHITECTURE -eq ' ARM64' ) {
152- $arg += ' --add' , ' Microsoft.VisualStudio.Component.VC.Tools.ARM64'
152+ $arg += ' --add' , ' Microsoft.VisualStudio.Component.VC.Tools.ARM64'
153153 }
154154 Start-Process - FilePath ' temp:/vs_buildtools.exe' - ArgumentList $arg - Wait
155155 Remove-Item temp:/ vs_installer.exe - ErrorAction Ignore
@@ -179,8 +179,7 @@ $flags = @($Release ? '-r' : $null)
179179if ($architecture -eq ' current' ) {
180180 $path = " .\target\$configuration "
181181 $target = Join-Path $PSScriptRoot ' bin' $configuration
182- }
183- else {
182+ } else {
184183 & $rustup target add $architecture
185184 $flags += ' --target'
186185 $flags += $architecture
@@ -220,8 +219,7 @@ if (!$SkipBuild) {
220219 $env: CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
221220 $env: CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = ' cargo:token'
222221 }
223- }
224- else {
222+ } else {
225223 Write-Warning " Azure CLI not found, proceeding with anonymous access."
226224 }
227225 }
@@ -274,8 +272,7 @@ if (!$SkipBuild) {
274272 if ($project -eq ' tree-sitter-dscexpression' ) {
275273 if ($UpdateLockFile ) {
276274 cargo generate- lockfile
277- }
278- else {
275+ } else {
279276 if ($Audit ) {
280277 if ($null -eq (Get-Command cargo- audit - ErrorAction Ignore)) {
281278 cargo install cargo- audit -- features= fix
@@ -288,26 +285,21 @@ if (!$SkipBuild) {
288285 }
289286 }
290287
291- if (Test-Path " ./Cargo.toml" )
292- {
288+ if (Test-Path " ./Cargo.toml" ) {
293289 if ($Clippy ) {
294290 if ($clippy_unclean_projects -contains $project ) {
295291 Write-Verbose - Verbose " Skipping clippy for $project "
296- }
297- elseif ($pedantic_unclean_projects -contains $project ) {
292+ } elseif ($pedantic_unclean_projects -contains $project ) {
298293 Write-Verbose - Verbose " Running clippy for $project "
299294 cargo clippy @flags -- - Dwarnings
300- }
301- else {
295+ } else {
302296 Write-Verbose - Verbose " Running clippy with pedantic for $project "
303297 cargo clippy @flags --% -- -Dwarnings -Dclippy::pedantic
304298 }
305- }
306- else {
299+ } else {
307300 if ($UpdateLockFile ) {
308301 cargo generate- lockfile
309- }
310- else {
302+ } else {
311303 if ($Audit ) {
312304 if ($null -eq (Get-Command cargo- audit - ErrorAction Ignore)) {
313305 cargo install cargo- audit -- features= fix
@@ -330,8 +322,7 @@ if (!$SkipBuild) {
330322
331323 if ($IsWindows ) {
332324 Copy-Item " $path /$binary .exe" $target - ErrorAction Ignore
333- }
334- else {
325+ } else {
335326 Copy-Item " $path /$binary " $target - ErrorAction Ignore
336327 }
337328
@@ -383,8 +374,7 @@ if (!$Clippy -and !$SkipBuild) {
383374 $dirSeparator = [System.IO.Path ]::DirectorySeparatorChar
384375 if ($Release ) {
385376 $oldTarget = $target.Replace ($dirSeparator + ' release' , $dirSeparator + ' debug' )
386- }
387- else {
377+ } else {
388378 $oldTarget = $target.Replace ($dirSeparator + ' debug' , $dirSeparator + ' release' )
389379 }
390380 $env: PATH = $env: PATH.Replace ($oldTarget , ' ' )
@@ -423,15 +413,14 @@ if ($Test) {
423413
424414 if ($IsWindows ) {
425415 # 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 )) {
429418 Install-PSResource - Name PSDesiredStateConfiguration - Version 2.0 .7 - Repository $repository - TrustRepository
430419 }
431420 }
432421
433- if (-not (Get-Module - ListAvailable - Name Pester))
434- { " Installing module Pester"
422+ if (-not (Get-Module - ListAvailable - Name Pester)) {
423+ " Installing module Pester"
435424 Install-PSResource Pester - WarningAction Ignore - Repository $repository - TrustRepository
436425 }
437426
@@ -444,8 +433,7 @@ if ($Test) {
444433 Write-Host - ForegroundColor Cyan " Testing $project ..."
445434 try {
446435 Push-Location " $PSScriptRoot /$project "
447- if (Test-Path " ./Cargo.toml" )
448- {
436+ if (Test-Path " ./Cargo.toml" ) {
449437 cargo test
450438
451439 if ($LASTEXITCODE -ne 0 ) {
@@ -474,8 +462,8 @@ if ($Test) {
474462 " Updated PSModulePath is:"
475463 $env: PSModulePath
476464
477- if (-not (Get-Module - ListAvailable - Name Pester))
478- { " Installing module Pester"
465+ if (-not (Get-Module - ListAvailable - Name Pester)) {
466+ " Installing module Pester"
479467 $InstallTargetDir = ($env: PSModulePath -split " ;" )[0 ]
480468 Find-PSResource - Name ' Pester' - Repository $repository | Save-PSResource - Path $InstallTargetDir - TrustRepository
481469 }
@@ -493,8 +481,7 @@ function Find-MakeAppx() {
493481 # try to find
494482 if (! $UseX64MakeAppx -and $architecture -eq ' aarch64-pc-windows-msvc' ) {
495483 $arch = ' arm64'
496- }
497- else {
484+ } else {
498485 $arch = ' x64'
499486 }
500487
@@ -539,8 +526,7 @@ if ($packageType -eq 'msixbundle') {
539526 Write-Verbose - Verbose " Preview version detected"
540527 if ($isPrivate ) {
541528 $productName += " -Private"
542- }
543- else {
529+ } else {
544530 $productName += " -Preview"
545531 }
546532 # save preview number
@@ -552,8 +538,7 @@ if ($packageType -eq 'msixbundle') {
552538
553539 if ($isPrivate ) {
554540 $displayName += " -Private"
555- }
556- else {
541+ } else {
557542 $displayName += " -Preview"
558543 }
559544 }
@@ -697,4 +682,41 @@ if ($packageType -eq 'msixbundle') {
697682 Write-Host - ForegroundColor Green " `n Gz file is created at $gzFile "
698683}
699684
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