Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a6c6ec5
Fix VMR build to use --with-packages for prebuilts
Dec 11, 2025
d1eb4d0
Ensure prebuilt-packages directory exists before passing to build script
Dec 11, 2025
68a5215
Address review feedback: Revert download path and use temp dir for ex…
Dec 11, 2025
c8caa7e
Address review feedback: Extract SDK and packages to temp dir, use --…
Dec 11, 2025
0d28407
Address final review feedback: Download artifacts to temp dir, avoid …
Dec 11, 2025
47a38ba
Address review feedback: define variables, flatten directories, renam…
Dec 11, 2025
d899270
Fix CI failure: Use find for robust tarball discovery and add debug l…
Dec 12, 2025
1fbc728
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Dec 12, 2025
7fb7552
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Dec 12, 2025
de548a3
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Dec 13, 2025
bef71c9
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Dec 13, 2025
ff32e08
Refactor: Move artifact extraction to Prep step and pass args to both…
Dec 13, 2025
eb4f429
Fix CI failure: initialize variable, improve logging, enhance safety
Dec 13, 2025
2ce2ecd
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Dec 13, 2025
ca0c6b3
Fix CI failure: Safely check for artifact directory existence and deb…
Dec 13, 2025
b123eff
Fix CI regression: conditionally check for artifacts directory and ad…
Dec 13, 2025
b948e15
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Dec 15, 2025
872f6ea
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Dec 16, 2025
8174dac
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Dec 17, 2025
97cf0ee
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Dec 17, 2025
88b1a03
Fix reuseBuildArtifactsFrom default and conditionals
Dec 17, 2025
a011185
Refactor script condition to use template expression
Dec 17, 2025
e8267c6
Restore bash condition with fixed parameter default
Dec 17, 2025
5ee43e8
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Dec 18, 2025
2d6520b
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Dec 22, 2025
52a38fc
Fix bash syntax errors and address Copilot review feedback
Dec 23, 2025
91bd3ca
Apply suggestion from @Copilot
csa7mdm Dec 23, 2025
4c3ecea
Merge branch 'main' into fix/issue-4427-vmr-packages
mthalman Jan 5, 2026
986be46
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Jan 5, 2026
9bedef2
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Jan 6, 2026
ff5c3b7
Fix CentOS pipeline: Create artifact staging directories upfront
Jan 26, 2026
6b8d215
Resolve merge conflict: Keep --with-packages logic from PR
Jan 26, 2026
77d8ddf
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Jan 26, 2026
a845eff
Fix cross-platform build issues
Jan 26, 2026
0bf0b0a
Apply code review feedback from PR #3824
Jan 27, 2026
d51e900
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Jan 27, 2026
230479a
Fix step display name by defining it before script block
Jan 27, 2026
9a711c5
Fix YAML syntax: script must precede displayName
Jan 28, 2026
59dd7cd
Merge branch 'main' into fix/issue-4427-vmr-packages
csa7mdm Jan 29, 2026
fc00b62
Apply MichaelSimons code review feedback
Jan 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 114 additions & 16 deletions eng/pipelines/templates/jobs/vmr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ parameters:
# The SDK from its artifacts is copied to $(sourcesPath)/.dotnet
- name: reuseBuildArtifactsFrom
type: object
default: ''
default: []

# Enables usage of the system libraries when building.
- name: useSystemLibraries
Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
image: ${{ parameters.container.image }}
options: $(defaultContainerOptions)

${{ if ne(parameters.reuseBuildArtifactsFrom, '') }}:
${{ if gt(length(parameters.reuseBuildArtifactsFrom), 0) }}:
${{ if eq(parameters.buildPass, '') }}:
# For PR builds, skip the stage 2 build if the stage 1 build fails.
# Otherwise, run the stage 2 build even if the stage 1 build fails so that we can get a complete assessment of the build status.
Expand All @@ -172,7 +172,7 @@ jobs:
${{ else }}:
condition: succeeded()
dependsOn:
- ${{ if ne(parameters.reuseBuildArtifactsFrom, '') }}:
- ${{ if gt(length(parameters.reuseBuildArtifactsFrom), 0) }}:
- ${{ parameters.reuseBuildArtifactsFrom }}
variables:
- ${{ if eq(variables['System.TeamProject'], 'internal') }}:
Expand Down Expand Up @@ -213,6 +213,13 @@ jobs:
- name: artifactsPrepublishDir
value: $(Build.ArtifactStagingDirectory)/prepublish

- name: downloadedArtifactsDir
value: $(Agent.TempDirectory)/downloaded-artifacts
- name: previouslySourceBuiltSdkDir
value: $(Agent.TempDirectory)/previously-source-built-sdk
- name: previouslySourceBuiltArtifactsDir
value: $(Agent.TempDirectory)/previously-source-built-artifacts

- name: successfulJobArtifactName
value: $(Agent.JobName)_Artifacts

Expand Down Expand Up @@ -387,6 +394,26 @@ jobs:
- checkout: self
fetchDepth: 1


# Create artifact staging directories upfront to satisfy 1ES templateContext.outputs validation
# These directories are referenced in templateContext.outputs which validates paths at job start
- ${{ if eq(parameters.targetOS, 'windows') }}:
- script: |
if not exist "$(Build.ArtifactStagingDirectory)\BuildLogs" mkdir "$(Build.ArtifactStagingDirectory)\BuildLogs"
if not exist "$(Build.ArtifactStagingDirectory)\prepublish" mkdir "$(Build.ArtifactStagingDirectory)\prepublish"
if not exist "$(Build.ArtifactStagingDirectory)\artifacts" mkdir "$(Build.ArtifactStagingDirectory)\artifacts"
displayName: Create artifact staging directories
condition: always()

- ${{ if ne(parameters.targetOS, 'windows') }}:
- script: |
mkdir -p "$(Build.ArtifactStagingDirectory)/BuildLogs"
mkdir -p "$(Build.ArtifactStagingDirectory)/prepublish"
mkdir -p "$(Build.ArtifactStagingDirectory)/artifacts"
displayName: Create artifact staging directories
condition: always()


- ${{ if not(parameters.isBuiltFromVmr) }}:
# Synchronize new content in the VMR during PRs
- template: /eng/common/templates/steps/vmr-sync.yml@self
Expand All @@ -402,7 +429,7 @@ jobs:
displayName: Export VMR sources
workingDirectory: $(Build.ArtifactStagingDirectory)

- ${{ if ne(parameters.reuseBuildArtifactsFrom,'') }}:
- ${{ if gt(length(parameters.reuseBuildArtifactsFrom), 0) }}:
- ${{ each reuseBuildArtifacts in parameters.reuseBuildArtifactsFrom }}:
- ${{ if eq(parameters.buildSourceOnly, true) }}:
- template: ../steps/download-artifacts.yml
Expand All @@ -412,7 +439,7 @@ jobs:
downloadFilePatterns: |
assets/*/Private.SourceBuilt.Artifacts.*.tar.gz
assets/*/dotnet-sdk-*.tar.gz
copyDestination: $(sourcesPath)/prereqs/packages/archive/
copyDestination: $(downloadedArtifactsDir)
flattenDirs: true

- ${{ else }}:
Expand All @@ -430,7 +457,7 @@ jobs:

- template: /eng/common/templates/steps/enable-internal-runtimes.yml

- ${{ if and(parameters.excludeRuntimeDependentJobs, eq(parameters.reuseBuildArtifactsFrom, ''), not(parameters.withPreviousSDK)) }}:
- ${{ if and(parameters.excludeRuntimeDependentJobs, eq(length(parameters.reuseBuildArtifactsFrom), 0), not(parameters.withPreviousSDK)) }}:
- script: |
source "$(sourcesPath)/eng/download-source-built-archive.sh"
if [[ $SYSTEM_TEAMPROJECT == "internal" ]]; then
Expand Down Expand Up @@ -576,20 +603,90 @@ jobs:
prepSdk=false
fi


additionalBuildArgs=""



if [[ "$prepSdk" == "false" ]]; then
customPrepArgs="${customPrepArgs} --no-sdk"
mkdir -p $(sourcesPath)/.dotnet
previousSdkPath="$(sourcesPath)/prereqs/packages/archive/dotnet-sdk-*.tar.gz"
eval tar -ozxf "$previousSdkPath" -C "$(sourcesPath)/.dotnet"
eval rm -f "$previousSdkPath"

# Determine where to find the SDK tarball.
# Prefer downloadedArtifactsDir (used when reuseBuildArtifactsFrom has items),
# but fall back to prereqs/packages/archive when it is not available.
sdkSearchDir="$(downloadedArtifactsDir)"
fallbackSdkDir="$(Build.SourcesDirectory)/prereqs/packages/archive"

# If the primary directory does not exist or does not contain an SDK tarball,
# fall back to the prereqs/packages/archive location.
if [ ! -d "$sdkSearchDir" ] || ! find "$sdkSearchDir" -name "dotnet-sdk-*.tar.gz" -print -quit >/dev/null 2>&1; then
echo "Primary SDK directory '$sdkSearchDir' is not usable. Falling back to '$fallbackSdkDir'."
sdkSearchDir="$fallbackSdkDir"
fi

# After fallback, ensure we have a directory to search.
if [ ! -d "$sdkSearchDir" ]; then
echo "##vso[task.logissue type=error]SDK extraction required but neither '$(downloadedArtifactsDir)' nor '$fallbackSdkDir' exists."
echo "Checking Pipeline Workspace content:"
ls -R "$(Pipeline.Workspace)" || true
exit 1
fi

previousSdkPath=$(find "$sdkSearchDir" -name "dotnet-sdk-*.tar.gz" | head -n 1)

if [ -z "$previousSdkPath" ]; then
echo "##vso[task.logissue type=error]dotnet-sdk-*.tar.gz not found in '$sdkSearchDir'."
echo "Contents of '$sdkSearchDir':"
ls -R "$sdkSearchDir" || true
exit 1
fi

echo "Found SDK tarball: $previousSdkPath"
echo "Extracting SDK..."
mkdir -p "$(previouslySourceBuiltSdkDir)"
eval tar -xzf "$previousSdkPath" -C "$(previouslySourceBuiltSdkDir)"

customPrepArgs="${customPrepArgs} --with-sdk $(previouslySourceBuiltSdkDir)"
additionalBuildArgs="--with-sdk $(previouslySourceBuiltSdkDir)"
fi

if [[ '${{ length(parameters.reuseBuildArtifactsFrom) }}' -gt '0' ]]; then
# Verify download directory exists
if [ ! -d "$(downloadedArtifactsDir)" ]; then
echo "##vso[task.logissue type=error]Package extraction required but '$(downloadedArtifactsDir)' does not exist."
echo "Checking Pipeline Workspace content:"
ls -R "$(Pipeline.Workspace)" || true
exit 1
fi

artifactsTarball=$(find "$(downloadedArtifactsDir)" -name "Private.SourceBuilt.Artifacts.*.tar.gz" | head -n 1)

if [ -z "$artifactsTarball" ]; then
echo "##vso[task.logissue type=error]Private.SourceBuilt.Artifacts.*.tar.gz not found in $(downloadedArtifactsDir)"
echo "Contents of downloaded artifacts:"
ls -R "$(downloadedArtifactsDir)"
exit 1
fi

echo "Found Artifacts tarball: $artifactsTarball"
echo "Extracting artifacts..."
mkdir -p "$(previouslySourceBuiltArtifactsDir)"
tar -xzf "$artifactsTarball" -C "$(previouslySourceBuiltArtifactsDir)"

customPrepArgs="${customPrepArgs} --with-packages $(previouslySourceBuiltArtifactsDir)"
additionalBuildArgs="${additionalBuildArgs} --with-packages $(previouslySourceBuiltArtifactsDir)"
fi

echo "Prep arguments: $customPrepArgs"
echo "Additional build arguments: $additionalBuildArgs"

echo "##vso[task.setvariable variable=additionalBuildArgs]--with-sdk $(sourcesPath)/.dotnet"
if [[ -n "$additionalBuildArgs" ]]; then
echo "##vso[task.setvariable variable=additionalBuildArgs]$additionalBuildArgs"
fi

./prep-source-build.sh $customPrepArgs
displayName: Prep the Build
workingDirectory: $(sourcesPath)

- ${{ if ne(parameters.skipBuild, 'true') }}:

- script: |
Expand All @@ -613,7 +710,6 @@ jobs:
# Set up for signing source-built artifacts post-build.
extraBuildProperties="$extraBuildProperties /p:DotNetSourceOnlyPostBuildSign=true"
fi

if [[ '${{ parameters.excludeRuntimeDependentJobs }}' == 'True' ]]; then
customBuildArgs="$customBuildArgs --with-shared-components $(sharedComponentsDir)"
fi
Expand Down Expand Up @@ -664,9 +760,11 @@ jobs:

buildArgs="$(additionalBuildArgs) $customBuildArgs $extraBuildProperties"

for envVar in $customEnvVars; do
customEnvVarsWithBashSyntax="$customEnvVarsWithBashSyntax export $envVar;"
done
if [[ -n "$customEnvVars" ]]; then
for envVar in $customEnvVars; do
customEnvVarsWithBashSyntax="$customEnvVarsWithBashSyntax export $envVar;"
done
fi

eval $customEnvVarsWithBashSyntax
$customPreBuildArgs ./build.sh $buildArgs
Expand Down
8 changes: 4 additions & 4 deletions prep-source-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ function BootstrapArtifacts {
rm -rf "$workingDir"
}

# Attempting to bootstrap without an SDK will fail. So either the --no-sdk flag must be passed
# or a pre-existing .dotnet SDK directory must exist.
if [ "$buildBootstrap" == true ] && [ "$installDotnet" == false ] && [ ! -d "$REPO_ROOT/.dotnet" ]; then
echo " ERROR: --no-sdk requires --no-bootstrap or a pre-existing .dotnet SDK directory. Exiting..."
# Attempting to bootstrap without an SDK will fail. So either the --no-sdk flag must be passed,
# a pre-existing .dotnet SDK directory must exist, or a custom SDK must be provided via --with-sdk.
if [ "$buildBootstrap" == true ] && [ "$installDotnet" == false ] && [ ! -d "$REPO_ROOT/.dotnet" ] && [ -z "$customSdkDir" ]; then
echo " ERROR: --no-sdk requires --no-bootstrap, a pre-existing .dotnet SDK directory, or --with-sdk. Exiting..."
exit 1
fi

Expand Down