Skip to content

[Cherry pick] Fix versioning of foundation package (#5393) #5403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
82 changes: 81 additions & 1 deletion BuildAll.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ This script is to build the Foundation transport package that will be used to ge
This script is called from BuildAll.ps1 from the aggregator repo and should not be called directly.

PackageVersion: NuGet Package Version that will be used in the packing of Foundation Transport Package
ComponentPackageVersion: NuGet Package Version that will be used in the packing of Foundation Component Package
Platform: Comma delimited string of platforms to run.
Configuration: Comma delimited string of configurations to run.
AzureBuildStep: Only used by the pipeline to perform tasks such as signing in between the steps
Expand All @@ -18,6 +19,7 @@ Main branch points to the external feed.

Param(
[string]$PackageVersion = "1.1.1.1",
[string]$ComponentPackageVersion = "1.1.1.1",
[string]$Platform = "x64",
[string]$Configuration = "Release",
[string]$AzureBuildStep = "all",
Expand Down Expand Up @@ -454,9 +456,70 @@ Try {
}

Copy-Item -Path "$nuSpecsPath\package.appxfragment" -Destination "$ComponentBasePath\runtimes-framework\package.appxfragment"

# Populate Intellisense files
$IntellisensePath = "$PSScriptRoot\build\NuSpecs\Intellisense"

$LibPaths = @(
(Join-Path $ComponentBasePath "metadata"),
(Join-Path $ComponentBasePath "lib\net6.0-windows10.0.17763.0")
)

foreach ($File in Get-ChildItem -Path $LibPaths)
{
if ($File.Extension -ne ".dll" -and $File.Extension -ne ".winmd")
{
continue
}

$IntellisenseFile = (Join-Path $IntellisensePath "$($File.BaseName).xml")
$DestinationDir = ($File.DirectoryName)

if (-not (Test-Path $IntellisenseFile))
{
Write-Host "Intellisense file not found: $IntellisenseFile"
continue
}

Copy-Item -Path $IntellisenseFile -Destination $DestinationDir
}
}
if (($AzureBuildStep -eq "all") -Or ($AzureBuildStep -eq "PackNuget"))
{
# Remove ProjectCapability for the one in the transport package
$propsFilePath = (Join-Path $BasePath 'build\Microsoft.WindowsAppSDK.Foundation.props')
[xml]$wasFoundationProps = Get-Content -Encoding UTF8 -Path $propsFilePath
foreach ($projectCapability in $wasFoundationProps.Project.ItemGroup.ProjectCapability)
{
if ($projectCapability.Id -eq "VersionSpecific")
{
$wasFoundationProps.Project.RemoveChild($projectCapability.ParentNode)
break
}
}
$wasFoundationProps.Save($propsFilePath)

# Fix up ProjectCapability versions
$FoundationBuildPaths = @(
'build',
'buildTransitive'
)

foreach ($BuildPath in $FoundationBuildPaths)
{
# Keep ProjectCapability and update the version for the one in the component package
$propsFilePath = (Join-Path $ComponentBasePath "$BuildPath\Microsoft.WindowsAppSDK.Foundation.props")
[xml]$wasFoundationProps = Get-Content -Encoding UTF8 -Path $propsFilePath
foreach ($projectCapability in $wasFoundationProps.Project.ItemGroup.ProjectCapability)
{
if ($projectCapability.Id -eq "VersionSpecific")
{
$projectCapability.Include = "Microsoft.WindowsAppSDK.Foundation.$ComponentPackageVersion"
}
}
$wasFoundationProps.Save($propsFilePath)
}

$nuspecPath = "BuildOutput\Microsoft.WindowsAppSDK.Foundation.TransportPackage.nuspec"
Copy-Item -Path ".\build\NuSpecs\Microsoft.WindowsAppSDK.Foundation.TransportPackage.nuspec" -Destination $nuspecPath

Expand All @@ -479,7 +542,24 @@ Try {

# Add the version to the nuspec.
[xml]$publicNuspec = Get-Content -Path $nuspecPath
$publicNuspec.package.metadata.version = $PackageVersion
$publicNuspec.package.metadata.version = $ComponentPackageVersion

# Update dependency versions in the nuspec
$versionDetailsPath = ".\eng\Version.Details.xml"
[xml]$buildConfig = Get-Content -Path $versionDetailsPath

foreach ($dependency in $publicNuspec.package.metadata.dependencies.dependency)
{
$buildDependency = $buildConfig.Dependencies.ProductDependencies.Dependency | Where-Object { $_.Name -eq $dependency.Id }
if (-not($buildDependency))
{
write-host "ERROR: NuGet package dependency $($dependency.Id) not found."
exit 1
}

$dependency.version = $buildDependency.Version
}

Set-Content -Value $publicNuspec.OuterXml $nuspecPath

# Make the foundation transport package.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ steps:
inputs:
targetType: "inline"
script: |
$srcWinAppSDKNupkgPath = Get-Childitem -Path '$(System.ArtifactsDirectory)\NugetPackages' -File '*Microsoft.WindowsAppSDK*' | Where-Object { $_.Name -match "Microsoft\.WindowsAppSDK\.[0-9].*" }
$srcWinAppSDKNupkgPath = Get-Childitem -Path '$(System.ArtifactsDirectory)\NugetPackages' -File '*Microsoft.WindowsAppSDK.Packages*'
if ($srcWinAppSDKNupkgPath -eq $null)
{
$srcWinAppSDKNupkgPath = Get-Childitem -Path '$(System.ArtifactsDirectory)\NugetPackages' -File '*Microsoft.WindowsAppSDK*'
}
Copy-Item -Force $srcWinAppSDKNupkgPath.FullName '$(Build.SourcesDirectory)\$(foundationRepoPath)packages\'
$destWinAppSDKNupkgPath = Get-Childitem -Path '$(Build.SourcesDirectory)\$(foundationRepoPath)packages\' -File '*Microsoft.WindowsAppSDK*'
$winAppSDKZip = $destWinAppSDKNupkgPath.FullName -replace '.nupkg','.zip'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,72 @@ stages:
$publicNuspec.package.metadata.version = $packageVersion
Set-Content -Value $publicNuspec.OuterXml $(Build.SourcesDirectory)\build\NuSpecs\Microsoft.WindowsAppSDK.Foundation.TransportPackage.nuspec

- task: PowerShell@2
name: DetermineComponentNugetPackageVersion
displayName: 'Determine Component Nuget Package Version'
inputs:
targetType: 'inline'
script: |
$paddedRevision = '$(versionCounter)'
if([int]$(versionCounter) -lt 10)
{
$paddedRevision = '00' + '$(versionCounter)'
}
elseif ([int]$(versionCounter) -lt 100)
{
$paddedRevision = '0' + '$(versionCounter)'
}
Write-Host "paddedRevision " $paddedRevision

if ([int]$(versionCounter) -gt 999)
{
Write-Host "Revision Number limit reach. Please try again the next day"
Write-Host "##vso[task.complete result=Failed;]DONE"
}

$buildType = '$(channel)'
$majorMinorPatchRev = '$(major).$(minor).$(versionMinDate)'
$majorMinorPatchRev = $majorMinorPatchRev + $paddedRevision
$version = $majorMinorPatchRev + '-' + $buildType

# If using release versioning, drop the version suffix, which includes a tag & build stamp.
# This should only be done when prepping final release packages.

if ('${{ parameters.IsOfficial }}' -eq 'true')
{
$versionTag = '$(versionTag)'
Write-Host "VersionTag: " $versionTag
if ($buildType -ne "stable" -and -not $versionTag.StartsWith($buildType))
{
Write-Host "Variable VersionTag must start with " $buildType
Write-Host "Please update this variable and restart the build"
Write-Host "##vso[task.complete result=Failed;]DONE"
}
if ($buildType -eq "stable" -and -not [String]::IsNullOrEmpty($versionTag))
{
Write-Host "Stable builds must have an empty VersionTag"
Write-Host "Please update this variable and restart the build"
Write-Host "##vso[task.complete result=Failed;]DONE"
}

$formattedTag = ''
if(-not [String]::IsNullOrEmpty($versionTag))
{
$formattedTag = '-' + $versionTag
}
Write-Host "Using Release Versioning"
$version = $majorMinorPatchRev + $formattedTag
}

Write-Host 'Component Package Version: ' $version
Write-Host "##vso[task.setvariable variable=componentPackageVersion;isOutput=true]$version"
Write-Host "##vso[task.setvariable variable=componentPackageVersion;]$version"

- task: PowerShell@2
name: PackNuget
inputs:
filePath: 'BuildAll.ps1'
arguments: -Platform "x64" -Configuration "release" -AzureBuildStep "PackNuget" -OutputDirectory "$(build.artifactStagingDirectory)\FullNuget" -PackageVersion "$(packageVersion)"
arguments: -Platform "x64" -Configuration "release" -AzureBuildStep "PackNuget" -OutputDirectory "$(build.artifactStagingDirectory)\FullNuget" -PackageVersion "$(packageVersion)" -ComponentPackageVersion "$(componentPackageVersion)"

# Disable building MockWindowsAppSDK until we can consider the public vs private scenario
# - ${{ if eq(parameters.BuildMockWindowsAppSDK, 'true') }}:
Expand Down
Loading
Loading