From b4fd74aa1b3aa98d8943f96cb7deda972617102d Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL HE/HIM) (from Dev Box)" Date: Fri, 7 Nov 2025 10:45:43 -0800 Subject: [PATCH 1/6] Misc fixes --- .cargo/config.toml | 25 +++++++++++++++++++--- .github/ISSUE_TEMPLATE/Feature_Request.yml | 2 +- .pipelines/DSC-Official.yml | 2 +- build.ps1 | 23 ++++++++------------ 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 27cca1ce0..09af976fd 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -8,12 +8,31 @@ POWERSHELL = { index = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/ [registry] global-credential-providers = ["cargo:token"] -# Enable Control Flow Guard (needed for OneBranch's post-build analysis). +# Avoid linking with vcruntime140.dll by statically linking everything, +# and then explicitly linking with ucrtbase.dll dynamically. +# We do this, because vcruntime140.dll is an optional Windows component. [target.x86_64-pc-windows-msvc] -rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DYNAMICBASE /CETCOMPAT"] +rustflags = [ + "-CControl-flow-guard", + "-Ctarget-feature=+crt-static", + "-Clink-args=/DEFAULTLIB:ucrt.lib", + "-Clink-args=/NODEFAULTLIB:vcruntime.lib", + "-Clink-args=/NODEFAULTLIB:msvcrt.lib", + "-Clink-args=/NODEFAULTLIB:libucrt.lib", + "-Clink-args=/DYNAMICBASE", + "-Clink-args=/CETCOMPAT" +] [target.aarch64-windows-msvc] -rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DYNAMICBASE"] +rustflags = [ + "-CControl-flow-guard", + "-Ctarget-feature=+crt-static", + "-Clink-args=/DEFAULTLIB:ucrt.lib", + "-Clink-args=/NODEFAULTLIB:vcruntime.lib", + "-Clink-args=/NODEFAULTLIB:msvcrt.lib", + "-Clink-args=/NODEFAULTLIB:libucrt.lib", + "-Clink-args=/DYNAMICBASE" +] # The following is only needed for release builds [source.crates-io] diff --git a/.github/ISSUE_TEMPLATE/Feature_Request.yml b/.github/ISSUE_TEMPLATE/Feature_Request.yml index 426f8e949..76c6bec52 100644 --- a/.github/ISSUE_TEMPLATE/Feature_Request.yml +++ b/.github/ISSUE_TEMPLATE/Feature_Request.yml @@ -14,7 +14,7 @@ body: new feature would solve. Try formulating it in user story style (if applicable). placeholder: >- - 'As a user I want X so that Y...' with X being the being the + 'As a user I want X so that Y...' with X being the action and Y being the value of the action. validations: required: true diff --git a/.pipelines/DSC-Official.yml b/.pipelines/DSC-Official.yml index 4d9cf7259..60870a794 100644 --- a/.pipelines/DSC-Official.yml +++ b/.pipelines/DSC-Official.yml @@ -585,7 +585,7 @@ extends: throw "PackageVersion variable is not set. Cannot proceed with publishing Universal Package." } Write-Verbose -Verbose "Universal Package version: $packageVersion" - az artifacts universal publish --organization https://dev.azure.com//PowerShell --project PowerShell --feed PowerShell-Universal --name microsoft.dsc-linux --version $packageVersion --description "Microsoft Desired State Configuration (DSC) - Universal Package" --path "$(LinuxDirectory)" --scope project --verbose + az artifacts universal publish --organization https://dev.azure.com/PowerShell --project PowerShell --feed PowerShell-Universal --name microsoft.dsc-linux --version $packageVersion --description "Microsoft Desired State Configuration (DSC) - Universal Package" --path "$(LinuxDirectory)" --scope project --verbose condition: succeeded() - task: AzureCLI@2 diff --git a/build.ps1 b/build.ps1 index 1ee551e20..6b843b72e 100755 --- a/build.ps1 +++ b/build.ps1 @@ -182,20 +182,15 @@ if ($null -ne $packageType) { throw "Azure CLI not found" } - if ($null -ne (Get-Command az -ErrorAction Ignore)) { - Write-Host "Getting token" - $accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv - if ($LASTEXITCODE -ne 0) { - Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access." - } else { - $header = "Bearer $accessToken" - $env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header - $env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token' - $env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell~force-auth/Cargo/index/" - } - } - else { - Write-Warning "Azure CLI not found, proceeding with anonymous access." + Write-Host "Getting token" + $accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv + if ($LASTEXITCODE -ne 0) { + Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access." + } else { + $header = "Bearer $accessToken" + $env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header + $env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token' + $env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell~force-auth/Cargo/index/" } } } else { From 0fc023ae91858fb1899e285eeae89c2f2ce66554 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL HE/HIM) (from Dev Box)" Date: Fri, 7 Nov 2025 11:05:40 -0800 Subject: [PATCH 2/6] add new cap to manifest --- packaging/msix/AppxManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/msix/AppxManifest.xml b/packaging/msix/AppxManifest.xml index 37f7f541e..3cbee4de7 100644 --- a/packaging/msix/AppxManifest.xml +++ b/packaging/msix/AppxManifest.xml @@ -47,5 +47,6 @@ + From 0680a02ec97a0afcef1c6cc8c925041bb3372bc7 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL HE/HIM) (from Dev Box)" Date: Fri, 7 Nov 2025 11:07:18 -0800 Subject: [PATCH 3/6] fix casing --- .cargo/config.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 09af976fd..14d9cc770 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -13,7 +13,7 @@ global-credential-providers = ["cargo:token"] # We do this, because vcruntime140.dll is an optional Windows component. [target.x86_64-pc-windows-msvc] rustflags = [ - "-CControl-flow-guard", + "-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DEFAULTLIB:ucrt.lib", "-Clink-args=/NODEFAULTLIB:vcruntime.lib", @@ -25,7 +25,7 @@ rustflags = [ [target.aarch64-windows-msvc] rustflags = [ - "-CControl-flow-guard", + "-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DEFAULTLIB:ucrt.lib", "-Clink-args=/NODEFAULTLIB:vcruntime.lib", From 17f2eadc579a0765753a4c854af379cf9cded5d3 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL HE/HIM) (from Dev Box)" Date: Fri, 7 Nov 2025 12:22:14 -0800 Subject: [PATCH 4/6] move rustflag from build to toml --- .cargo/config.toml | 6 ++++-- build.ps1 | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 14d9cc770..aaef8570d 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -20,7 +20,8 @@ rustflags = [ "-Clink-args=/NODEFAULTLIB:msvcrt.lib", "-Clink-args=/NODEFAULTLIB:libucrt.lib", "-Clink-args=/DYNAMICBASE", - "-Clink-args=/CETCOMPAT" + "-Clink-args=/CETCOMPAT", + "-Dwarnings" ] [target.aarch64-windows-msvc] @@ -31,7 +32,8 @@ rustflags = [ "-Clink-args=/NODEFAULTLIB:vcruntime.lib", "-Clink-args=/NODEFAULTLIB:msvcrt.lib", "-Clink-args=/NODEFAULTLIB:libucrt.lib", - "-Clink-args=/DYNAMICBASE" + "-Clink-args=/DYNAMICBASE", + "-Dwarnings" ] # The following is only needed for release builds diff --git a/build.ps1 b/build.ps1 index 6b843b72e..f92f6571f 100755 --- a/build.ps1 +++ b/build.ps1 @@ -29,7 +29,6 @@ trap { } $env:RUSTC_LOG=$null -$env:RUSTFLAGS='-Dwarnings' $usingADO = ($null -ne $env:TF_BUILD) if ($usingADO -or $UseCFSAuth) { $UseCFS = $true From 1ae176d104ec0fb694406cdf1b3b54d59c7b26e0 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL HE/HIM) (from Dev Box)" Date: Fri, 7 Nov 2025 12:44:55 -0800 Subject: [PATCH 5/6] remove unncessary static_vcruntime crate use --- Cargo.lock | 8 -------- Cargo.toml | 2 -- archive/ntreg/Cargo.toml | 3 --- archive/ntreg/build.rs | 2 -- archive/registry/Cargo.toml | 3 --- archive/registry/build.rs | 2 -- lib/dsc-lib-registry/Cargo.toml | 1 - resources/registry/Cargo.toml | 3 --- resources/registry/build.rs | 1 - 9 files changed, 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e5a5c607..b2b5c1cbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -729,7 +729,6 @@ dependencies = [ "schemars", "serde", "serde_json", - "static_vcruntime", "thiserror 2.0.17", "tracing", "tracing-subscriber", @@ -784,7 +783,6 @@ dependencies = [ "schemars", "serde", "serde_json", - "static_vcruntime", "thiserror 2.0.17", "tracing", "tracing-subscriber", @@ -2678,12 +2676,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "static_vcruntime" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "954e3e877803def9dc46075bf4060147c55cd70db97873077232eae0269dc89b" - [[package]] name = "streaming-iterator" version = "0.1.9" diff --git a/Cargo.toml b/Cargo.toml index 31f5c69fd..6339ec197 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -208,8 +208,6 @@ which = { version = "8.0" } # build-only dependencies # dsc-lib, dsc-lib-registry, sshdconfig, tree-sitter-dscexpression, tree-sitter-ssh-server-config cc = { version = "1.2" } -# registry, dsc-lib-registry -static_vcruntime = { version = "2.0" } # test-only dependencies # dsc-lib-jsonschema diff --git a/archive/ntreg/Cargo.toml b/archive/ntreg/Cargo.toml index 18c322bdf..362b04261 100644 --- a/archive/ntreg/Cargo.toml +++ b/archive/ntreg/Cargo.toml @@ -29,6 +29,3 @@ thiserror = "1.0" [target.'cfg(onecore)'.dependencies] pal = { path = "../pal" } - -[build-dependencies] -static_vcruntime = "2.0" diff --git a/archive/ntreg/build.rs b/archive/ntreg/build.rs index abbdaf1e7..bc775bbcc 100644 --- a/archive/ntreg/build.rs +++ b/archive/ntreg/build.rs @@ -7,11 +7,9 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rustc-link-lib=onecore_apiset"); println!("cargo:rustc-link-lib=onecoreuap_apiset"); - static_vcruntime::metabuild(); } #[cfg(not(onecore))] fn main() { println!("cargo:rerun-if-changed=build.rs"); - static_vcruntime::metabuild(); } diff --git a/archive/registry/Cargo.toml b/archive/registry/Cargo.toml index 13dcd4026..e2656a748 100644 --- a/archive/registry/Cargo.toml +++ b/archive/registry/Cargo.toml @@ -24,6 +24,3 @@ serde_json = { version = "1.0", features = ["preserve_order"] } [target.'cfg(onecore)'.dependencies] pal = { path = "../pal" } - -[build-dependencies] -static_vcruntime = "2.0" diff --git a/archive/registry/build.rs b/archive/registry/build.rs index ce4b7a084..a75972259 100644 --- a/archive/registry/build.rs +++ b/archive/registry/build.rs @@ -7,12 +7,10 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rustc-link-lib=onecore_apiset"); println!("cargo:rustc-link-lib=onecoreuap_apiset"); - static_vcruntime::metabuild(); } #[cfg(not(onecore))] fn main() { // Prevent this build script from rerunning unnecessarily. println!("cargo:rerun-if-changed=build.rs"); - static_vcruntime::metabuild(); } diff --git a/lib/dsc-lib-registry/Cargo.toml b/lib/dsc-lib-registry/Cargo.toml index f72e50347..cd38a3e3b 100644 --- a/lib/dsc-lib-registry/Cargo.toml +++ b/lib/dsc-lib-registry/Cargo.toml @@ -24,5 +24,4 @@ tracing-subscriber = { workspace = true } utfx = { workspace = true } [build-dependencies] -static_vcruntime = { workspace = true } cc = { workspace = true } diff --git a/resources/registry/Cargo.toml b/resources/registry/Cargo.toml index 50dd79eb8..de7e3a825 100644 --- a/resources/registry/Cargo.toml +++ b/resources/registry/Cargo.toml @@ -27,6 +27,3 @@ tracing-subscriber = { workspace = true } utfx = { workspace = true } # workspace crate dependencies dsc-lib-registry = { workspace = true } - -[build-dependencies] -static_vcruntime = { workspace = true } diff --git a/resources/registry/build.rs b/resources/registry/build.rs index 495c64a43..977722481 100644 --- a/resources/registry/build.rs +++ b/resources/registry/build.rs @@ -4,5 +4,4 @@ fn main() { // Prevent this build script from rerunning unnecessarily. println!("cargo:rerun-if-changed=build.rs"); - static_vcruntime::metabuild(); } From 3d5ae86f0931d73a579326d8607a05e85522b6e7 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL HE/HIM) (from Dev Box)" Date: Fri, 7 Nov 2025 20:53:27 -0800 Subject: [PATCH 6/6] remove rustflags from helpers module --- build.helpers.psm1 | 3 --- 1 file changed, 3 deletions(-) diff --git a/build.helpers.psm1 b/build.helpers.psm1 index 1142333d0..83a3a7719 100644 --- a/build.helpers.psm1 +++ b/build.helpers.psm1 @@ -750,9 +750,6 @@ function Set-RustEnvironment { Write-Verbose "Caching current rust environment variables..." [hashtable]$currentRustEnvironment = Get-RustEnvironment - Write-Verbose "Setting RUSTFLAGS to '-Dwarnings'" - $env:RUSTFLAGS='-Dwarnings' - if ($VerbosePreference -eq 'Continue') { Write-Verbose "Running verbose, setting RUSTC_LOG " # $env:RUSTC_LOG='rustc_codegen_ssa::back::link=info'