msbuild
129 строк · 6.0 Кб
1parameters:
2# This template adds arcade-powered source-build to CI.
3
4# This is a 'steps' template, and is intended for advanced scenarios where the existing build
5# infra has a careful build methodology that must be followed. For example, a repo
6# (dotnet/runtime) might choose to clone the GitHub repo only once and store it as a pipeline
7# artifact for all subsequent jobs to use, to reduce dependence on a strong network connection to
8# GitHub. Using this steps template leaves room for that infra to be included.
9
10# Defines the platform on which to run the steps. See 'eng/common/templates-official/job/source-build.yml'
11# for details. The entire object is described in the 'job' template for simplicity, even though
12# the usage of the properties on this object is split between the 'job' and 'steps' templates.
13platform: {}
14
15steps:
16# Build. Keep it self-contained for simple reusability. (No source-build-specific job variables.)
17- script: |
18set -x
19df -h
20
21# If building on the internal project, the artifact feeds variable may be available (usually only if needed)
22# In that case, call the feed setup script to add internal feeds corresponding to public ones.
23# In addition, add an msbuild argument to copy the WIP from the repo to the target build location.
24# This is because SetupNuGetSources.sh will alter the current NuGet.config file, and we need to preserve those
25# changes.
26internalRestoreArgs=
27if [ '$(dn-bot-dnceng-artifact-feeds-rw)' != '$''(dn-bot-dnceng-artifact-feeds-rw)' ]; then
28# Temporarily work around https://github.com/dotnet/arcade/issues/7709
29chmod +x $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh
30$(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh $(Build.SourcesDirectory)/NuGet.config $(dn-bot-dnceng-artifact-feeds-rw)
31internalRestoreArgs='/p:CopyWipIntoInnerSourceBuildRepo=true'
32
33# The 'Copy WIP' feature of source build uses git stash to apply changes from the original repo.
34# This only works if there is a username/email configured, which won't be the case in most CI runs.
35git config --get user.email
36if [ $? -ne 0 ]; then
37git config user.email dn-bot@microsoft.com
38git config user.name dn-bot
39fi
40fi
41
42# If building on the internal project, the internal storage variable may be available (usually only if needed)
43# In that case, add variables to allow the download of internal runtimes if the specified versions are not found
44# in the default public locations.
45internalRuntimeDownloadArgs=
46if [ '$(dotnetbuilds-internal-container-read-token-base64)' != '$''(dotnetbuilds-internal-container-read-token-base64)' ]; then
47internalRuntimeDownloadArgs='/p:DotNetRuntimeSourceFeed=https://dotnetbuilds.blob.core.windows.net/internal /p:DotNetRuntimeSourceFeedKey=$(dotnetbuilds-internal-container-read-token-base64) --runtimesourcefeed https://dotnetbuilds.blob.core.windows.net/internal --runtimesourcefeedkey $(dotnetbuilds-internal-container-read-token-base64)'
48fi
49
50buildConfig=Release
51# Check if AzDO substitutes in a build config from a variable, and use it if so.
52if [ '$(_BuildConfig)' != '$''(_BuildConfig)' ]; then
53buildConfig='$(_BuildConfig)'
54fi
55
56officialBuildArgs=
57if [ '${{ and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}' = 'True' ]; then
58officialBuildArgs='/p:DotNetPublishUsingPipelines=true /p:OfficialBuildId=$(BUILD.BUILDNUMBER)'
59fi
60
61targetRidArgs=
62if [ '${{ parameters.platform.targetRID }}' != '' ]; then
63targetRidArgs='/p:TargetRid=${{ parameters.platform.targetRID }}'
64fi
65
66runtimeOsArgs=
67if [ '${{ parameters.platform.runtimeOS }}' != '' ]; then
68runtimeOsArgs='/p:RuntimeOS=${{ parameters.platform.runtimeOS }}'
69fi
70
71baseOsArgs=
72if [ '${{ parameters.platform.baseOS }}' != '' ]; then
73baseOsArgs='/p:BaseOS=${{ parameters.platform.baseOS }}'
74fi
75
76publishArgs=
77if [ '${{ parameters.platform.skipPublishValidation }}' != 'true' ]; then
78publishArgs='--publish'
79fi
80
81assetManifestFileName=SourceBuild_RidSpecific.xml
82if [ '${{ parameters.platform.name }}' != '' ]; then
83assetManifestFileName=SourceBuild_${{ parameters.platform.name }}.xml
84fi
85
86${{ coalesce(parameters.platform.buildScript, './build.sh') }} --ci \
87--configuration $buildConfig \
88--restore --build --pack $publishArgs -bl \
89$officialBuildArgs \
90$internalRuntimeDownloadArgs \
91$internalRestoreArgs \
92$targetRidArgs \
93$runtimeOsArgs \
94$baseOsArgs \
95/p:SourceBuildNonPortable=${{ parameters.platform.nonPortable }} \
96/p:ArcadeBuildFromSource=true \
97/p:AssetManifestFileName=$assetManifestFileName
98displayName: Build
99
100# Upload build logs for diagnosis.
101- task: CopyFiles@2
102displayName: Prepare BuildLogs staging directory
103inputs:
104SourceFolder: '$(Build.SourcesDirectory)'
105Contents: |
106**/*.log
107**/*.binlog
108artifacts/source-build/self/prebuilt-report/**
109TargetFolder: '$(Build.StagingDirectory)/BuildLogs'
110CleanTargetFolder: true
111continueOnError: true
112condition: succeededOrFailed()
113
114- task: 1ES.PublishPipelineArtifact@1
115displayName: Publish BuildLogs
116inputs:
117targetPath: '$(Build.StagingDirectory)/BuildLogs'
118artifactName: BuildLogs_SourceBuild_${{ parameters.platform.name }}_Attempt$(System.JobAttempt)
119continueOnError: true
120condition: succeededOrFailed()
121
122# Manually inject component detection so that we can ignore the source build upstream cache, which contains
123# a nupkg cache of input packages (a local feed).
124# This path must match the upstream cache path in property 'CurrentRepoSourceBuiltNupkgCacheDir'
125# in src\Microsoft.DotNet.Arcade.Sdk\tools\SourceBuild\SourceBuildArcade.targets
126- task: ComponentGovernanceComponentDetection@0
127displayName: Component Detection (Exclude upstream cache)
128inputs:
129ignoreDirectories: '$(Build.SourcesDirectory)/artifacts/source-build/self/src/artifacts/obj/source-built-upstream-cache'
130