Skip to content

Commit 8b19175

Browse files
authored
58217464 - Enable EO-compliant PREfast and Compiler Warning Checks for the WinAppSDK repo (#5611)
* Update WindowsAppSDK-Build-Per-Platform-Stage.yml * Update WindowsAppSDK-Build-Stage.yml * Update WindowsAppSDK-BuildFoundation-AnyCPU-Steps.yml * Update WindowsAppSDK-BuildFoundation-Steps.yml * Update WindowsAppSDK-BuildMRT-Steps.yml * Update WindowsAppSDK-CommonVariables.yml * Update WindowsAppSDK-BuildInstaller-Steps.yml * Update WindowsAppSDK-BuildVSIX-Steps.yml * Update WindowsAppSDK-BuildVSIX-Stage.yml * Update WindowsAppSDK-BuildInstaller-Stage.yml * Update WindowsAppSDK-BuildInstaller-Stage.yml * Update WindowsAppSDK-BuildInstaller-Steps.yml
1 parent a6b221a commit 8b19175

10 files changed

+73
-38
lines changed

build/AzurePipelinesTemplates/WindowsAppSDK-Build-Per-Platform-Stage.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ stages:
7878
value: $[coalesce(variables.compilerOverridePackageVersion, variables.global_CompilerOverridePackageVersion)]
7979
- name: localCompilerOverrideNupkgVersion
8080
value: $[coalesce(variables.compilerOverrideNupkgVersion, variables.global_CompilerOverrideNupkgVersion)]
81+
- name: ob_sdl_checkCompliantCompilerWarnings
82+
value: true # This setting has no effect unless ob_sdl_msbuildOverride below is also set to true.
83+
- name: ob_sdl_prefast_runDuring
84+
value: 'Guardian' # The default 'Build' setting does not match the fact that we are calling msbuild.exe directly.
85+
- name: ob_sdl_msbuildOverride
86+
value: true # Because we are calling MSBuild directly instead of through the MSBuild@1 or VSBuild@1 tasks.
8187
steps:
8288
- script: |
8389
echo Build.SourceBranch=$(Build.SourceBranch)
@@ -91,6 +97,9 @@ stages:
9197
echo localCompilerOverrideNupkgVersion=$(localCompilerOverrideNupkgVersion)
9298
echo System.PullRequest.targetBranchName=$(System.PullRequest.targetBranchName)
9399
echo mySourceBranch=$(mySourceBranch)
100+
echo ob_sdl_msbuildOverride=$(ob_sdl_msbuildOverride)
101+
echo ob_sdl_prefast_runDuring=$(ob_sdl_prefast_runDuring)
102+
echo ob_sdl_checkCompliantCompilerWarnings=$(ob_sdl_checkCompliantCompilerWarnings)
94103
95104
- template: WindowsAppSDK-BuildFoundation-Steps.yml@self
96105
parameters:
@@ -99,13 +108,6 @@ stages:
99108
runApiScan: ${{ parameters.runApiScan }}
100109
runPREfast: ${{ parameters.runPREfast }}
101110

102-
# This is a temporarily workaround to avoid getting non-fatal "folder C:\__t\NativeCompilerPrefast not found"
103-
# errors from the Guardian PREfast task, which shouldn't even be run in the first place, because its pre-
104-
# requisite of isNative=true isn't met currently.
105-
- script: |
106-
md "C:\__t\NativeCompilerPrefast"
107-
displayName: 'Creating C:\__t\NativeCompilerPrefast to prevent errors from Guardian PREfast'
108-
109111
- job: BuildMRT
110112
pool:
111113
# read more about custom job pool types at https://aka.ms/obpipelines/yaml/jobs
@@ -161,6 +163,12 @@ stages:
161163
value: $[coalesce(variables.compilerOverridePackageVersion, variables.global_CompilerOverridePackageVersion)]
162164
- name: localCompilerOverrideNupkgVersion
163165
value: $[coalesce(variables.compilerOverrideNupkgVersion, variables.global_CompilerOverrideNupkgVersion)]
166+
- name: ob_sdl_checkCompliantCompilerWarnings
167+
value: true # This setting has no effect unless ob_sdl_msbuildOverride below is also set to true.
168+
- name: ob_sdl_prefast_runDuring
169+
value: 'Guardian' # The default 'Build' setting does not match the fact that we are calling msbuild.exe directly.
170+
- name: ob_sdl_msbuildOverride
171+
value: true # Because we are calling MSBuild directly instead of through the MSBuild@1 or VSBuild@1 tasks.
164172
steps:
165173
- script: |
166174
echo Build.SourceBranch=$(Build.SourceBranch)
@@ -174,6 +182,9 @@ stages:
174182
echo localCompilerOverrideNupkgVersion=$(localCompilerOverrideNupkgVersion)
175183
echo System.PullRequest.targetBranchName=$(System.PullRequest.targetBranchName)
176184
echo mySourceBranch=$(mySourceBranch)
185+
echo ob_sdl_msbuildOverride=$(ob_sdl_msbuildOverride)
186+
echo ob_sdl_prefast_runDuring=$(ob_sdl_prefast_runDuring)
187+
echo ob_sdl_checkCompliantCompilerWarnings=$(ob_sdl_checkCompliantCompilerWarnings)
177188
178189
- template: WindowsAppSDK-BuildMRT-Steps.yml@self
179190
parameters:
@@ -182,13 +193,6 @@ stages:
182193
runPREfast : ${{ parameters.runPREfast }}
183194
runApiScan : ${{ parameters.runApiScan }}
184195

185-
# This is a temporarily workaround to avoid getting non-fatal "folder C:\__t\NativeCompilerPrefast not found"
186-
# errors from the Guardian PREfast task, which shouldn't even be run in the first place, because its pre-
187-
# requisite of isNative=true isn't met currently.
188-
- script: |
189-
md "C:\__t\NativeCompilerPrefast"
190-
displayName: 'Creating C:\__t\NativeCompilerPrefast to prevent errors from Guardian PREfast'
191-
192196
- job: ExtractMatrix
193197
pool:
194198
type: windows

build/AzurePipelinesTemplates/WindowsAppSDK-Build-Stage.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,16 @@ stages:
5959
ob_sdl_apiscan_enabled: false
6060
ob_sdl_apiscan_softwareFolder: '$(build.SourcesDirectory)\BuildOutput\Release\AnyCPU'
6161
ob_sdl_apiscan_symbolsFolder: '$(build.SourcesDirectory)\BuildOutput\Release\AnyCPU;SRV*https://symweb.azurefd.net'
62+
ob_sdl_checkCompliantCompilerWarnings: true # This setting has no effect unless ob_sdl_msbuildOverride below is also set to true.
63+
ob_sdl_prefast_runDuring: 'Guardian' # The default 'Build' setting does not match the fact that we are calling msbuild.exe directly.
64+
ob_sdl_msbuildOverride: true # Because we are calling MSBuild directly instead of through the MSBuild@1 or VSBuild@1 tasks.
6265
steps:
6366
- template: WindowsAppSDK-BuildFoundation-AnyCPU-Steps.yml@self
6467
parameters:
6568
SignOutput: ${{ parameters.SignOutput }}
6669
IsOneBranch: ${{ parameters.IsOneBranch }}
6770
runPREfast : ${{ parameters.runPREfast }}
6871

69-
# This is a temporarily workaround to avoid getting non-fatal "folder C:\__t\NativeCompilerPrefast not found"
70-
# errors from the Guardian PREfast task, which shouldn't even be run in the first place, because its pre-
71-
# requisite of isNative=true isn't met currently.
72-
- script: |
73-
md "C:\__t\NativeCompilerPrefast"
74-
displayName: 'Creating C:\__t\NativeCompilerPrefast to prevent errors from Guardian PREfast'
75-
7672
# extract BuildFoundation and BuildMRT into WindowsAppSDK-Build-Stage-Per-Platform.yml. Separate the build stage per platform
7773

7874
- template: WindowsAppSDK-Build-Per-Platform-Stage.yml@self

build/AzurePipelinesTemplates/WindowsAppSDK-BuildFoundation-AnyCPU-Steps.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ steps:
3939
# Generally speaking, we leave it to the external repos to scan the bits in their packages.
4040
excludedPaths: |
4141
$(Build.SourcesDirectory)\packages
42+
# Explicitly specify the EO-compliant rule set, as the default Sdl.Recommended.Warning.ruleset is not EO-compliant.
43+
rulesetName: Custom
44+
customRuleset: $(Agent.ToolsDirectory)\NativeCompilerStaticAnalysisRuleset\mandatory_to_fix.ruleset
4245
continueOnError: true
4346
env:
4447
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
@@ -77,4 +80,4 @@ steps:
7780
- task: PublishBuildArtifacts@1
7881
inputs:
7982
PathtoPublish: '$(ob_outputDirectory)'
80-
artifactName: '$(ob_artifactBaseName)'
83+
artifactName: '$(ob_artifactBaseName)'

build/AzurePipelinesTemplates/WindowsAppSDK-BuildFoundation-Steps.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ steps:
8585
# Generally speaking, we leave it to the external repos to scan the bits in their packages.
8686
excludedPaths: |
8787
$(Agent.ToolsDirectory)\uCRT\#$(Build.SourcesDirectory)\obj\$(buildConfiguration)\$(buildPlatform)#$(Build.SourcesDirectory)\packages
88+
# Explicitly specify the EO-compliant rule set, as the default Sdl.Recommended.Warning.ruleset is not EO-compliant.
89+
rulesetName: Custom
90+
customRuleset: $(Agent.ToolsDirectory)\NativeCompilerStaticAnalysisRuleset\mandatory_to_fix.ruleset
8891
env:
8992
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
9093
continueOnError: true

build/AzurePipelinesTemplates/WindowsAppSDK-BuildInstaller-Stage.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ stages:
4040
value: $[coalesce(variables.compilerOverridePackageVersion, variables.global_CompilerOverridePackageVersion)]
4141
- name: localCompilerOverrideNupkgVersion
4242
value: $[coalesce(variables.compilerOverrideNupkgVersion, variables.global_CompilerOverrideNupkgVersion)]
43+
- name: ob_sdl_checkCompliantCompilerWarnings
44+
value: true
45+
- name: ob_sdl_prefast_runDuring
46+
value: 'Build'
47+
- name: ob_sdl_msbuildOverride
48+
value: true
4349
condition: ne(variables.LatestOfficialBuildID, '')
4450
steps:
4551
- script: |
@@ -52,7 +58,9 @@ stages:
5258
echo localCompilerOverridePackageName=$(localCompilerOverridePackageName)
5359
echo localCompilerOverridePackageVersion=$(localCompilerOverridePackageVersion)
5460
echo localCompilerOverrideNupkgVersion=$(localCompilerOverrideNupkgVersion)
55-
echo System.PullRequest.targetBranchName=$(System.PullRequest.targetBranchName)
56-
echo mySourceBranch=$(mySourceBranch)
57-
61+
echo System.PullRequest.targetBranchName=$(System.PullRequest.targetBranchName)
62+
echo ob_sdl_checkCompliantCompilerWarnings=$(ob_sdl_checkCompliantCompilerWarnings)
63+
echo ob_sdl_prefast_runDuring=$(ob_sdl_prefast_runDuring)
64+
echo ob_sdl_msbuildOverride=$(ob_sdl_msbuildOverride)
65+
5866
- template: WindowsAppSDK-BuildInstaller-Steps.yml@self

build/AzurePipelinesTemplates/WindowsAppSDK-BuildInstaller-Steps.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,19 +224,24 @@ steps:
224224
${{ if eq( parameters.runStaticAnalysis, 'true') }}:
225225
createLogFile: true
226226

227-
- ${{ if eq(parameters.runStaticAnalysis, 'true') }}:
228-
- task: SDLNativeRules@3
229-
condition: and(succeeded(), eq(variables['buildConfiguration'], 'Release'), eq(variables['buildPlatform'], 'x64'))
230-
displayName: Run the PREfast SDL Native Rules
231-
inputs:
232-
userProvideBuildInfo: auto
233-
toolVersion: Latest
234-
# Generally speaking, we leave it to the external repos to scan the bits in their packages.
235-
excludedPaths: |
236-
$(Build.SourcesDirectory)\packages
237-
continueOnError: true
238-
env:
239-
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
227+
# The VSBuild@1 task above seems to be able to do inline PREfast scanning with the EO-compliant ruleset now. So, we don't seem to
228+
# need the following any more. Commenting it out for now and observe a bit more. Remove it when we feel comfortable.
229+
#- ${{ if eq(parameters.runStaticAnalysis, 'true') }}:
230+
# - task: SDLNativeRules@3
231+
# condition: and(succeeded(), eq(variables['buildConfiguration'], 'Release'), eq(variables['buildPlatform'], 'x64'))
232+
# displayName: Run the PREfast SDL Native Rules
233+
# inputs:
234+
# userProvideBuildInfo: auto
235+
# toolVersion: Latest
236+
# # Generally speaking, we leave it to the external repos to scan the bits in their packages.
237+
# excludedPaths: |
238+
# $(Build.SourcesDirectory)\packages
239+
# # Explicitly specify the EO-compliant rule set, as the default Sdl.Recommended.Warning.ruleset is not EO-compliant.
240+
# rulesetName: Custom
241+
# customRuleset: $(Agent.ToolsDirectory)\NativeCompilerStaticAnalysisRuleset\mandatory_to_fix.ruleset
242+
# continueOnError: true
243+
# env:
244+
# SYSTEM_ACCESSTOKEN: $(System.AccessToken)
240245

241246
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
242247
displayName: 'Component Governance Detection'

build/AzurePipelinesTemplates/WindowsAppSDK-BuildMRT-Steps.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ steps:
4646
# Generally speaking, we leave it to the external repos to scan the bits in their packages.
4747
excludedPaths: |
4848
$(Build.SourcesDirectory)\packages
49+
# Explicitly specify the EO-compliant rule set, as the default Sdl.Recommended.Warning.ruleset is not EO-compliant.
50+
rulesetName: Custom
51+
customRuleset: $(Agent.ToolsDirectory)\NativeCompilerStaticAnalysisRuleset\mandatory_to_fix.ruleset
4952
env:
5053
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
5154
continueOnError: true

build/AzurePipelinesTemplates/WindowsAppSDK-BuildVSIX-Stage.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ stages:
1717
# it is not under $(Build.SourcesDirectory)\WindowsAppSDK
1818
foundationRepoPath: ""
1919
buildConfiguration: "Release"
20+
ob_sdl_checkCompliantCompilerWarnings: true
21+
ob_sdl_prefast_runDuring: 'Build'
22+
ob_sdl_msbuildOverride: true
2023
condition: ne(variables.LatestOfficialBuildID, '')
2124
steps:
2225
- template: WindowsAppSDK-BuildVSIX-Steps.yml@self

build/AzurePipelinesTemplates/WindowsAppSDK-BuildVSIX-Steps.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ steps:
118118
# Generally speaking, we leave it to the external repos to scan the bits in their packages.
119119
excludedPaths: |
120120
$(Build.SourcesDirectory)\packages
121+
# Explicitly specify the EO-compliant rule set, as the default Sdl.Recommended.Warning.ruleset is not EO-compliant.
122+
rulesetName: Custom
123+
customRuleset: $(Agent.ToolsDirectory)\NativeCompilerStaticAnalysisRuleset\mandatory_to_fix.ruleset
121124
continueOnError: true
122125
env:
123126
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
@@ -150,6 +153,9 @@ steps:
150153
# Generally speaking, we leave it to the external repos to scan the bits in their packages.
151154
excludedPaths: |
152155
$(Build.SourcesDirectory)\packages
156+
# Explicitly specify the EO-compliant rule set, as the default Sdl.Recommended.Warning.ruleset is not EO-compliant.
157+
rulesetName: Custom
158+
customRuleset: $(Agent.ToolsDirectory)\NativeCompilerStaticAnalysisRuleset\mandatory_to_fix.ruleset
153159
continueOnError: true
154160
env:
155161
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

build/WindowsAppSDK-CommonVariables.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ variables:
2626
# Use the following corresponding version string instead of the above when calling nuget install directly.
2727
compilerOverrideNupkgVersion: ""
2828

29+
ob_sdl_checkCompliantCompilerWarnings: true
30+
ob_sdl_prefast_runDuring: 'Guardian'
31+
ob_sdl_msbuildOverride: true
32+
2933
# Docker image which is used to build the project https://aka.ms/obpipelines/containers
3034
WindowsContainerImage: 'onebranch.azurecr.io/windows/ltsc2019/vse2022:latest'
3135

0 commit comments

Comments
 (0)