diff --git a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md index 3004a125480..62b54a51f1d 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md @@ -167,6 +167,7 @@ * Debug: fix if and match condition sequence points ([PR #19932](https://github.com/dotnet/fsharp/pull/19932)) * Checker: recover on checking language version ([PR ##19970](https://github.com/dotnet/fsharp/pull/19970)) * Implied argument names for function-to-delegate coercions now fall back to the delegate's `Invoke` parameter names when the function has no recoverable names (e.g. a partial application like `System.Func((+) 1)`), instead of synthetic `delegateArg0`, `delegateArg1`, … names. ([PR #20001](https://github.com/dotnet/fsharp/pull/20001)) +* Add internal `ResetCompilerGeneratedNameState` to `CompilerGlobalState` name generators so warm-checker re-compilation can produce fresh-process-identical generated names. ([PR #20017](https://github.com/dotnet/fsharp/pull/20017)) ### Improved diff --git a/eng/Version.Details.props b/eng/Version.Details.props index 38e3f16219e..4030e07535c 100644 --- a/eng/Version.Details.props +++ b/eng/Version.Details.props @@ -6,12 +6,12 @@ This file should be imported by eng/Versions.props - 11.0.0-beta.26330.1 + 11.0.0-beta.26369.1 - 18.10.0-preview-26358-03 - 18.10.0-preview-26358-03 - 18.10.0-preview-26358-03 - 18.10.0-preview-26358-03 + 18.10.0-1.26370.18 + 18.10.0-1.26370.18 + 18.10.0-1.26370.18 + 18.10.0-1.26370.18 1.0.0-prerelease.26309.1 1.0.0-prerelease.26309.1 @@ -19,19 +19,19 @@ This file should be imported by eng/Versions.props 1.0.0-prerelease.26309.1 1.0.0-prerelease.26309.1 - 5.10.0-1.26358.9 - 5.10.0-1.26358.9 - 5.10.0-1.26358.9 - 5.10.0-1.26358.9 - 5.10.0-1.26358.9 - 5.10.0-1.26358.9 - 5.10.0-1.26358.9 - 5.10.0-1.26358.9 + 5.10.0-1.26365.3 + 5.10.0-1.26365.3 + 5.10.0-1.26365.3 + 5.10.0-1.26365.3 + 5.10.0-1.26365.3 + 5.10.0-1.26365.3 + 5.10.0-1.26365.3 + 5.10.0-1.26365.3 - 10.0.2 - 10.0.2 - 10.0.2 - 10.0.2 + 10.0.8 + 10.0.8 + 10.0.8 + 10.0.8 10.0.8 diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 737ecef5aa1..b17d2d942a1 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -2,74 +2,74 @@ - + https://github.com/dotnet/msbuild - 98935500d8efcb66c1f32927cb2976ea067172d2 + eae54023463db15e9a9081f35a959c9162797643 - + https://github.com/dotnet/msbuild - 98935500d8efcb66c1f32927cb2976ea067172d2 + eae54023463db15e9a9081f35a959c9162797643 - + https://github.com/dotnet/msbuild - 98935500d8efcb66c1f32927cb2976ea067172d2 + eae54023463db15e9a9081f35a959c9162797643 - + https://github.com/dotnet/msbuild - 98935500d8efcb66c1f32927cb2976ea067172d2 + eae54023463db15e9a9081f35a959c9162797643 - + https://github.com/dotnet/roslyn - 35967bab3447f7edd6162baee7048f801f18fffe + 3d32d464e2949f054086fbb5346e4beea0c6df56 - + https://github.com/dotnet/roslyn - 35967bab3447f7edd6162baee7048f801f18fffe + 3d32d464e2949f054086fbb5346e4beea0c6df56 - + https://github.com/dotnet/roslyn - 35967bab3447f7edd6162baee7048f801f18fffe + 3d32d464e2949f054086fbb5346e4beea0c6df56 - + https://github.com/dotnet/roslyn - 35967bab3447f7edd6162baee7048f801f18fffe + 3d32d464e2949f054086fbb5346e4beea0c6df56 - + https://github.com/dotnet/roslyn - 35967bab3447f7edd6162baee7048f801f18fffe + 3d32d464e2949f054086fbb5346e4beea0c6df56 - + https://github.com/dotnet/roslyn - 35967bab3447f7edd6162baee7048f801f18fffe + 3d32d464e2949f054086fbb5346e4beea0c6df56 - + https://github.com/dotnet/roslyn - 35967bab3447f7edd6162baee7048f801f18fffe + 3d32d464e2949f054086fbb5346e4beea0c6df56 - + https://github.com/dotnet/roslyn - 35967bab3447f7edd6162baee7048f801f18fffe + 3d32d464e2949f054086fbb5346e4beea0c6df56 - + https://github.com/dotnet/runtime - + https://github.com/dotnet/runtime - + https://github.com/dotnet/runtime - + https://github.com/dotnet/runtime @@ -82,9 +82,9 @@ - + https://github.com/dotnet/arcade - f87bce1e0d389d515282c5f74466d629ef653026 + 09bc8c946f4c4ae5d031c8875b85a6b8f1876b93 https://dev.azure.com/dnceng/internal/_git/dotnet-optimization diff --git a/eng/Versions.props b/eng/Versions.props index 6b84491276b..16e0dc2bd6c 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -89,12 +89,9 @@ 4.6.1 4.6.3 6.1.2 - - 10.0.2 - $(SystemPackagesVersion) - $(SystemPackagesVersion) - $(SystemPackagesVersion) - $(SystemPackagesVersion) + @@ -108,16 +105,17 @@ 18.0.2188-preview.1 18.0.1237-pre 18.0.2077-preview.1 - 18.0.5 + 18.7.19 2.0.28 $(MicrosoftVisualStudioShellPackagesVersion) $(VisualStudioShellProjectsPackages) - $(MicrosoftVisualStudioShellPackagesVersion) - $(MicrosoftVisualStudioShellPackagesVersion) - $(MicrosoftVisualStudioShellPackagesVersion) + + 18.9.438 + 18.9.438 + 18.9.438 $(MicrosoftVisualStudioShellPackagesVersion) $(MicrosoftVisualStudioShellPackagesVersion) $(MicrosoftVisualStudioShellPackagesVersion) @@ -132,7 +130,12 @@ $(VisualStudioEditorPackagesVersion) $(VisualStudioEditorPackagesVersion) $(VisualStudioEditorPackagesVersion) - $(VisualStudioEditorPackagesVersion) + + 18.9.123 $(VisualStudioEditorPackagesVersion) 17.14.0 0.1.800-beta @@ -141,6 +144,20 @@ $(MicrosoftVisualStudioThreadingPackagesVersion) + + 18.7.1 + 18.9.453 + 4.10.128 + 2.26.5 + + + 1.0.52 + $(VisualStudioProjectSystemPackagesVersion) 2.3.6152103 diff --git a/eng/common/SetupNugetSources.ps1 b/eng/common/SetupNugetSources.ps1 index 58002808bc8..b3bddff355e 100644 --- a/eng/common/SetupNugetSources.ps1 +++ b/eng/common/SetupNugetSources.ps1 @@ -13,7 +13,11 @@ # filePath: $(System.DefaultWorkingDirectory)/eng/common/SetupNugetSources.ps1 # arguments: -ConfigFile $(System.DefaultWorkingDirectory)/NuGet.config -Password $Env:Token # env: -# Token: $(dn-bot-dnceng-artifact-feeds-rw) +# Token: $(InternalFeedToken) +# +# Note: This logic is abstracted into enable-internal-sources.yml, which uses +# NuGetAuthenticate or a WIF-backed service connection. Prefer that template +# over calling this script directly. # # Note that the NuGetAuthenticate task should be called after SetupNugetSources. # This ensures that: diff --git a/eng/common/build.ps1 b/eng/common/build.ps1 index 2cbb725323e..dd84699f500 100644 --- a/eng/common/build.ps1 +++ b/eng/common/build.ps1 @@ -23,6 +23,7 @@ Param( [switch] $clean, [switch][Alias('pb')]$productBuild, [switch]$fromVMR, + [switch]$disablePipelineSetResult, [switch][Alias('bl')]$binaryLog, [string][Alias('bln')]$binaryLogName = '', [switch][Alias('nobl')]$excludeCIBinarylog, @@ -80,6 +81,7 @@ function Print-Usage() { Write-Host " -nodeReuse Sets nodereuse msbuild parameter ('true' or 'false')" Write-Host " -buildCheck Sets /check msbuild parameter" Write-Host " -fromVMR Set when building from within the VMR" + Write-Host " -disablePipelineSetResult Set to disable masking the actual exit code in the pipeline when the build fails" Write-Host "" Write-Host "Command line arguments not listed above are passed thru to msbuild." diff --git a/eng/common/build.sh b/eng/common/build.sh index 3a9fdcfd0f5..e37edd6cff3 100755 --- a/eng/common/build.sh +++ b/eng/common/build.sh @@ -40,12 +40,14 @@ usage() echo " --projects Project or solution file(s) to build" echo " --ci Set when running on CI server" echo " --excludeCIBinarylog Don't output binary log (short: -nobl)" + echo " --pipelinesLog Promote msbuild errors/warnings to Azure Pipelines timeline issues; defaults to on in CI (short: -pl)" echo " --prepareMachine Prepare machine for CI run, clean up processes after build" echo " --nodeReuse Sets nodereuse msbuild parameter ('true' or 'false')" echo " --warnAsError Sets warnaserror msbuild parameter ('true' or 'false')" echo " --warnNotAsError Sets a semi-colon delimited list of warning codes that should not be treated as errors" echo " --buildCheck Sets /check msbuild parameter" echo " --fromVMR Set when building from within the VMR" + echo " --disablePipelineSetResult Set to disable masking the actual exit code in the pipeline when the build fails" echo "" echo "Command line arguments not listed above are passed thru to msbuild." echo "Arguments can also be passed in with a single hyphen." @@ -68,6 +70,7 @@ build=false source_build=false product_build=false from_vmr=false +disable_pipeline_set_result=false rebuild=false test=false integration_test=false @@ -86,6 +89,7 @@ build_check=false binary_log=false binary_log_name='' exclude_ci_binary_log=false +pipelines_log=false projects='' configuration='' @@ -124,6 +128,9 @@ while [[ $# -gt 0 ]]; do -excludecibinarylog|-nobl) exclude_ci_binary_log=true ;; + -pipelineslog|-pl) + pipelines_log=true + ;; -restore|-r) restore=true ;; @@ -152,6 +159,9 @@ while [[ $# -gt 0 ]]; do -fromvmr|-from-vmr) from_vmr=true ;; + -disablepipelinesetresult|-disable-pipeline-set-result) + disable_pipeline_set_result=true + ;; -test|-t) test=true ;; @@ -213,6 +223,7 @@ if [[ -z "$configuration" ]]; then fi if [[ "$ci" == true ]]; then + pipelines_log=true # Disable node reuse on CI unless explicitly opted in via MSBUILD_NODEREUSE_ENABLED. # Internal testing only; this env var will be replaced with a switch (https://github.com/dotnet/arcade/issues/17013) and must not be depended on. if [[ "${MSBUILD_NODEREUSE_ENABLED:-}" != "1" ]]; then diff --git a/eng/common/core-templates/job/helix-job-monitor.yml b/eng/common/core-templates/job/helix-job-monitor.yml index 96287e55a15..0da13cf69db 100644 --- a/eng/common/core-templates/job/helix-job-monitor.yml +++ b/eng/common/core-templates/job/helix-job-monitor.yml @@ -65,6 +65,14 @@ parameters: type: boolean default: true +# When true, test results are reported to Azure DevOps using the fully qualified test name +# (Namespace.Type.Method) as the stable automatedTestName and the visible title is qualified as +# well (--use-fully-qualified-test-name). Opt-in because it changes AzDO test identity and display; +# primarily useful for frameworks like MSTest whose display name is only the method name. +- name: useFullyQualifiedTestName + type: boolean + default: false + # Advanced: optional pipeline artifact (produced earlier in this run) that contains the tool # nupkg. When set, the artifact is downloaded and the tool is installed from the nupkg into # a local tool-path; this bypasses the repo's .config/dotnet-tools.json manifest and is @@ -176,11 +184,12 @@ jobs: set -euo pipefail toolArgs=( - --helix-base-uri '${{ parameters.helixBaseUri }}' - --polling-interval-seconds '${{ parameters.pollingIntervalSeconds }}' - --fail-on-failed-tests '${{ parameters.failWorkItemsWithFailedTests }}' - --max-wait-minutes "$((${{ parameters.timeoutInMinutes }} - 5))" # Set the tool's timeout slightly lower than the Azure DevOps job timeout to allow it to exit gracefully. - --stage-name '$(System.StageName)' + --helix-base-uri '${{ parameters.helixBaseUri }}' + --polling-interval-seconds '${{ parameters.pollingIntervalSeconds }}' + --fail-on-failed-tests '${{ parameters.failWorkItemsWithFailedTests }}' + --use-fully-qualified-test-name '${{ parameters.useFullyQualifiedTestName }}' + --max-wait-minutes "$((${{ parameters.timeoutInMinutes }} - 5))" # Set the tool's timeout slightly lower than the Azure DevOps job timeout to allow it to exit gracefully. + --stage-name '$(System.StageName)' ) organization='${{ parameters.organization }}' diff --git a/eng/common/core-templates/job/onelocbuild.yml b/eng/common/core-templates/job/onelocbuild.yml index 86ea9f63504..2816d2905a0 100644 --- a/eng/common/core-templates/job/onelocbuild.yml +++ b/eng/common/core-templates/job/onelocbuild.yml @@ -8,6 +8,12 @@ parameters: CeapexPat: $(dn-bot-ceapex-package-r) # PAT for the loc AzDO instance https://dev.azure.com/ceapex GithubPat: $(BotAccount-dotnet-bot-repo-PAT) + # Service connection for WIF-based Entra authentication to ceapex feeds (replaces CeapexPat). + # When set, dnceng/internal builds acquire a federated Entra token instead of using a PAT. + # All other projects (e.g. DevDiv, public), where this dnceng-scoped service connection does not + # exist, and any pipeline that sets this to '' fall back to PAT-based auth via the CeapexPat parameter. + CeapexServiceConnection: 'dnceng-onelocbuild-ceapex' + SourcesDirectory: $(System.DefaultWorkingDirectory) CreatePr: true AutoCompletePr: false @@ -74,6 +80,15 @@ jobs: displayName: Generate LocProject.json condition: ${{ parameters.condition }} + # Acquire an Entra token for ceapex feed access via WIF (dnceng/internal only). + # All other projects use PAT-based auth, since the ceapex service connection is scoped to dnceng/internal. + - ${{ if and(ne(parameters.CeapexServiceConnection, ''), eq(variables['System.TeamProject'], 'internal')) }}: + - template: /eng/common/templates/steps/get-federated-access-token.yml + parameters: + federatedServiceConnection: ${{ parameters.CeapexServiceConnection }} + outputVariableName: 'CeapexEntraToken' + condition: ${{ parameters.condition }} + - task: OneLocBuild@2 displayName: OneLocBuild env: @@ -89,7 +104,10 @@ jobs: isUseLfLineEndingsSelected: ${{ parameters.UseLfLineEndings }} isShouldReusePrSelected: ${{ parameters.ReusePr }} packageSourceAuth: patAuth - patVariable: ${{ parameters.CeapexPat }} + ${{ if and(ne(parameters.CeapexServiceConnection, ''), eq(variables['System.TeamProject'], 'internal')) }}: + patVariable: $(CeapexEntraToken) + ${{ if or(eq(parameters.CeapexServiceConnection, ''), ne(variables['System.TeamProject'], 'internal')) }}: + patVariable: ${{ parameters.CeapexPat }} ${{ if eq(parameters.RepoType, 'gitHub') }}: repoType: ${{ parameters.RepoType }} gitHubPatVariable: "${{ parameters.GithubPat }}" diff --git a/eng/common/core-templates/job/publish-build-assets.yml b/eng/common/core-templates/job/publish-build-assets.yml index 700f7711465..4229288d3d3 100644 --- a/eng/common/core-templates/job/publish-build-assets.yml +++ b/eng/common/core-templates/job/publish-build-assets.yml @@ -122,9 +122,6 @@ jobs: # Populate internal runtime variables. - template: /eng/common/templates/steps/enable-internal-sources.yml - ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}: - parameters: - legacyCredential: $(dn-bot-dnceng-artifact-feeds-rw) - template: /eng/common/templates/steps/enable-internal-runtimes.yml diff --git a/eng/common/core-templates/post-build/post-build.yml b/eng/common/core-templates/post-build/post-build.yml index 8aa86e30491..9d951352696 100644 --- a/eng/common/core-templates/post-build/post-build.yml +++ b/eng/common/core-templates/post-build/post-build.yml @@ -295,8 +295,6 @@ stages: # Populate internal runtime variables. - template: /eng/common/templates/steps/enable-internal-sources.yml - parameters: - legacyCredential: $(dn-bot-dnceng-artifact-feeds-rw) - template: /eng/common/templates/steps/enable-internal-runtimes.yml diff --git a/eng/common/cross/build-rootfs.sh b/eng/common/cross/build-rootfs.sh index 3150ccac6fc..38a3512f148 100755 --- a/eng/common/cross/build-rootfs.sh +++ b/eng/common/cross/build-rootfs.sh @@ -18,7 +18,10 @@ usage() echo "--skipsigcheck - optional, will skip package signature checks (allowing untrusted packages)." echo "--skipemulation - optional, will skip qemu and debootstrap requirement when building environment for debian based systems." echo "--use-mirror - optional, use mirror URL to fetch resources, when available." - echo "--jobs N - optional, restrict to N jobs." + echo "--ubuntu-repo - optional, override the Ubuntu apt repository base URL." + echo "--debian-repo - optional, override the Debian apt repository base URL." + echo "--alpine-repo - optional, override the Alpine Linux repository base URL." + echo "--jobs N (or --use-jobs N) - optional, restrict to N jobs." exit 1 } @@ -144,6 +147,9 @@ __KeyringFile="/usr/share/keyrings/ubuntu-archive-keyring.gpg" __SkipSigCheck=0 __SkipEmulation=0 __UseMirror=0 +__UbuntuRepoOverride= +__DebianRepoOverride= +__AlpineRepoOverride= __UnprocessedBuildArgs= while :; do @@ -397,6 +403,31 @@ while :; do --use-mirror) __UseMirror=1 ;; + --ubuntu-repo|-ubuntu-repo) + shift + if [[ "$#" -le 0 ]]; then + echo "ERROR: --ubuntu-repo requires a URL argument." + usage + fi + __UbuntuRepoOverride="$1" + ;; + --debian-repo|-debian-repo) + shift + if [[ "$#" -le 0 ]]; then + echo "ERROR: --debian-repo requires a URL argument." + usage + fi + __DebianRepoOverride="$1" + ;; + --alpine-repo|-alpine-repo) + shift + if [[ "$#" -le 0 ]]; then + echo "ERROR: --alpine-repo requires a URL argument." + usage + fi + __AlpineRepoOverride="$1" + ;; + # Removed duplicate/invalid option handling block (was breaking case statement parsing). --use-jobs) shift MAXJOBS=$1 @@ -422,9 +453,12 @@ case "$__AlpineVersion" in elif [[ "$__AlpineArch" == "x86" ]]; then __AlpineVersion=3.17 # minimum version that supports lldb-dev __AlpinePackages+=" llvm15-libs" - elif [[ "$__AlpineArch" == "riscv64" || "$__AlpineArch" == "loongarch64" ]]; then + elif [[ "$__AlpineArch" == "loongarch64" ]]; then __AlpineVersion=3.21 # minimum version that supports lldb-dev __AlpinePackages+=" llvm19-libs" + elif [[ "$__AlpineArch" == "riscv64" ]]; then + __AlpineVersion=3.22 # lldb-dev requires 3.21+, but 3.22+ provides the newer linux-headers needed for RISC-V extension probes + __AlpinePackages+=" llvm20-libs" elif [[ -n "$__AlpineMajorVersion" ]]; then # use whichever alpine version is provided and select the latest toolchain libs __AlpineLlvmLibsLookup=1 @@ -446,6 +480,12 @@ if [[ -z "$__UbuntuRepo" ]]; then __UbuntuRepo="https://ports.ubuntu.com/" fi +if [[ -n "$__UbuntuRepoOverride" && "$__KeyringFile" == *ubuntu* ]]; then + __UbuntuRepo="$__UbuntuRepoOverride" +elif [[ -n "$__DebianRepoOverride" && "$__KeyringFile" == *debian* ]]; then + __UbuntuRepo="$__DebianRepoOverride" +fi + if [[ -n "$__LLVM_MajorVersion" ]]; then __UbuntuPackages+=" libclang-common-${__LLVM_MajorVersion}${__LLVM_MinorVersion:+.$__LLVM_MinorVersion}-dev" fi @@ -486,6 +526,7 @@ if [[ "$__CodeName" == "alpine" ]]; then __ApkToolsDir="$(mktemp -d)" __ApkKeysDir="$(mktemp -d)" arch="$(uname -m)" + __AlpineRepo="${__AlpineRepoOverride:-https://dl-cdn.alpinelinux.org/alpine}" ensureDownloadTool @@ -530,15 +571,15 @@ if [[ "$__CodeName" == "alpine" ]]; then # initialize DB # shellcheck disable=SC2086 "$__ApkToolsDir/apk.static" \ - -X "https://dl-cdn.alpinelinux.org/alpine/$version/main" \ - -X "https://dl-cdn.alpinelinux.org/alpine/$version/community" \ + -X "$__AlpineRepo/$version/main" \ + -X "$__AlpineRepo/$version/community" \ -U $__ApkSignatureArg --root "$__RootfsDir" --arch "$__AlpineArch" --initdb add if [[ "$__AlpineLlvmLibsLookup" == 1 ]]; then # shellcheck disable=SC2086 __AlpinePackages+=" $("$__ApkToolsDir/apk.static" \ - -X "https://dl-cdn.alpinelinux.org/alpine/$version/main" \ - -X "https://dl-cdn.alpinelinux.org/alpine/$version/community" \ + -X "$__AlpineRepo/$version/main" \ + -X "$__AlpineRepo/$version/community" \ -U $__ApkSignatureArg --root "$__RootfsDir" --arch "$__AlpineArch" \ search 'llvm*-libs' | grep -E '^llvm' | sort | tail -1 | sed 's/-[^-]*//2g')" fi @@ -546,8 +587,8 @@ if [[ "$__CodeName" == "alpine" ]]; then # install all packages in one go # shellcheck disable=SC2086 "$__ApkToolsDir/apk.static" \ - -X "https://dl-cdn.alpinelinux.org/alpine/$version/main" \ - -X "https://dl-cdn.alpinelinux.org/alpine/$version/community" \ + -X "$__AlpineRepo/$version/main" \ + -X "$__AlpineRepo/$version/community" \ -U $__ApkSignatureArg --root "$__RootfsDir" --arch "$__AlpineArch" $__NoEmulationArg \ add $__AlpinePackages diff --git a/eng/common/cross/toolchain.cmake b/eng/common/cross/toolchain.cmake index ead7fe3ef26..70b71395e3b 100644 --- a/eng/common/cross/toolchain.cmake +++ b/eng/common/cross/toolchain.cmake @@ -87,6 +87,8 @@ elseif(TARGET_ARCH_NAME STREQUAL "ppc64le") set(CMAKE_SYSTEM_PROCESSOR ppc64le) if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/powerpc64le-alpine-linux-musl) set(TOOLCHAIN "powerpc64le-alpine-linux-musl") + elseif(FREEBSD) + set(TOOLCHAIN "powerpc64le-unknown-freebsd14") else() set(TOOLCHAIN "powerpc64le-linux-gnu") endif() diff --git a/eng/common/dotnet-install.ps1 b/eng/common/dotnet-install.ps1 index 50ae6273768..b6d45f2bdc4 100644 --- a/eng/common/dotnet-install.ps1 +++ b/eng/common/dotnet-install.ps1 @@ -4,13 +4,16 @@ Param( [string] $architecture = '', [string] $version = 'Latest', [string] $runtime = 'dotnet', + [string] $dotnetPath = '', [string] $RuntimeSourceFeed = '', [string] $RuntimeSourceFeedKey = '' ) . $PSScriptRoot\tools.ps1 -if (-not [string]::IsNullOrEmpty($env:DOTNET_GLOBAL_INSTALL_DIR)) { +if (-not [string]::IsNullOrEmpty($dotnetPath)) { + $dotnetRoot = $dotnetPath +} elseif (-not [string]::IsNullOrEmpty($env:DOTNET_GLOBAL_INSTALL_DIR)) { $dotnetRoot = $env:DOTNET_GLOBAL_INSTALL_DIR } else { $dotnetRoot = Join-Path $RepoRoot '.dotnet' diff --git a/eng/common/dotnet-install.sh b/eng/common/dotnet-install.sh index 1cb3f5abac2..58a7e6f384e 100755 --- a/eng/common/dotnet-install.sh +++ b/eng/common/dotnet-install.sh @@ -16,6 +16,7 @@ scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" version='Latest' architecture='' runtime='dotnet' +dotnetPath='' runtimeSourceFeed='' runtimeSourceFeedKey='' while [[ $# -gt 0 ]]; do @@ -33,6 +34,10 @@ while [[ $# -gt 0 ]]; do shift runtime="$1" ;; + -dotnetpath) + shift + dotnetPath="$1" + ;; -runtimesourcefeed) shift runtimeSourceFeed="$1" @@ -80,7 +85,9 @@ case $cpuname in ;; esac -if [[ -n "${DOTNET_GLOBAL_INSTALL_DIR:-}" ]]; then +if [[ -n "${dotnetPath:-}" ]]; then + dotnetRoot="$dotnetPath" +elif [[ -n "${DOTNET_GLOBAL_INSTALL_DIR:-}" ]]; then dotnetRoot="$DOTNET_GLOBAL_INSTALL_DIR" else dotnetRoot="${repo_root}.dotnet" diff --git a/eng/common/native/NativeAotSupported.props b/eng/common/native/NativeAotSupported.props index 559a6663929..cdff9ef0361 100644 --- a/eng/common/native/NativeAotSupported.props +++ b/eng/common/native/NativeAotSupported.props @@ -13,6 +13,8 @@ <_NativeAotSupportedArch Condition=" '$(TargetArchitecture)' != 'wasm' and + '$(TargetArchitecture)' != 's390x' and + '$(TargetArchitecture)' != 'ppc64le' and ('$(TargetArchitecture)' != 'x86' or '$(TargetOS)' == 'windows') ">true diff --git a/eng/common/native/init-os-and-arch.sh b/eng/common/native/init-os-and-arch.sh index 38921d4338f..62d62fed522 100644 --- a/eng/common/native/init-os-and-arch.sh +++ b/eng/common/native/init-os-and-arch.sh @@ -27,6 +27,10 @@ if [ "$os" = "sunos" ]; then os="solaris" fi CPUName=$(isainfo -n) +elif [ "$os" = "freebsd" ]; then + # FreeBSD's `uname -m` is the machine class ("powerpc" for every PowerPC + # variant); `uname -p` gives the specific processor (e.g. powerpc64le). + CPUName=$(uname -p) else # For the rest of the operating systems, use uname(1) to determine what the CPU is. CPUName=$(uname -m) @@ -75,7 +79,7 @@ case "$CPUName" in arch=s390x ;; - ppc64le) + ppc64le|powerpc64le) arch=ppc64le ;; *) diff --git a/eng/common/sdk-task.ps1 b/eng/common/sdk-task.ps1 index 68119de603e..8d72d803dd2 100644 --- a/eng/common/sdk-task.ps1 +++ b/eng/common/sdk-task.ps1 @@ -4,7 +4,9 @@ Param( [string] $task, [string] $verbosity = 'minimal', [string] $msbuildEngine = $null, - [switch] $restore, + # Restore defaults to on; -restore is retained only so existing consumers that pass it don't break. Use -norestore to opt out. + [switch] $restore = $true, + [switch] $norestore, [switch] $prepareMachine, [switch][Alias('nobl')]$excludeCIBinaryLog, [switch]$noWarnAsError, @@ -18,12 +20,23 @@ $ci = $true $binaryLog = if ($excludeCIBinaryLog) { $false } else { $true } $warnAsError = if ($noWarnAsError) { $false } else { $true } +# Reconcile the restore state before importing tools.ps1: it reads $restore at import time to +# decide whether toolset/SDK acquisition installs. -norestore must win so that skipping restore +# also skips toolset initialization, not just the explicit Restore build below. +if ($norestore) { $restore = $false } + +# sdk-task runs a standalone Arcade SDK task and does not need repo-specific toolset setup. +# Skip importing configure-toolset.ps1 so its side effects (e.g. a repo's configure-toolset.ps1 +# calling exit) don't terminate this script before the task runs. +$disableConfigureToolsetImport = $true + . $PSScriptRoot\tools.ps1 function Print-Usage() { Write-Host "Common settings:" Write-Host " -task Name of Arcade task (name of a project in toolset directory of the Arcade SDK package)" - Write-Host " -restore Restore dependencies" + Write-Host " -restore (Legacy) Restore runs by default; retained for backward compatibility. Use -norestore to skip" + Write-Host " -norestore Skip restoring dependencies" Write-Host " -verbosity Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]" Write-Host " -help Print help and exit" Write-Host "" diff --git a/eng/common/sdk-task.sh b/eng/common/sdk-task.sh index 1cf71bb2aea..a7f1ba060d7 100644 --- a/eng/common/sdk-task.sh +++ b/eng/common/sdk-task.sh @@ -3,7 +3,8 @@ show_usage() { echo "Common settings:" echo " --task Name of Arcade task (name of a project in toolset directory of the Arcade SDK package)" - echo " --restore Restore dependencies" + echo " --restore (Legacy) Restore runs by default; retained for backward compatibility. Use --norestore to skip" + echo " --norestore Skip restoring dependencies" echo " --verbosity Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]" echo " --help Print help and exit" echo "" @@ -50,10 +51,11 @@ binary_log=true configuration="Debug" verbosity="minimal" exclude_ci_binary_log=false -restore=false +# restore defaults to on; --restore is retained only so existing consumers that pass it don't break. Use --norestore to opt out. +restore=true help=false properties='' -warnAsError=true +warn_as_error=true while (($# > 0)); do lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")" @@ -63,7 +65,10 @@ while (($# > 0)); do shift 2 ;; --restore) - restore=true + shift 1 + ;; + --norestore) + restore=false shift 1 ;; --verbosity) @@ -75,8 +80,8 @@ while (($# > 0)); do exclude_ci_binary_log=true shift 1 ;; - --noWarnAsError) - warnAsError=false + --nowarnaserror) + warn_as_error=false shift 1 ;; --help) @@ -97,6 +102,11 @@ if $help; then exit 0 fi +# sdk-task runs a standalone Arcade SDK task and does not need repo-specific toolset setup. +# Skip importing configure-toolset.sh so its side effects (e.g. a repo's configure-toolset.sh +# calling exit) don't terminate this script before the task runs. +disable_configure_toolset_import=1 + . "$scriptroot/tools.sh" InitializeToolset diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index de32a6da377..ebc31f7ecdc 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -13,6 +13,12 @@ # Set to true to output binary log from msbuild. Note that emitting binary log slows down the build. [bool]$binaryLog = if (Test-Path variable:binaryLog) { $binaryLog } else { $ci -and !$excludeCIBinarylog } +# Set to true to use the pipelines logger which will enable Azure logging output. +# https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md +# This flag is meant as a temporary opt-in for the feature while validating it across +# our consumers. It will be deleted in the future. +[bool]$pipelinesLog = if (Test-Path variable:pipelinesLog) { $pipelinesLog } else { $ci } + # Turns on machine preparation/clean up code that changes the machine state (e.g. kills build processes). [bool]$prepareMachine = if (Test-Path variable:prepareMachine) { $prepareMachine } else { $false } @@ -65,6 +71,8 @@ $ErrorActionPreference = 'Stop' # True when the build is running within the VMR. [bool]$fromVMR = if (Test-Path variable:fromVMR) { $fromVMR } else { $false } +[bool]$disablePipelineSetResult = if (Test-Path variable:disablePipelineSetResult) { $disablePipelineSetResult } else { $false } + function Create-Directory ([string[]] $path) { New-Item -Path $path -Force -ItemType 'Directory' | Out-Null } @@ -432,11 +440,31 @@ function InitializeVisualStudioMSBuild([object]$vsRequirements = $null) { $msbuildVersionDir = if ([int]$vsMajorVersion -lt 16) { "$vsMajorVersion.0" } else { "Current" } $local:BinFolder = Join-Path $vsInstallDir "MSBuild\$msbuildVersionDir\Bin" - $local:Prefer64bit = if (Get-Member -InputObject $vsRequirements -Name 'Prefer64bit') { $vsRequirements.Prefer64bit } else { $false } - if ($local:Prefer64bit -and (Test-Path(Join-Path $local:BinFolder "amd64"))) { - $global:_MSBuildExe = Join-Path $local:BinFolder "amd64\msbuild.exe" - } else { - $global:_MSBuildExe = Join-Path $local:BinFolder "msbuild.exe" + + # Use the MSBuild matching the host's process architecture (e.g. amd64 or arm64), + # falling back to the 32-bit MSBuild in the root Bin folder when no matching subfolder exists. + + # Determine the architecture of the current process, accounting for a 32-bit process + # running on a 64-bit OS (PROCESSOR_ARCHITEW6432 holds the real machine architecture). + $local:ProcessArchitecture = $env:PROCESSOR_ARCHITECTURE + if (($local:ProcessArchitecture -eq 'x86') -and ($env:PROCESSOR_ARCHITEW6432)) { + $local:ProcessArchitecture = $env:PROCESSOR_ARCHITEW6432 + } + + # Map the architecture to the corresponding MSBuild subfolder. The 32-bit MSBuild lives in the + # root Bin folder, so x86 maps to an empty subfolder. + $local:MSBuildArchSubFolder = switch ($local:ProcessArchitecture) { + 'AMD64' { 'amd64' } + 'ARM64' { 'arm64' } + default { '' } + } + + $global:_MSBuildExe = Join-Path $local:BinFolder "msbuild.exe" + if ($local:MSBuildArchSubFolder) { + $local:ArchMSBuildExe = Join-Path $local:BinFolder (Join-Path $local:MSBuildArchSubFolder "msbuild.exe") + if (Test-Path $local:ArchMSBuildExe) { + $global:_MSBuildExe = $local:ArchMSBuildExe + } } return $global:_MSBuildExe @@ -531,6 +559,16 @@ function LocateVisualStudio([object]$vsRequirements = $null){ } function InitializeBuildTool() { + # Allow a caller (e.g. a bootstrap script running out-of-proc) to inject the build tool via + # environment variables instead of the in-proc $global:_BuildTool variable. Only Path and + # Command are consumed by the MSBuild function below, so those are all that's needed. + if ($env:_BuildToolPath) { + return $global:_BuildTool = @{ + Path = $env:_BuildToolPath + Command = $env:_BuildToolCommand + } + } + if (Test-Path variable:global:_BuildTool) { # If the requested msbuild parameters do not match, clear the cached variables. if($global:_BuildTool.Contains('ExcludePrereleaseVS') -and $global:_BuildTool.ExcludePrereleaseVS -ne $excludePrereleaseVS) { @@ -558,7 +596,7 @@ function InitializeBuildTool() { } $dotnetPath = Join-Path $dotnetRoot (GetExecutableFileName 'dotnet') - $buildTool = @{ Path = $dotnetPath; Command = 'msbuild'; Tool = 'dotnet'; Framework = 'net' } + $buildTool = @{ Path = $dotnetPath; Command = 'msbuild' } } elseif ($msbuildEngine -eq "vs") { try { $msbuildPath = InitializeVisualStudioMSBuild @@ -567,7 +605,7 @@ function InitializeBuildTool() { ExitWithExitCode 1 } - $buildTool = @{ Path = $msbuildPath; Command = ""; Tool = "vs"; Framework = "netframework"; ExcludePrereleaseVS = $excludePrereleaseVS } + $buildTool = @{ Path = $msbuildPath; Command = ""; ExcludePrereleaseVS = $excludePrereleaseVS } } else { Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Unexpected value of -msbuildEngine: '$msbuildEngine'." ExitWithExitCode 1 @@ -683,7 +721,17 @@ function InitializeToolset() { $downloadArgs += "--configfile" $downloadArgs += $nugetConfig } - DotNet @downloadArgs + + # 'dotnet package download' fails outright if any source in the repo's NuGet.config is + # unavailable (for example a transport feed that was decommissioned after a release). The + # Arcade SDK is always published to the public dotnet-eng feed, so if the config-driven + # download fails, retry once against that feed directly (which ignores the other sources) + # before giving up, so a single dead source doesn't block the build. + $downloadExitCode = DotNet -ignoreFailure @downloadArgs + if ($downloadExitCode) { + Write-Host "Restoring the Arcade SDK from the configured sources failed; retrying from the public dotnet-eng feed." + DotNet @downloadArgs --source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" + } $packageDir = Join-Path $nugetPackageCachePath (Join-Path 'microsoft.dotnet.arcade.sdk' $toolsetVersion) $packageToolsetDir = Join-Path $packageDir 'toolset' @@ -706,7 +754,7 @@ function InitializeToolset() { } function ExitWithExitCode([int] $exitCode) { - if ($ci -and $prepareMachine) { + if ($prepareMachine) { Stop-Processes } exit $exitCode @@ -741,17 +789,23 @@ function MSBuild() { Write-PipelineTelemetryError -Category 'Build' -Message 'Binary log must be enabled in CI build, or explicitly opted-out from with the -excludeCIBinarylog switch.' ExitWithExitCode 1 } - - # Node reuse must be disabled in CI builds unless explicitly opted in via MSBUILD_NODEREUSE_ENABLED. - # Internal testing only; this env var will be replaced with a switch (https://github.com/dotnet/arcade/issues/17013) and must not be depended on. - if ($nodeReuse -and $env:MSBUILD_NODEREUSE_ENABLED -ne "1") { - Write-PipelineTelemetryError -Category 'Build' -Message 'Node reuse must be disabled in CI build.' - ExitWithExitCode 1 - } } $buildTool = InitializeBuildTool + if ($pipelinesLog) { + $toolsetBuildProject = InitializeToolset + $basePath = Split-Path -parent $toolsetBuildProject + $selectedPath = Join-Path $basePath (Join-Path 'net' 'Microsoft.DotNet.ArcadeLogging.dll') + + # Only inject the logger when it's present. A last-known-good Arcade used to bootstrap + # the build may not ship the logger yet, so its absence must not be a hard error. + # Specify the logger type explicitly so loading is deterministic. + if (Test-Path $selectedPath) { + $args += "/logger:Microsoft.DotNet.ArcadeLogging.PipelinesLogger,$selectedPath" + } + } + $cmdArgs = "$($buildTool.Command) /m /nologo /clp:Summary /v:$verbosity /nr:$nodeReuse /p:ContinuousIntegrationBuild=$ci" # Add -mt flag for MSBuild multithreaded mode if enabled via environment variable @@ -789,14 +843,9 @@ function MSBuild() { # The build already logged an error, that's the reason it failed. Producing an error here only adds noise. Write-Host "Build failed with exit code $exitCode. Check errors above." -ForegroundColor Red - $buildLog = GetMSBuildBinaryLogCommandLineArgument $args - if ($null -ne $buildLog) { - Write-Host "See log: $buildLog" -ForegroundColor DarkGray - } - # When running on Azure Pipelines, override the returned exit code to avoid double logging. - # Skip this when the build is a child of the VMR build. - if ($ci -and $env:SYSTEM_TEAMPROJECT -ne $null -and !$fromVMR) { + # Skip this when the build is a child of the VMR build, or when -disablePipelineSetResult is set so the real exit code propagates. + if ($ci -and $env:SYSTEM_TEAMPROJECT -ne $null -and !$fromVMR -and !$disablePipelineSetResult) { Write-PipelineSetResult -Result "Failed" -Message "msbuild execution failed." # Exiting with an exit code causes the azure pipelines task to log yet another "noise" error # The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error @@ -811,7 +860,7 @@ function MSBuild() { # Executes a dotnet command with arguments passed to the function. # Terminates the script if the command fails. # -function DotNet() { +function DotNet([switch]$ignoreFailure) { $dotnetRoot = InitializeDotNetCli -install:$restore $dotnetPath = Join-Path $dotnetRoot (GetExecutableFileName 'dotnet') @@ -830,9 +879,15 @@ function DotNet() { $exitCode = Exec-Process $dotnetPath $cmdArgs if ($exitCode -ne 0) { + # When -ignoreFailure is set, return the exit code to the caller so it can implement + # its own fallback logic instead of terminating the script. + if ($ignoreFailure) { + return $exitCode + } + Write-Host "dotnet command failed with exit code $exitCode. Check errors above." -ForegroundColor Red - if ($ci -and $env:SYSTEM_TEAMPROJECT -ne $null -and !$fromVMR) { + if ($ci -and $env:SYSTEM_TEAMPROJECT -ne $null -and !$fromVMR -and !$disablePipelineSetResult) { Write-PipelineSetResult -Result "Failed" -Message "dotnet command execution failed." ExitWithExitCode 0 } else { @@ -841,23 +896,6 @@ function DotNet() { } } -function GetMSBuildBinaryLogCommandLineArgument($arguments) { - foreach ($argument in $arguments) { - if ($argument -ne $null) { - $arg = $argument.Trim() - if ($arg.StartsWith('/bl:', "OrdinalIgnoreCase")) { - return $arg.Substring('/bl:'.Length) - } - - if ($arg.StartsWith('/binaryLogger:', 'OrdinalIgnoreCase')) { - return $arg.Substring('/binaryLogger:'.Length) - } - } - } - - return $null -} - function GetExecutableFileName($baseName) { if (IsWindowsPlatform) { return "$baseName.exe" diff --git a/eng/common/tools.sh b/eng/common/tools.sh index 3164fff333a..cd31d8a0a0e 100755 --- a/eng/common/tools.sh +++ b/eng/common/tools.sh @@ -8,6 +8,16 @@ ci=${ci:-false} # Build mode source_build=${source_build:-false} +# Set to true to use the pipelines logger which will enable Azure logging output. +# https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md +# This flag is meant as a temporary opt-in for the feature while validating it across +# our consumers. It will be deleted in the future. +if [[ "$ci" == true ]]; then + pipelines_log=${pipelines_log:-true} +else + pipelines_log=${pipelines_log:-false} +fi + # Build configuration. Common values include 'Debug' and 'Release', but the repository may use other names. configuration=${configuration:-'Debug'} @@ -68,6 +78,8 @@ runtime_source_feed_key=${runtime_source_feed_key:-''} # True when the build is running within the VMR. from_vmr=${from_vmr:-false} +disable_pipeline_set_result=${disable_pipeline_set_result:-false} + # Resolve any symlinks in the given path. function ResolvePath { local path=$1 @@ -353,6 +365,15 @@ function GetDotNetInstallScript { } function InitializeBuildTool { + # Allow a caller (e.g. a bootstrap script running out-of-proc) to inject the build tool via + # environment variables instead of the in-proc _InitializeBuildTool variable. Only the tool path and + # command are consumed by the MSBuild function below, so those are all that's needed. + if [[ -n "${_BuildToolPath:-}" ]]; then + _InitializeBuildTool="$_BuildToolPath" + _InitializeBuildToolCommand="$_BuildToolCommand" + return + fi + if [[ -n "${_InitializeBuildTool:-}" ]]; then return fi @@ -433,7 +454,16 @@ function InitializeToolset { if [[ -n "$nuget_config" ]]; then download_args+=("--configfile" "$nuget_config") fi - DotNet "${download_args[@]}" + + # 'dotnet package download' fails outright if any source in the repo's NuGet.config is + # unavailable (for example a transport feed that was decommissioned after a release). The + # Arcade SDK is always published to the public dotnet-eng feed, so if the config-driven + # download fails, retry once against that feed directly (which ignores the other sources) + # before giving up, so a single dead source doesn't block the build. + if ! DotNet true "${download_args[@]}"; then + echo "Restoring the Arcade SDK from the configured sources failed; retrying from the public dotnet-eng feed." + DotNet "${download_args[@]}" --source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" + fi local package_dir="$_InitializeNuGetPackageCachePath/microsoft.dotnet.arcade.sdk/$toolset_version" @@ -457,7 +487,7 @@ function InitializeToolset { } function ExitWithExitCode { - if [[ "$ci" == true && "$prepare_machine" == true ]]; then + if [[ "$prepare_machine" == true ]]; then StopProcesses fi exit $1 @@ -472,6 +502,15 @@ function StopProcesses { } function DotNet { + # When the first argument is 'true' or 'false' it controls the exit behavior on failure: + # 'true' returns the dotnet exit code to the caller (so it can implement its own fallback), + # while the default terminates the script. Any other first argument is treated as a dotnet argument. + local ignore_failure=false + if [[ "$1" == 'true' || "$1" == 'false' ]]; then + ignore_failure="$1" + shift + fi + InitializeDotNetCli $restore local dotnet_path="$_InitializeDotNetCli/dotnet" @@ -480,9 +519,14 @@ function DotNet { "$dotnet_path" "$@" || { local exit_code=$? + + if [[ "$ignore_failure" == true ]]; then + return $exit_code + fi + echo "dotnet command failed with exit code $exit_code. Check errors above." - if [[ "$ci" == true && -n ${SYSTEM_TEAMPROJECT:-} && "$from_vmr" != true ]]; then + if [[ "$ci" == true && -n ${SYSTEM_TEAMPROJECT:-} && "$from_vmr" != true && "$disable_pipeline_set_result" != true ]]; then Write-PipelineSetResult -result "Failed" -message "dotnet command execution failed." ExitWithExitCode 0 else @@ -494,20 +538,28 @@ function DotNet { function MSBuild { if [[ "$ci" == true ]]; then if [[ "$binary_log" != true && "$exclude_ci_binary_log" != true ]]; then - Write-PipelineTelemetryError -category 'Build' "Binary log must be enabled in CI build, or explicitly opted-out from with the -noBinaryLog switch." - ExitWithExitCode 1 - fi - - # Node reuse must be disabled in CI builds unless explicitly opted in via MSBUILD_NODEREUSE_ENABLED. - # Internal testing only; this env var will be replaced with a switch (https://github.com/dotnet/arcade/issues/17013) and must not be depended on. - if [[ "$node_reuse" == true && "${MSBUILD_NODEREUSE_ENABLED:-}" != "1" ]]; then - Write-PipelineTelemetryError -category 'Build' "Node reuse must be disabled in CI build." + Write-PipelineTelemetryError -category 'Build' "Binary log must be enabled in CI build, or explicitly opted-out from with the --excludeCIBinarylog switch." ExitWithExitCode 1 fi fi InitializeBuildTool + local logger_switch=() + if [[ "$pipelines_log" == true ]]; then + InitializeToolset + + local toolset_dir="${_InitializeToolset%/*}" + local selectedPath="$toolset_dir/net/Microsoft.DotNet.ArcadeLogging.dll" + + # Only inject the logger when it's present. A last-known-good Arcade used to bootstrap + # the build may not ship the logger yet, so its absence must not be a hard error. + # Specify the logger type explicitly so loading is deterministic. + if [[ -f "$selectedPath" ]]; then + logger_switch=("-logger:Microsoft.DotNet.ArcadeLogging.PipelinesLogger,$selectedPath") + fi + fi + local warnaserror_switch="" if [[ $warn_as_error == true ]]; then warnaserror_switch="/warnaserror" @@ -523,8 +575,8 @@ function MSBuild { echo "Build failed with exit code $exit_code. Check errors above." # When running on Azure Pipelines, override the returned exit code to avoid double logging. - # Skip this when the build is a child of the VMR build. - if [[ "$ci" == true && -n ${SYSTEM_TEAMPROJECT:-} && "$from_vmr" != true ]]; then + # Skip this when the build is a child of the VMR build, or when -disablePipelineSetResult is set so the real exit code propagates. + if [[ "$ci" == true && -n ${SYSTEM_TEAMPROJECT:-} && "$from_vmr" != true && "$disable_pipeline_set_result" != true ]]; then Write-PipelineSetResult -result "Failed" -message "msbuild execution failed." # Exiting with an exit code causes the azure pipelines task to log yet another "noise" error # The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error @@ -546,7 +598,7 @@ function MSBuild { warnnotaserror_switch="/warnnotaserror:$warn_not_as_error /p:AdditionalWarningsNotAsErrors=$warn_not_as_error" fi - RunBuildTool "$_InitializeBuildToolCommand" /m /nologo /clp:Summary /v:$verbosity /nr:$node_reuse $warnaserror_switch $mt_switch $warnnotaserror_switch /p:TreatWarningsAsErrors=$warn_as_error /p:ContinuousIntegrationBuild=$ci "$@" + RunBuildTool "$_InitializeBuildToolCommand" /m /nologo /clp:Summary /v:$verbosity /nr:$node_reuse $warnaserror_switch $mt_switch $warnnotaserror_switch "${logger_switch[@]}" /p:TreatWarningsAsErrors=$warn_as_error /p:ContinuousIntegrationBuild=$ci "$@" } function GetDarc { diff --git a/global.json b/global.json index fac25d3b1fb..6fb8ec3196f 100644 --- a/global.json +++ b/global.json @@ -22,7 +22,7 @@ "xcopy-msbuild": "18.0.0" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "11.0.0-beta.26330.1", + "Microsoft.DotNet.Arcade.Sdk": "11.0.0-beta.26369.1", "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2" } } diff --git a/src/Compiler/TypedTree/CompilerGlobalState.fs b/src/Compiler/TypedTree/CompilerGlobalState.fs index dfc8bb0abbe..1f46a53ad6c 100644 --- a/src/Compiler/TypedTree/CompilerGlobalState.fs +++ b/src/Compiler/TypedTree/CompilerGlobalState.fs @@ -45,6 +45,11 @@ type NiceNameGenerator() = let count = incrementBucket basicName scopeFileIndex mkName basicName m count + /// Reset the per-(basicName, file) occurrence counters so a subsequent codegen run assigns the + /// same compiler-generated occurrence names a fresh process would. Callers must ensure no + /// concurrent codegen is using this generator when resetting. + member _.ResetCompilerGeneratedNameState() = basicNameCounts.Clear() + /// Generates compiler-generated names marked up with a source code location, but if given the same unique value then /// return precisely the same name. Each name generated also includes the StartLine number of the range passed in /// at the point of first generation. @@ -61,6 +66,12 @@ type StableNiceNameGenerator() = let key = basicName, uniq niceNames.GetOrAddLazy(key, fun (basicName, _) -> innerGenerator.FreshCompilerGeneratedNameOfBasicName(basicName, m)) + /// Reset the stable-name cache and inner occurrence counters, so both the cached stable names and + /// the underlying occurrence counters are cleared. See NiceNameGenerator.ResetCompilerGeneratedNameState. + member _.ResetCompilerGeneratedNameState() = + niceNames.Clear() + innerGenerator.ResetCompilerGeneratedNameState() + [] type PerFileNamingScope internal (nng: NiceNameGenerator, fileIndex: int) = @@ -86,6 +97,15 @@ type internal CompilerGlobalState () = member _.NewFileScope (fileRange: range) = PerFileNamingScope(globalNng, fileRange.FileIndex) + /// Reset all compiler-generated-name occurrence counters on this state, so successive in-process + /// codegen runs over the same source produce identical generated names (a fresh-process layout). + /// Callers must ensure no compilation is concurrently generating names (quiescence). Needed by + /// Edit-and-Continue style scenarios that re-emit from a warm checker. + member _.ResetCompilerGeneratedNameState() = + globalNng.ResetCompilerGeneratedNameState() + globalStableNameGenerator.ResetCompilerGeneratedNameState() + ilxgenGlobalNng.ResetCompilerGeneratedNameState() + /// Unique name generator for stamps attached to lambdas and object expressions type Unique = int64 diff --git a/src/Compiler/TypedTree/CompilerGlobalState.fsi b/src/Compiler/TypedTree/CompilerGlobalState.fsi index cf357d066be..5768089a668 100644 --- a/src/Compiler/TypedTree/CompilerGlobalState.fsi +++ b/src/Compiler/TypedTree/CompilerGlobalState.fsi @@ -18,6 +18,11 @@ type NiceNameGenerator = new: unit -> NiceNameGenerator member FreshCompilerGeneratedName: name: string * m: range -> string + /// Reset the per-(basicName, file) occurrence counters so a subsequent codegen run assigns the + /// same compiler-generated occurrence names a fresh process would. Callers must ensure no + /// concurrent codegen is using this generator when resetting. + member ResetCompilerGeneratedNameState: unit -> unit + /// Generates compiler-generated names marked up with a source code location, but if given the same unique value then /// return precisely the same name. Each name generated also includes the StartLine number of the range passed in /// at the point of first generation. @@ -29,6 +34,10 @@ type StableNiceNameGenerator = new: unit -> StableNiceNameGenerator member GetUniqueCompilerGeneratedName: name: string * m: range * uniq: int64 -> string + /// Reset the stable-name cache and inner occurrence counters, so both the cached stable names and + /// the underlying occurrence counters are cleared. See NiceNameGenerator.ResetCompilerGeneratedNameState. + member ResetCompilerGeneratedNameState: unit -> unit + /// A compiler-generated-name allocation scope bound to a single ImplFile being optimized. /// Instances can only be obtained from CompilerGlobalState.NewFileScope so a call site can't /// accidentally bucket names by the wrong (e.g. inlined-source) file and reintroduce the @@ -58,6 +67,12 @@ type internal CompilerGlobalState = /// under parallel optimization. See https://github.com/dotnet/fsharp/issues/19732. member NewFileScope: fileRange: range -> PerFileNamingScope + /// Reset all compiler-generated-name occurrence counters on this state, so successive in-process + /// codegen runs over the same source produce identical generated names (a fresh-process layout). + /// Callers must ensure no compilation is concurrently generating names (quiescence). Needed by + /// Edit-and-Continue style scenarios that re-emit from a warm checker. + member ResetCompilerGeneratedNameState: unit -> unit + type Unique = int64 /// Concurrency-safe diff --git a/src/Compiler/xlf/FSStrings.cs.xlf b/src/Compiler/xlf/FSStrings.cs.xlf index 86f2f70699a..2a344c5d674 100644 --- a/src/Compiler/xlf/FSStrings.cs.xlf +++ b/src/Compiler/xlf/FSStrings.cs.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Compiler/xlf/FSStrings.de.xlf b/src/Compiler/xlf/FSStrings.de.xlf index 12e8860ae56..eb13919bfaf 100644 --- a/src/Compiler/xlf/FSStrings.de.xlf +++ b/src/Compiler/xlf/FSStrings.de.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Compiler/xlf/FSStrings.es.xlf b/src/Compiler/xlf/FSStrings.es.xlf index 317e1230228..1fc832b7e27 100644 --- a/src/Compiler/xlf/FSStrings.es.xlf +++ b/src/Compiler/xlf/FSStrings.es.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Compiler/xlf/FSStrings.fr.xlf b/src/Compiler/xlf/FSStrings.fr.xlf index c35bfe5ed08..b539a265b93 100644 --- a/src/Compiler/xlf/FSStrings.fr.xlf +++ b/src/Compiler/xlf/FSStrings.fr.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Compiler/xlf/FSStrings.it.xlf b/src/Compiler/xlf/FSStrings.it.xlf index fcbe444c44e..acd4ffcfe20 100644 --- a/src/Compiler/xlf/FSStrings.it.xlf +++ b/src/Compiler/xlf/FSStrings.it.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Compiler/xlf/FSStrings.ja.xlf b/src/Compiler/xlf/FSStrings.ja.xlf index 75b5d835d55..2d199d7f94e 100644 --- a/src/Compiler/xlf/FSStrings.ja.xlf +++ b/src/Compiler/xlf/FSStrings.ja.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Compiler/xlf/FSStrings.ko.xlf b/src/Compiler/xlf/FSStrings.ko.xlf index b495c3a27c8..2611ca958be 100644 --- a/src/Compiler/xlf/FSStrings.ko.xlf +++ b/src/Compiler/xlf/FSStrings.ko.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Compiler/xlf/FSStrings.pl.xlf b/src/Compiler/xlf/FSStrings.pl.xlf index 7d5af0e89d1..27c6d4455ce 100644 --- a/src/Compiler/xlf/FSStrings.pl.xlf +++ b/src/Compiler/xlf/FSStrings.pl.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Compiler/xlf/FSStrings.pt-BR.xlf b/src/Compiler/xlf/FSStrings.pt-BR.xlf index 47f6b1d5cda..df00934621b 100644 --- a/src/Compiler/xlf/FSStrings.pt-BR.xlf +++ b/src/Compiler/xlf/FSStrings.pt-BR.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Compiler/xlf/FSStrings.ru.xlf b/src/Compiler/xlf/FSStrings.ru.xlf index d420b749357..a0958ee1efc 100644 --- a/src/Compiler/xlf/FSStrings.ru.xlf +++ b/src/Compiler/xlf/FSStrings.ru.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Compiler/xlf/FSStrings.tr.xlf b/src/Compiler/xlf/FSStrings.tr.xlf index 43123521b37..509eb6d5ac6 100644 --- a/src/Compiler/xlf/FSStrings.tr.xlf +++ b/src/Compiler/xlf/FSStrings.tr.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Compiler/xlf/FSStrings.zh-Hans.xlf b/src/Compiler/xlf/FSStrings.zh-Hans.xlf index 637d8d2b7a9..7a3c8482ebc 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hans.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hans.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Compiler/xlf/FSStrings.zh-Hant.xlf b/src/Compiler/xlf/FSStrings.zh-Hant.xlf index f4452359da8..e671202ffb2 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hant.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hant.xlf @@ -1,4 +1,4 @@ - + diff --git a/tests/FSharp.Compiler.Service.Tests/CompilerGlobalStateTests.fs b/tests/FSharp.Compiler.Service.Tests/CompilerGlobalStateTests.fs new file mode 100644 index 00000000000..888e79ac50e --- /dev/null +++ b/tests/FSharp.Compiler.Service.Tests/CompilerGlobalStateTests.fs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +module FSharp.Compiler.Service.Tests.CompilerGlobalStateTests + +open FSharp.Compiler.CompilerGlobalState +open FSharp.Compiler.Text.Range +open FSharp.Test.Assert +open Xunit + +[] +let ``NiceNameGenerator drifts across calls and ResetCompilerGeneratedNameState restores a fresh-process layout`` () = + let nng = NiceNameGenerator() + let r = rangeN "niceNameGenerator.fs" 10 + + // First batch: occurrence counters start from zero, so names drift f@10, f@10-1, f@10-2. + let batch1 = [ for _ in 1 .. 3 -> nng.FreshCompilerGeneratedName("f", r) ] + batch1 |> shouldEqual [ "f@10"; "f@10-1"; "f@10-2" ] + + // Without a reset, further calls keep drifting from where the counters left off. + let keepsDriftingWithoutReset = [ for _ in 1 .. 2 -> nng.FreshCompilerGeneratedName("f", r) ] + keepsDriftingWithoutReset |> shouldEqual [ "f@10-3"; "f@10-4" ] + + // Resetting clears the occurrence counters, so a subsequent run reproduces the very first batch. + nng.ResetCompilerGeneratedNameState() + let batch2 = [ for _ in 1 .. 3 -> nng.FreshCompilerGeneratedName("f", r) ] + batch2 |> shouldEqual batch1 + +[] +let ``StableNiceNameGenerator caches by uniq and ResetCompilerGeneratedNameState clears both the cache and the counters`` () = + let gen = StableNiceNameGenerator() + let r = rangeN "stableNiceNameGenerator.fs" 20 + + // First occurrence of "h" for uniq 1. + let first = gen.GetUniqueCompilerGeneratedName("h", r, 1L) + first |> shouldEqual "h@20" + + // A different uniq for the same basic name advances the shared occurrence counter. + let second = gen.GetUniqueCompilerGeneratedName("h", r, 2L) + second |> shouldEqual "h@20-1" + + // Re-querying uniq 1 must return the cached name, not a recomputed (drifted) one, even though + // the shared occurrence counter for "h" has since advanced to produce `second`. + let cachedAgain = gen.GetUniqueCompilerGeneratedName("h", r, 1L) + cachedAgain |> shouldEqual first + + gen.ResetCompilerGeneratedNameState() + + // Replaying the exact same sequence of calls after a reset reproduces the exact same names + // ("h@20" then "h@20-1"), because both the stable-name cache and the shared occurrence + // counter were cleared: a fresh call for uniq 1 is once again the first-ever occurrence. + let afterResetForUniq1 = gen.GetUniqueCompilerGeneratedName("h", r, 1L) + afterResetForUniq1 |> shouldEqual first + + let afterResetForUniq2 = gen.GetUniqueCompilerGeneratedName("h", r, 2L) + afterResetForUniq2 |> shouldEqual second + + // The cache is fully functional again after reset: re-querying uniq 1 still returns the + // cached (post-reset) name rather than drifting further. + let cachedAgainAfterReset = gen.GetUniqueCompilerGeneratedName("h", r, 1L) + cachedAgainAfterReset |> shouldEqual afterResetForUniq1 + + // Prove the stable-name CACHE itself was cleared, not just the inner counters: after another + // reset, the same (name, uniq) key queried with a DIFFERENT range must be recomputed from the + // new range ("h@99"). A stale cache entry would instead return the pre-reset "h@20". + gen.ResetCompilerGeneratedNameState() + let differentRange = rangeN "stableNiceNameGenerator.fs" 99 + let recomputedForUniq1 = gen.GetUniqueCompilerGeneratedName("h", differentRange, 1L) + recomputedForUniq1 |> shouldEqual "h@99" + +[] +let ``CompilerGlobalState.ResetCompilerGeneratedNameState resets all three generators together`` () = + let state = CompilerGlobalState() + let r = rangeN "compilerGlobalState.fs" 30 + + let niceName1 = state.NiceNameGenerator.FreshCompilerGeneratedName("f", r) + let ilxName1 = state.IlxGenNiceNameGenerator.FreshCompilerGeneratedName("g", r) + let stableName1 = state.StableNameGenerator.GetUniqueCompilerGeneratedName("h", r, 1L) + + // Drift each generator away from its first-occurrence name before resetting. + state.NiceNameGenerator.FreshCompilerGeneratedName("f", r) |> ignore + state.IlxGenNiceNameGenerator.FreshCompilerGeneratedName("g", r) |> ignore + state.StableNameGenerator.GetUniqueCompilerGeneratedName("h", r, 2L) |> ignore + + state.ResetCompilerGeneratedNameState() + + let niceName2 = state.NiceNameGenerator.FreshCompilerGeneratedName("f", r) + let ilxName2 = state.IlxGenNiceNameGenerator.FreshCompilerGeneratedName("g", r) + // Replaying the same first call (uniq 1) after the aggregate reset reproduces the original + // stable name, confirming the reset reached the StableNameGenerator too. (StableNiceNameGenerator's + // own tests separately confirm that the reset actually clears its cache, rather than merely + // resetting the shared occurrence counter.) + let stableName2 = state.StableNameGenerator.GetUniqueCompilerGeneratedName("h", r, 1L) + + niceName2 |> shouldEqual niceName1 + ilxName2 |> shouldEqual ilxName1 + stableName2 |> shouldEqual stableName1 diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index d29c8693d18..6193e4f73a4 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -53,6 +53,7 @@ + diff --git a/vsintegration/Directory.Build.targets b/vsintegration/Directory.Build.targets index 6d09285feca..16099d6637c 100644 --- a/vsintegration/Directory.Build.targets +++ b/vsintegration/Directory.Build.targets @@ -14,6 +14,11 @@ + + + + + diff --git a/vsintegration/tests/Directory.Build.targets b/vsintegration/tests/Directory.Build.targets index 14437118703..2bbbb8d4d4c 100644 --- a/vsintegration/tests/Directory.Build.targets +++ b/vsintegration/tests/Directory.Build.targets @@ -1,3 +1,10 @@ + + + + +