Skip to content

Commit 0d7a920

Browse files
authored
Include STL/CRT libs and headers with LKG to eliminate yvals_core.h static_assert build errors on mismatch (#4933)
* include STL/CRT libs/headers with LKG * add platform * opt into internal UCRT * opt into undocked settings loaded * publish binlogs on failure * use lower case platform for LKG toolset * treat Platform as local to allow override of x86 to win32 for LKG * define GUID_NULL, publish binlog on binary build failure * define GUID_NULL another way * collect binlogs for nuget restores * fix restore binlog name * nuget restore with platform for LKG compat, renamed BuildBinaries to BuildFoundation for clarity * setting platform to win32 has downstream effects - surgically wrapping LKG imports instead * import MsUCRT x86 targets explicitly * removed unnecessary LKG targets overrides
1 parent 8ebf35b commit 0d7a920

9 files changed

+85
-80
lines changed

BuildAll.ps1

Lines changed: 34 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,27 @@ write-host "VCToolsInstallDir: $VCToolsInstallDir"
7777
$msBuildPath = "$VCToolsInstallDir\MSBuild\Current\Bin\msbuild.exe"
7878
write-host "msBuildPath: $msBuildPath"
7979

80-
8180
# Generate overrides
8281
# Make sure override directory exists.
8382
if(-not (test-path "$buildOverridePath"))
8483
{
8584
new-item -path "$buildOverridePath" -itemtype "directory"
8685
}
8786

87+
function NugetRestore([string] $Label, [string] $Target)
88+
{
89+
if ($AzureBuildStep -ne "all")
90+
{
91+
$env:NUGET_RESTORE_MSBUILD_ARGS = "/binaryLogger:BuildOutput\binlogs\$Label.restore.$Platform.$Configuration.binlog /p:Platform=$Platform /p:Configuration=$Configuration"
92+
}
93+
& .\.nuget\nuget.exe restore $Target -configfile NuGet.config
94+
if ($lastexitcode -ne 0)
95+
{
96+
write-host "ERROR: nuget.exe restore $Label FAILED."
97+
exit 1
98+
}
99+
}
100+
88101
Try {
89102
$WindowsAppSDKBuildPipeline = 0
90103
$WindowsAppSDKVersionProperty = ""
@@ -110,34 +123,23 @@ Try {
110123
# If $AzureBuildStep is not "all", that means we are in the pipeline
111124
$WindowsAppSDKBuildPipeline = 1
112125
}
113-
# PreFastSetup is specifically for use when preparing for PREFast scans. It triggers the same actions below as BuildBinaries or BuildMRT, except
126+
# PreFastSetup is specifically for use when preparing for PREFast scans. It triggers the same actions below as BuildFoundation or BuildMRT, except
114127
# PreFastSetup stops short of calling msBuild.exe to build the target, which the Guardian:PREFast task does _not_ support, so the caller of this
115128
# script needs to resort to calling the MSBuild/VSBuild task later to build the target, which the Guardian:PREFast task does support. Structuring
116129
# the code this way allows minimally diveraging the flow while supporting building the target both via this script and the VSBuild/MSBuild task.
117-
if (($AzureBuildStep -eq "all") -Or (($AzureBuildStep -eq "BuildBinaries") -Or ($AzureBuildStep -eq "BuildMRT") -Or ($AzureBuildStep -eq "PreFastSetup")))
130+
if (($AzureBuildStep -eq "all") -Or (($AzureBuildStep -eq "BuildFoundation") -Or ($AzureBuildStep -eq "BuildMRT") -Or ($AzureBuildStep -eq "PreFastSetup")))
118131
{
119-
& .\.nuget\nuget.exe restore WindowsAppRuntime.sln -configfile NuGet.config
120-
121-
if ($lastexitcode -ne 0)
122-
{
123-
write-host "ERROR: restore WindowsAppRuntime.sln FAILED."
124-
exit 1
125-
}
126-
127-
& .\.nuget\nuget.exe restore "dev\Bootstrap\CS\Microsoft.WindowsAppRuntime.Bootstrap.Net\Microsoft.WindowsAppRuntime.Bootstrap.Net.csproj" -configfile NuGet.config
128-
129-
if ($lastexitcode -ne 0)
130-
{
131-
write-host "ERROR: restore Microsoft.WindowsAppRuntime.Bootstrap.Net.csproj FAILED."
132-
exit 1
133-
}
132+
NugetRestore "WindowsAppRuntime" "WindowsAppRuntime.sln"
133+
NugetRestore "Microsoft.WindowsAppRuntime.Bootstrap.Net" "dev\Bootstrap\CS\Microsoft.WindowsAppRuntime.Bootstrap.Net\Microsoft.WindowsAppRuntime.Bootstrap.Net.csproj"
134134

135135
$srcPath = Get-Childitem -Path 'dev\WindowsAppRuntime_Insights\packages' -File 'MicrosoftTelemetry.h' -Recurse
136136

137-
if (($srcPath -ne $null)){
137+
if (($srcPath -ne $null))
138+
{
138139
$destinationPaths = Get-Childitem -Path 'packages' -File 'Traceloggingconfig.h' -Recurse
139140

140-
if (($destinationPaths -ne $null)) {
141+
if (($destinationPaths -ne $null))
142+
{
141143
foreach ($destPath in $destinationPaths) {
142144
Write-Host 'SourcePath:' $srcPath.FullName
143145
Write-Host 'DestinationPath:' $destPath.FullName
@@ -153,7 +155,7 @@ Try {
153155
}
154156
}
155157
# PreFastSetup intentionally skips the call to MSBuild.exe below.
156-
if (($AzureBuildStep -eq "all") -Or ($AzureBuildStep -eq "BuildBinaries"))
158+
if (($AzureBuildStep -eq "all") -Or ($AzureBuildStep -eq "BuildFoundation"))
157159
{
158160
foreach($configurationToRun in $configuration.Split(","))
159161
{
@@ -163,15 +165,15 @@ Try {
163165
& $msBuildPath /restore `
164166
WindowsAppRuntime.sln `
165167
/p:Configuration=$configurationToRun,Platform=$platformToRun `
166-
/binaryLogger:"BuildOutput/WindowsAppRuntime.$platformToRun.$configurationToRun.binlog" `
168+
/binaryLogger:"BuildOutput/binlogs/WindowsAppRuntime.$platformToRun.$configurationToRun.binlog" `
167169
$WindowsAppSDKVersionProperty `
168170
/p:PGOBuildMode=$PGOBuildMode `
169171
/p:WindowsAppSDKCleanIntermediateFiles=true `
170172
/p:AppxSymbolPackageEnabled=false `
171173
/p:WindowsAppSDKBuildPipeline=$WindowsAppSDKBuildPipeline
172174
if ($lastexitcode -ne 0)
173175
{
174-
write-host "ERROR: msbuild.exe /restore WindowsAppRuntime.sln FAILED."
176+
write-host "ERROR: msbuild.exe WindowsAppRuntime.sln FAILED."
175177
exit 1
176178
}
177179
}
@@ -184,45 +186,11 @@ Try {
184186
#------------------
185187

186188
#Restore packages from mrt.
187-
& .\.nuget\nuget.exe restore "$MRTSourcesDirectory\mrt\MrtCore.sln" -ConfigFile NuGet.config
188-
189-
if ($lastexitcode -ne 0)
190-
{
191-
write-host "ERROR: restore MrtCore.sln FAILED."
192-
exit 1
193-
}
194-
195-
& .\.nuget\nuget.exe restore "$MRTSourcesDirectory\mrt\Microsoft.Windows.ApplicationModel.Resources\src\packages.config" -ConfigFile NuGet.config
196-
197-
if ($lastexitcode -ne 0)
198-
{
199-
write-host "ERROR: restore Microsoft.Windows.ApplicationModel.Resources\src\packages.config FAILED."
200-
exit 1
201-
}
202-
203-
& .\.nuget\nuget.exe restore "$MRTSourcesDirectory\mrt\mrm\mrmex\packages.config" -ConfigFile NuGet.config
204-
205-
if ($lastexitcode -ne 0)
206-
{
207-
write-host "ERROR: restore mrm\mrmex\packages.config FAILED."
208-
exit 1
209-
}
210-
211-
& .\.nuget\nuget.exe restore "$MRTSourcesDirectory\mrt\mrm\mrmmin\packages.config" -ConfigFile NuGet.config
212-
213-
if ($lastexitcode -ne 0)
214-
{
215-
write-host "ERROR: restore mrmmin\packages.config FAILED."
216-
exit 1
217-
}
218-
219-
& .\.nuget\nuget.exe restore "$MRTSourcesDirectory\mrt\mrm\unittests\packages.config" -ConfigFile NuGet.config
220-
221-
if ($lastexitcode -ne 0)
222-
{
223-
write-host "ERROR: restore unittests\packages.config FAILED."
224-
exit 1
225-
}
189+
NugetRestore "MrtCore" "$MRTSourcesDirectory\mrt\MrtCore.sln"
190+
NugetRestore "Microsoft.Windows.ApplicationModel.Resources" "$MRTSourcesDirectory\mrt\Microsoft.Windows.ApplicationModel.Resources\src\packages.config"
191+
NugetRestore "mrmex" "$MRTSourcesDirectory\mrt\mrm\mrmex\packages.config"
192+
NugetRestore "mrmmin" "$MRTSourcesDirectory\mrt\mrm\mrmmin\packages.config"
193+
NugetRestore "unittests" "$MRTSourcesDirectory\mrt\mrm\unittests\packages.config"
226194

227195
# Init mrtcore
228196
foreach($platformToRun in $platform.Split(","))
@@ -247,11 +215,11 @@ Try {
247215
& $msBuildPath /restore "$MRTSourcesDirectory\mrt\MrtCore.sln" `
248216
/p:Configuration=$configurationToRun,Platform=$platformToRun `
249217
/p:PGOBuildMode=$PGOBuildMode `
250-
/binaryLogger:"BuildOutput/mrtcore.$platformToRun.$configurationToRun.binlog"
218+
/binaryLogger:"BuildOutput/binlogs/MrtCore.$platformToRun.$configurationToRun.binlog"
251219

252220
if ($lastexitcode -ne 0)
253221
{
254-
write-host "ERROR: Building '$MRTSourcesDirectory\mrt\MrtCore.sln' FAILED."
222+
write-host "ERROR: msbuild.exe '$MRTSourcesDirectory\mrt\MrtCore.sln' FAILED."
255223
exit 1
256224
}
257225
}
@@ -263,11 +231,11 @@ Try {
263231
#------------------
264232
# Build windowsAppRuntime.sln (anyCPU) and move output to staging.
265233
#------------------
266-
# build AnyCPU
234+
# build and restore AnyCPU
267235
& $msBuildPath /restore "dev\Bootstrap\CS\Microsoft.WindowsAppRuntime.Bootstrap.Net\Microsoft.WindowsAppRuntime.Bootstrap.Net.csproj" /p:Configuration=$configurationForMrtAndAnyCPU,Platform=AnyCPU
268236
if ($lastexitcode -ne 0)
269237
{
270-
write-host "ERROR: msbuild restore Microsoft.WindowsAppRuntime.Bootstrap.Net.csproj FAILED."
238+
write-host "ERROR: msbuild.exe Microsoft.WindowsAppRuntime.Bootstrap.Net.csproj FAILED."
271239
exit 1
272240
}
273241
}
@@ -418,12 +386,6 @@ Try {
418386
exit 1
419387
}
420388
}
421-
# if (($AzureBuildStep -eq "all") -Or ($AzureBuildStep -eq "BuildMock"))
422-
# {
423-
# $transportPackagepath = (Join-Path $OutputDirectory "Microsoft.WindowsAppSDK.Foundation.TransportPackage.$PackageVersion.nupkg")
424-
# . eng\common\Scripts\buildMockWinAppSdkPackage.ps1 -TransportPackageName "Foundation" -TransportPackagePath $transportPackagepath -RepoRoot $env:Build_SourcesDirectory -Output $OutputDirectory -Platform $Platform -Configuration $Configuration -TransportPackageVersion $PackageVersion -CleanOutput
425-
# }
426-
427389
$files = Get-ChildItem $OutputDirectory -File -Filter "*.nupkg"
428390
foreach ($file in $files)
429391
{

Directory.Build.props

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE-CODE in the project root for license information. -->
33
<!-- This is a special MSBuild file that is parsed before everything else when MSBuild detects it in our directory structure.
44
Adding Sdk="Microsoft.NET.Sdk" to a project causes NuGet files to be generated very early on, so we need these defines to be here
55
to ensure that all of our build output files end up in the same location. -->
66
<Project InitialTargets="DirectoryBuildPropsInfo" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
7+
<Import Project="LkgToolset.props" />
78
<Import Project="eng\Version.Dependencies.props" />
89
<!-- Due to import ordering inconsistencies between different project types, we import this file from multiple places. -->
910
<Import Project="$(MSBuildThisFileDirectory)build\EnsureOutputLayout.props" Condition="$(EnsureOutputLayoutPropsIncluded) == ''" />
@@ -23,6 +24,7 @@
2324
<AssemblyOriginatorKeyFile>$(RepoRoot)\WasdkStrongNameSign.snk</AssemblyOriginatorKeyFile>
2425
<WindowsSdkPackageVersion>10.0.17763.$(CsWinRTDependencyWindowsSdkVersionSuffixPackageVersion)</WindowsSdkPackageVersion>
2526
</PropertyGroup>
27+
2628
<PropertyGroup>
2729
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
2830
</PropertyGroup>

LkgToolset.props

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
3+
<Project ToolsVersion="14.0" TreatAsLocalProperty="Platform" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
4+
5+
<!-- Enable synchronized LKG and internal MsUCRT consumption -->
6+
<PropertyGroup>
7+
<UseInternalMSUniCrtPackage>true</UseInternalMSUniCrtPackage>
8+
<UndockedSettingsLoaded>true</UndockedSettingsLoaded>
9+
</PropertyGroup>
10+
11+
<!-- The LKG toolset only supports Platform=win32. To work around, we TreatAsLocalProperty=Platform above to
12+
enable overriding the global (command-line) Platform, explicitly import LKG's custom.props, and restore Platform. -->
13+
<PropertyGroup Condition="'$(Platform)'=='x86'">
14+
<WorkaroundLkgWin32>true</WorkaroundLkgWin32>
15+
<Platform>Win32</Platform>
16+
</PropertyGroup>
17+
<Import Project="custom.props" Condition="Exists('custom.props') and '$(WorkaroundLkgWin32)'=='true'" />
18+
<PropertyGroup Condition="'$(WorkaroundLkgWin32)'=='true'">
19+
<Platform>x86</Platform>
20+
</PropertyGroup>
21+
22+
</Project>

build/AzurePipelinesTemplates/WindowsAppSDK-Build-Stage.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ stages:
2626
targetType: filePath
2727
filePath: tools\VerifyCopyrightHeaders.ps1
2828

29-
- job: BuildBinaries
29+
- job: BuildFoundation
3030
pool:
3131
${{ if parameters.IsOneBranch }}:
3232
type: windows
@@ -63,13 +63,13 @@ stages:
6363
ob_sdl_apiscan_softwareFolder: '$(build.SourcesDirectory)\APIScanTarget'
6464
ob_sdl_apiscan_symbolsFolder: '$(build.SourcesDirectory)\APIScanTarget;SRV*https://symweb.azurefd.net'
6565
steps:
66-
- template: WindowsAppSDK-BuildBinaries-Steps.yml@self
66+
- template: WindowsAppSDK-BuildFoundation-Steps.yml@self
6767
parameters:
6868
SignOutput: ${{ parameters.SignOutput }}
6969
IsOneBranch: ${{ parameters.IsOneBranch }}
7070
runStaticAnalysis : ${{ parameters.runStaticAnalysis }}
7171

72-
- job: BuildBinaries_release_anycpu
72+
- job: BuildFoundation_release_anycpu
7373
# For now, this job just builds Microsoft.WindowsAppRuntime.Bootstrap.Net.dll in AnyCPU
7474
# Can be expanded to add any other binary as needed
7575
pool:
@@ -90,7 +90,7 @@ stages:
9090
ob_sdl_apiscan_softwareFolder: '$(build.SourcesDirectory)\BuildOutput\Release\AnyCPU'
9191
ob_sdl_apiscan_symbolsFolder: '$(build.SourcesDirectory)\BuildOutput\Release\AnyCPU;SRV*https://symweb.azurefd.net'
9292
steps:
93-
- template: WindowsAppSDK-BuildBinaries-AnyCPU-Steps.yml@self
93+
- template: WindowsAppSDK-BuildFoundation-AnyCPU-Steps.yml@self
9494
parameters:
9595
SignOutput: ${{ parameters.SignOutput }}
9696
IsOneBranch: ${{ parameters.IsOneBranch }}

build/AzurePipelinesTemplates/WindowsAppSDK-BuildBinaries-AnyCPU-Steps.yml renamed to build/AzurePipelinesTemplates/WindowsAppSDK-BuildFoundation-AnyCPU-Steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ steps:
2727
IsOneBranch: ${{ parameters.IsOneBranch }}
2828

2929
- task: PowerShell@2
30-
name: BuildBinaries
30+
name: BuildFoundation
3131
inputs:
3232
filePath: 'BuildAll.ps1'
3333
arguments: -AzureBuildStep "BuildAnyCPU"

build/AzurePipelinesTemplates/WindowsAppSDK-BuildBinaries-Steps.yml renamed to build/AzurePipelinesTemplates/WindowsAppSDK-BuildFoundation-Steps.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,15 @@ steps:
6363
compilerPackageName: $(compilerOverridePackageName)
6464
compilerPackageVersion: $(compilerOverridePackageVersion)
6565
slnDirectory: $(Build.SourcesDirectory)
66+
includeUCRT: true
67+
ucrtFeedPat: $(System.AccessToken)
68+
platform: $(buildPlatform)
6669

6770
- task: PowerShell@2
68-
name: BuildBinaries
71+
name: BuildFoundation
6972
inputs:
7073
filePath: 'BuildAll.ps1'
71-
arguments: -Platform "$(buildPlatform)" -Configuration "$(buildConfiguration)" -AzureBuildStep "BuildBinaries"
74+
arguments: -Platform "$(buildPlatform)" -Configuration "$(buildConfiguration)" -AzureBuildStep "BuildFoundation"
7275

7376
- ${{ if eq(parameters.runStaticAnalysis, 'true') }}:
7477
- task: SDLNativeRules@3
@@ -130,18 +133,21 @@ steps:
130133
# so the CopyFiles below are to move all the vPack files to the right locations
131134
- task: CopyFiles@2
132135
displayName: MoveToOutputDirectory
136+
condition: always()
133137
inputs:
134138
SourceFolder: '$(build.SourcesDirectory)\BuildOutput'
135139
TargetFolder: '$(ob_outputDirectory)'
136140

137141
- task: CopyFiles@2
138142
displayName: MoveToOutputDirectory
143+
condition: always()
139144
inputs:
140145
SourceFolder: '$(build.SourcesDirectory)\packages'
141146
TargetFolder: '$(ob_outputDirectory)\packages'
142147

143148
- ${{ if not( parameters.IsOneBranch ) }}:
144149
- task: PublishBuildArtifacts@1
150+
condition: always()
145151
inputs:
146152
PathtoPublish: '$(ob_outputDirectory)'
147153
artifactName: '$(ob_artifactBaseName)'

build/AzurePipelinesTemplates/WindowsAppSDK-BuildInstaller-Steps.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ steps:
202202
compilerPackageName: $(compilerOverridePackageName)
203203
compilerPackageVersion: $(compilerOverridePackageVersion)
204204
slnDirectory: $(Build.SourcesDirectory)\$(foundationRepoPath)installer\dev
205+
includeUCRT: true
206+
ucrtFeedPat: $(System.AccessToken)
207+
platform: $(buildPlatform)
205208

206209
- task: VSBuild@1
207210
displayName: 'Build Windows App Runtime Install'
@@ -263,6 +266,7 @@ steps:
263266

264267
- ${{ if ne(parameters.IsOneBranch, 'true') }}:
265268
- task: PublishBuildArtifacts@1
269+
condition: always()
266270
inputs:
267271
PathtoPublish: '$(ob_outputDirectory)'
268272
artifactName: '$(ob_artifactBaseName)'

build/AzurePipelinesTemplates/WindowsAppSDK-BuildMRT-Steps.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ steps:
2121
compilerPackageName: $(compilerOverridePackageName)
2222
compilerPackageVersion: $(compilerOverridePackageVersion)
2323
slnDirectory: $(Build.SourcesDirectory)\dev\MRTCore\mrt
24+
includeUCRT: true
25+
ucrtFeedPat: $(System.AccessToken)
26+
platform: $(buildPlatform)
2427

2528
- task: PowerShell@2
2629
name: BuildBinaries
@@ -88,6 +91,7 @@ steps:
8891

8992
- ${{ if not( parameters.IsOneBranch ) }}:
9093
- task: PublishBuildArtifacts@1
94+
condition: always()
9195
inputs:
9296
PathtoPublish: '$(ob_outputDirectory)'
9397
artifactName: '$(ob_artifactBaseName)'

installer/dev/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
#include "install.h"
77
#include "resource.h"
88

9+
#ifndef GUID_NULL
10+
struct __declspec(uuid("00000000-0000-0000-0000-000000000000")) GUID_NULL;
11+
#define GUID_NULL __uuidof(struct GUID_NULL)
12+
#endif
13+
914
using namespace winrt;
1015

1116
using namespace WindowsAppRuntimeInstaller::Console;

0 commit comments

Comments
 (0)