Skip to content

Commit

Permalink
Cherry pick LKG/MsUCRT fixes (#4970)
Browse files Browse the repository at this point in the history
* 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

* Find custom.props in parent dir (#4946)

* Update LkgToolset.props

Fix build break - custom.props in parent directory

* Update LkgToolset.props
  • Loading branch information
Scottj1s authored Dec 14, 2024
1 parent fcfcd4b commit 3d7cec3
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 80 deletions.
106 changes: 34 additions & 72 deletions BuildAll.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,27 @@ write-host "VCToolsInstallDir: $VCToolsInstallDir"
$msBuildPath = "$VCToolsInstallDir\MSBuild\Current\Bin\msbuild.exe"
write-host "msBuildPath: $msBuildPath"


# Generate overrides
# Make sure override directory exists.
if(-not (test-path "$buildOverridePath"))
{
new-item -path "$buildOverridePath" -itemtype "directory"
}

function NugetRestore([string] $Label, [string] $Target)
{
if ($AzureBuildStep -ne "all")
{
$env:NUGET_RESTORE_MSBUILD_ARGS = "/binaryLogger:BuildOutput\binlogs\$Label.restore.$Platform.$Configuration.binlog /p:Platform=$Platform /p:Configuration=$Configuration"
}
& .\.nuget\nuget.exe restore $Target -configfile NuGet.config
if ($lastexitcode -ne 0)
{
write-host "ERROR: nuget.exe restore $Label FAILED."
exit 1
}
}

Try {
$WindowsAppSDKBuildPipeline = 0

Expand All @@ -109,34 +122,23 @@ Try {
# If $AzureBuildStep is not "all", that means we are in the pipeline
$WindowsAppSDKBuildPipeline = 1
}
# PreFastSetup is specifically for use when preparing for PREFast scans. It triggers the same actions below as BuildBinaries or BuildMRT, except
# PreFastSetup is specifically for use when preparing for PREFast scans. It triggers the same actions below as BuildFoundation or BuildMRT, except
# PreFastSetup stops short of calling msBuild.exe to build the target, which the Guardian:PREFast task does _not_ support, so the caller of this
# script needs to resort to calling the MSBuild/VSBuild task later to build the target, which the Guardian:PREFast task does support. Structuring
# the code this way allows minimally diveraging the flow while supporting building the target both via this script and the VSBuild/MSBuild task.
if (($AzureBuildStep -eq "all") -Or (($AzureBuildStep -eq "BuildBinaries") -Or ($AzureBuildStep -eq "BuildMRT") -Or ($AzureBuildStep -eq "PreFastSetup")))
if (($AzureBuildStep -eq "all") -Or (($AzureBuildStep -eq "BuildFoundation") -Or ($AzureBuildStep -eq "BuildMRT") -Or ($AzureBuildStep -eq "PreFastSetup")))
{
& .\.nuget\nuget.exe restore WindowsAppRuntime.sln -configfile NuGet.config

if ($lastexitcode -ne 0)
{
write-host "ERROR: restore WindowsAppRuntime.sln FAILED."
exit 1
}

& .\.nuget\nuget.exe restore "dev\Bootstrap\CS\Microsoft.WindowsAppRuntime.Bootstrap.Net\Microsoft.WindowsAppRuntime.Bootstrap.Net.csproj" -configfile NuGet.config

if ($lastexitcode -ne 0)
{
write-host "ERROR: restore Microsoft.WindowsAppRuntime.Bootstrap.Net.csproj FAILED."
exit 1
}
NugetRestore "WindowsAppRuntime" "WindowsAppRuntime.sln"
NugetRestore "Microsoft.WindowsAppRuntime.Bootstrap.Net" "dev\Bootstrap\CS\Microsoft.WindowsAppRuntime.Bootstrap.Net\Microsoft.WindowsAppRuntime.Bootstrap.Net.csproj"

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

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

if (($destinationPaths -ne $null)) {
if (($destinationPaths -ne $null))
{
foreach ($destPath in $destinationPaths) {
Write-Host 'SourcePath:' $srcPath.FullName
Write-Host 'DestinationPath:' $destPath.FullName
Expand All @@ -152,7 +154,7 @@ Try {
}
}
# PreFastSetup intentionally skips the call to MSBuild.exe below.
if (($AzureBuildStep -eq "all") -Or ($AzureBuildStep -eq "BuildBinaries"))
if (($AzureBuildStep -eq "all") -Or ($AzureBuildStep -eq "BuildFoundation"))
{
foreach($configurationToRun in $configuration.Split(","))
{
Expand All @@ -162,15 +164,15 @@ Try {
& $msBuildPath /restore `
WindowsAppRuntime.sln `
/p:Configuration=$configurationToRun,Platform=$platformToRun `
/binaryLogger:"BuildOutput/WindowsAppRuntime.$platformToRun.$configurationToRun.binlog" `
/binaryLogger:"BuildOutput/binlogs/WindowsAppRuntime.$platformToRun.$configurationToRun.binlog" `
$WindowsAppSDKVersionProperty `
/p:PGOBuildMode=$PGOBuildMode `
/p:WindowsAppSDKCleanIntermediateFiles=true `
/p:AppxSymbolPackageEnabled=false `
/p:WindowsAppSDKBuildPipeline=$WindowsAppSDKBuildPipeline
if ($lastexitcode -ne 0)
{
write-host "ERROR: msbuild.exe /restore WindowsAppRuntime.sln FAILED."
write-host "ERROR: msbuild.exe WindowsAppRuntime.sln FAILED."
exit 1
}
}
Expand All @@ -183,45 +185,11 @@ Try {
#------------------

#Restore packages from mrt.
& .\.nuget\nuget.exe restore "$MRTSourcesDirectory\mrt\MrtCore.sln" -ConfigFile NuGet.config

if ($lastexitcode -ne 0)
{
write-host "ERROR: restore MrtCore.sln FAILED."
exit 1
}

& .\.nuget\nuget.exe restore "$MRTSourcesDirectory\mrt\Microsoft.Windows.ApplicationModel.Resources\src\packages.config" -ConfigFile NuGet.config

if ($lastexitcode -ne 0)
{
write-host "ERROR: restore Microsoft.Windows.ApplicationModel.Resources\src\packages.config FAILED."
exit 1
}

& .\.nuget\nuget.exe restore "$MRTSourcesDirectory\mrt\mrm\mrmex\packages.config" -ConfigFile NuGet.config

if ($lastexitcode -ne 0)
{
write-host "ERROR: restore mrm\mrmex\packages.config FAILED."
exit 1
}

& .\.nuget\nuget.exe restore "$MRTSourcesDirectory\mrt\mrm\mrmmin\packages.config" -ConfigFile NuGet.config

if ($lastexitcode -ne 0)
{
write-host "ERROR: restore mrmmin\packages.config FAILED."
exit 1
}

& .\.nuget\nuget.exe restore "$MRTSourcesDirectory\mrt\mrm\unittests\packages.config" -ConfigFile NuGet.config

if ($lastexitcode -ne 0)
{
write-host "ERROR: restore unittests\packages.config FAILED."
exit 1
}
NugetRestore "MrtCore" "$MRTSourcesDirectory\mrt\MrtCore.sln"
NugetRestore "Microsoft.Windows.ApplicationModel.Resources" "$MRTSourcesDirectory\mrt\Microsoft.Windows.ApplicationModel.Resources\src\packages.config"
NugetRestore "mrmex" "$MRTSourcesDirectory\mrt\mrm\mrmex\packages.config"
NugetRestore "mrmmin" "$MRTSourcesDirectory\mrt\mrm\mrmmin\packages.config"
NugetRestore "unittests" "$MRTSourcesDirectory\mrt\mrm\unittests\packages.config"

# Init mrtcore
foreach($platformToRun in $platform.Split(","))
Expand All @@ -246,11 +214,11 @@ Try {
& $msBuildPath /restore "$MRTSourcesDirectory\mrt\MrtCore.sln" `
/p:Configuration=$configurationToRun,Platform=$platformToRun `
/p:PGOBuildMode=$PGOBuildMode `
/binaryLogger:"BuildOutput/mrtcore.$platformToRun.$configurationToRun.binlog"
/binaryLogger:"BuildOutput/binlogs/MrtCore.$platformToRun.$configurationToRun.binlog"

if ($lastexitcode -ne 0)
{
write-host "ERROR: Building '$MRTSourcesDirectory\mrt\MrtCore.sln' FAILED."
write-host "ERROR: msbuild.exe '$MRTSourcesDirectory\mrt\MrtCore.sln' FAILED."
exit 1
}
}
Expand All @@ -262,11 +230,11 @@ Try {
#------------------
# Build windowsAppRuntime.sln (anyCPU) and move output to staging.
#------------------
# build AnyCPU
# build and restore AnyCPU
& $msBuildPath /restore "dev\Bootstrap\CS\Microsoft.WindowsAppRuntime.Bootstrap.Net\Microsoft.WindowsAppRuntime.Bootstrap.Net.csproj" /p:Configuration=$configurationForMrtAndAnyCPU,Platform=AnyCPU
if ($lastexitcode -ne 0)
{
write-host "ERROR: msbuild restore Microsoft.WindowsAppRuntime.Bootstrap.Net.csproj FAILED."
write-host "ERROR: msbuild.exe Microsoft.WindowsAppRuntime.Bootstrap.Net.csproj FAILED."
exit 1
}
}
Expand Down Expand Up @@ -417,12 +385,6 @@ Try {
exit 1
}
}
# if (($AzureBuildStep -eq "all") -Or ($AzureBuildStep -eq "BuildMock"))
# {
# $transportPackagepath = (Join-Path $OutputDirectory "Microsoft.WindowsAppSDK.Foundation.TransportPackage.$PackageVersion.nupkg")
# . eng\common\Scripts\buildMockWinAppSdkPackage.ps1 -TransportPackageName "Foundation" -TransportPackagePath $transportPackagepath -RepoRoot $env:Build_SourcesDirectory -Output $OutputDirectory -Platform $Platform -Configuration $Configuration -TransportPackageVersion $PackageVersion -CleanOutput
# }

$files = Get-ChildItem $OutputDirectory -File -Filter "*.nupkg"
foreach ($file in $files)
{
Expand Down
4 changes: 3 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE-CODE in the project root for license information. -->
<!-- This is a special MSBuild file that is parsed before everything else when MSBuild detects it in our directory structure.
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
to ensure that all of our build output files end up in the same location. -->
<Project InitialTargets="DirectoryBuildPropsInfo" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="LkgToolset.props" />
<Import Project="eng\Version.Dependencies.props" />
<!-- Due to import ordering inconsistencies between different project types, we import this file from multiple places. -->
<Import Project="$(MSBuildThisFileDirectory)build\EnsureOutputLayout.props" Condition="$(EnsureOutputLayoutPropsIncluded) == ''" />
Expand All @@ -23,6 +24,7 @@
<AssemblyOriginatorKeyFile>$(RepoRoot)\WasdkStrongNameSign.snk</AssemblyOriginatorKeyFile>
<WindowsSdkPackageVersion>10.0.17763.$(CsWinRTDependencyWindowsSdkVersionSuffixPackageVersion)</WindowsSdkPackageVersion>
</PropertyGroup>

<PropertyGroup>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
Expand Down
23 changes: 23 additions & 0 deletions LkgToolset.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<Project ToolsVersion="14.0" TreatAsLocalProperty="Platform" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Enable synchronized LKG and internal MsUCRT consumption -->
<PropertyGroup>
<UseInternalMSUniCrtPackage>true</UseInternalMSUniCrtPackage>
<UndockedSettingsLoaded>true</UndockedSettingsLoaded>
</PropertyGroup>

<!-- The LKG toolset only supports Platform=win32. To work around, we TreatAsLocalProperty=Platform above to
enable overriding the global (command-line) Platform, explicitly import LKG's custom.props, and restore Platform. -->
<PropertyGroup Condition="'$(Platform)'=='x86'">
<WorkaroundLkgWin32>true</WorkaroundLkgWin32>
<Platform>Win32</Platform>
<CustomProps>$([MSBuild]::GetPathOfFileAbove('custom.props', '$(MSBuildThisFileDirectory)'))</CustomProps>
</PropertyGroup>
<Import Project="$(CustomProps)" Condition="Exists('$(CustomProps)') and '$(WorkaroundLkgWin32)'=='true'" />
<PropertyGroup Condition="'$(WorkaroundLkgWin32)'=='true'">
<Platform>x86</Platform>
</PropertyGroup>

</Project>
8 changes: 4 additions & 4 deletions build/AzurePipelinesTemplates/WindowsAppSDK-Build-Stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ stages:
targetType: filePath
filePath: tools\VerifyCopyrightHeaders.ps1

- job: BuildBinaries
- job: BuildFoundation
pool:
${{ if parameters.IsOneBranch }}:
type: windows
Expand Down Expand Up @@ -63,13 +63,13 @@ stages:
ob_sdl_apiscan_softwareFolder: '$(build.SourcesDirectory)\APIScanTarget'
ob_sdl_apiscan_symbolsFolder: '$(build.SourcesDirectory)\APIScanTarget;SRV*https://symweb.azurefd.net'
steps:
- template: WindowsAppSDK-BuildBinaries-Steps.yml@self
- template: WindowsAppSDK-BuildFoundation-Steps.yml@self
parameters:
SignOutput: ${{ parameters.SignOutput }}
IsOneBranch: ${{ parameters.IsOneBranch }}
runStaticAnalysis : ${{ parameters.runStaticAnalysis }}

- job: BuildBinaries_release_anycpu
- job: BuildFoundation_release_anycpu
# For now, this job just builds Microsoft.WindowsAppRuntime.Bootstrap.Net.dll in AnyCPU
# Can be expanded to add any other binary as needed
pool:
Expand All @@ -90,7 +90,7 @@ stages:
ob_sdl_apiscan_softwareFolder: '$(build.SourcesDirectory)\BuildOutput\Release\AnyCPU'
ob_sdl_apiscan_symbolsFolder: '$(build.SourcesDirectory)\BuildOutput\Release\AnyCPU;SRV*https://symweb.azurefd.net'
steps:
- template: WindowsAppSDK-BuildBinaries-AnyCPU-Steps.yml@self
- template: WindowsAppSDK-BuildFoundation-AnyCPU-Steps.yml@self
parameters:
SignOutput: ${{ parameters.SignOutput }}
IsOneBranch: ${{ parameters.IsOneBranch }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ steps:
IsOneBranch: ${{ parameters.IsOneBranch }}

- task: PowerShell@2
name: BuildBinaries
name: BuildFoundation
inputs:
filePath: 'BuildAll.ps1'
arguments: -AzureBuildStep "BuildAnyCPU"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ steps:
compilerPackageName: $(compilerOverridePackageName)
compilerPackageVersion: $(compilerOverridePackageVersion)
slnDirectory: $(Build.SourcesDirectory)
includeUCRT: true
ucrtFeedPat: $(System.AccessToken)
platform: $(buildPlatform)

- task: PowerShell@2
name: BuildBinaries
name: BuildFoundation
inputs:
filePath: 'BuildAll.ps1'
arguments: -Platform "$(buildPlatform)" -Configuration "$(buildConfiguration)" -AzureBuildStep "BuildBinaries"
arguments: -Platform "$(buildPlatform)" -Configuration "$(buildConfiguration)" -AzureBuildStep "BuildFoundation"

- ${{ if eq(parameters.runStaticAnalysis, 'True') }}:
- task: SDLNativeRules@3
Expand Down Expand Up @@ -130,18 +133,21 @@ steps:
# so the CopyFiles below are to move all the vPack files to the right locations
- task: CopyFiles@2
displayName: MoveToOutputDirectory
condition: always()
inputs:
SourceFolder: '$(build.SourcesDirectory)\BuildOutput'
TargetFolder: '$(ob_outputDirectory)'

- task: CopyFiles@2
displayName: MoveToOutputDirectory
condition: always()
inputs:
SourceFolder: '$(build.SourcesDirectory)\packages'
TargetFolder: '$(ob_outputDirectory)\packages'

- ${{ if not( parameters.IsOneBranch ) }}:
- task: PublishBuildArtifacts@1
condition: always()
inputs:
PathtoPublish: '$(ob_outputDirectory)'
artifactName: '$(ob_artifactBaseName)'
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ steps:
compilerPackageName: $(compilerOverridePackageName)
compilerPackageVersion: $(compilerOverridePackageVersion)
slnDirectory: $(Build.SourcesDirectory)\$(foundationRepoPath)installer\dev
includeUCRT: true
ucrtFeedPat: $(System.AccessToken)
platform: $(buildPlatform)

- task: VSBuild@1
displayName: 'Build Windows App Runtime Install'
Expand Down Expand Up @@ -262,6 +265,7 @@ steps:

- ${{ if ne(parameters.IsOneBranch, 'true') }}:
- task: PublishBuildArtifacts@1
condition: always()
inputs:
PathtoPublish: '$(ob_outputDirectory)'
artifactName: '$(ob_artifactBaseName)'
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ steps:
compilerPackageName: $(compilerOverridePackageName)
compilerPackageVersion: $(compilerOverridePackageVersion)
slnDirectory: $(Build.SourcesDirectory)\dev\MRTCore\mrt
includeUCRT: true
ucrtFeedPat: $(System.AccessToken)
platform: $(buildPlatform)

- task: PowerShell@2
name: BuildBinaries
Expand Down Expand Up @@ -88,6 +91,7 @@ steps:

- ${{ if not( parameters.IsOneBranch ) }}:
- task: PublishBuildArtifacts@1
condition: always()
inputs:
PathtoPublish: '$(ob_outputDirectory)'
artifactName: '$(ob_artifactBaseName)'
5 changes: 5 additions & 0 deletions installer/dev/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
#include "install.h"
#include "resource.h"

#ifndef GUID_NULL
struct __declspec(uuid("00000000-0000-0000-0000-000000000000")) GUID_NULL;
#define GUID_NULL __uuidof(struct GUID_NULL)
#endif

using namespace winrt;

using namespace WindowsAppRuntimeInstaller::Console;
Expand Down

0 comments on commit 3d7cec3

Please sign in to comment.