Skip to content

Commit 93078ca

Browse files
committed
Completed the creation of the version override script.
1 parent d1437b7 commit 93078ca

File tree

2 files changed

+101
-47
lines changed

2 files changed

+101
-47
lines changed

eng/create-version-override.ps1

Lines changed: 99 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,108 @@
1-
# Using the downloaded workloads, this creates the VS drops to upload for VS insertion.
2-
# It builds the Microsoft.NET.Workloads.Vsman.vsmanproj per workload ZIP, which creates the appropriate VSMAN file.
1+
# Creates a Version.Overrides.props file to override version components for the workload set creation.
32

4-
# $workloadPath: The path to the directory containing the workload ZIPs, usually the output path used by DARC in the download-workloads.ps1 script.
5-
# - Example Value: "$(RepoRoot)artifacts\workloads"
6-
# $msBuildToolsPath: The path to the MSBuild tools directory, generally $(MSBuildToolsPath) in MSBuild.
7-
# - Example Value: 'C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin'
3+
# $createTestWorkloadSet:
4+
# - If $true, adds PreReleaseVersionIteration overrides for creating a test workload set.
5+
# - If $false, does not add any PreReleaseVersionIteration overrides.
6+
# $versionSdkMinor: Adds the VersionSdkMinor property to the Version.Overrides.props file with the provided value.
7+
# - Example Value: '2'
8+
# $versionFeature: Adds the VersionFeature property to the Version.Overrides.props file with the provided value.
9+
# - Example Value: '01'
10+
# $versionPatch: Adds the VersionPatch property to the Version.Overrides.props file with the provided value.
11+
# - Example Value: '4'
12+
# $preReleaseVersionLabel: Adds the PreReleaseVersionLabel property to the Version.Overrides.props file with the provided value.
13+
# - Example Value: 'preview'
14+
# $preReleaseVersionIteration: Adds the PreReleaseVersionIteration property to the Version.Overrides.props file with the provided value.
15+
# - Example Value: '1'
816

9-
param ([bool] $createTestWorkloadSet = $false, [string] $sdkVersionMinor = '|default|', [string] $versionFeature = '|default|', [string] $versionPatch = '|default|', [string] $preReleaseVersionLabel = '|default|', [string] $preReleaseVersionIteration = '|default|')
17+
param ([bool] $createTestWorkloadSet = $false, [string] $versionSdkMinor = '|default|', [string] $versionFeature = '|default|', [string] $versionPatch = '|default|', [string] $preReleaseVersionLabel = '|default|', [string] $preReleaseVersionIteration = '|default|')
1018

1119
$containsNonDefault = ($sdkVersionMinor, $versionFeature, $versionPatch, $preReleaseVersionLabel, $preReleaseVersionIteration | Where-Object { $_ -ne '|default|' }) -ne $null
1220

1321
if (-not $containsNonDefault -and -not $createTestWorkloadSet) {
14-
Write-Host "No version overrides to apply."
15-
exit 0
22+
Write-Host 'No version overrides to apply.'
23+
exit 0
1624
}
1725

1826
$xmlDoc = New-Object System.Xml.XmlDocument
19-
$projectElement = $xmlDoc.CreateElement("Project")
20-
$xmlDoc.AppendChild($rootElement)
21-
22-
$propertyGroup1Element = $xmlDoc.CreateElement("PropertyGroup")
23-
$projectElement.AppendChild($propertyGroup1Element)
24-
25-
$propertyGroup2Element = $xmlDoc.CreateElement("PropertyGroup")
26-
$projectElement.AppendChild($propertyGroup2Element)
27-
28-
29-
$settingElement.SetAttribute("Name", "LogLevel")
30-
$settingElement.InnerText = "Debug"
31-
32-
$xmlDoc.Save("D:\Workspace\TestMe.xml")
33-
34-
35-
36-
# <Project>
37-
# <PropertyGroup>
38-
# <VersionSDKMinor>3</VersionSDKMinor>
39-
# <VersionFeature>05</VersionFeature>
40-
# <VersionPatch>0</VersionPatch>
41-
# <PreReleaseVersionLabel>rc</PreReleaseVersionLabel>
42-
# <PreReleaseVersionIteration Condition="'$(StabilizePackageVersion)' != 'true'">1</PreReleaseVersionIteration>
43-
# </PropertyGroup>
44-
# <PropertyGroup>
45-
# <VersionPrefix>$(VersionMajor).$(VersionSDKMinor)$(VersionFeature).$(VersionPatch)</VersionPrefix>
46-
# <WorkloadsVersion>$(VersionMajor).$(VersionMinor).$(VersionSDKMinor)$(VersionFeature)</WorkloadsVersion>
47-
# <WorkloadsVersion Condition="'$(StabilizePackageVersion)' == 'true' and '$(VersionPatch)' != '0'">$(WorkloadsVersion).$(VersionPatch)</WorkloadsVersion>
48-
# <SdkFeatureBand>$(VersionMajor).$(VersionMinor).$(VersionSDKMinor)00</SdkFeatureBand>
49-
# <SdkFeatureBand Condition="'$(StabilizePackageVersion)' != 'true' and $(PreReleaseVersionLabel) != 'servicing'">$(SdkFeatureBand)-$(PreReleaseVersionLabel).$(PreReleaseVersionIteration)</SdkFeatureBand>
50-
# <!-- Conditional include -->
51-
# <PreReleaseVersionIteration Condition="'$(TestWorkloadVersion)' == 'true' and $(PreReleaseVersionLabel) != 'servicing'">$(PreReleaseVersionIteration).0</PreReleaseVersionIteration>
52-
# <PreReleaseVersionIteration Condition="'$(TestWorkloadVersion)' == 'true' and $(PreReleaseVersionLabel) == 'servicing'">0</PreReleaseVersionIteration>
53-
# </PropertyGroup>
54-
# </Project>
27+
$project = $xmlDoc.CreateElement('Project')
28+
$propertyGroup1 = $xmlDoc.CreateElement('PropertyGroup')
29+
30+
if ($versionSdkMinor -ne '|default|') {
31+
$versionSdkMinorElem = $xmlDoc.CreateElement('VersionSdkMinor')
32+
$versionSdkMinorElem.InnerText = $versionSdkMinor
33+
$null = $propertyGroup1.AppendChild($versionSdkMinorElem)
34+
Write-Host "Setting VersionSdkMinor to $versionSdkMinor."
35+
}
36+
37+
if ($versionFeature -ne '|default|') {
38+
$versionFeatureElem = $xmlDoc.CreateElement('VersionFeature')
39+
$versionFeatureElem.InnerText = $versionFeature
40+
$null = $propertyGroup1.AppendChild($versionFeatureElem)
41+
Write-Host "Setting VersionFeature to $versionFeature."
42+
}
43+
44+
if ($versionPatch -ne '|default|') {
45+
$versionPatchElem = $xmlDoc.CreateElement('VersionPatch')
46+
$versionPatchElem.InnerText = $versionPatch
47+
$null = $propertyGroup1.AppendChild($versionPatchElem)
48+
Write-Host "Setting VersionPatch to $versionPatch."
49+
}
50+
51+
if ($preReleaseVersionLabel -ne '|default|') {
52+
$preReleaseVersionLabelElem = $xmlDoc.CreateElement('PreReleaseVersionLabel')
53+
$preReleaseVersionLabelElem.InnerText = $preReleaseVersionLabel
54+
$null = $propertyGroup1.AppendChild($preReleaseVersionLabelElem)
55+
Write-Host "Setting PreReleaseVersionLabel to $preReleaseVersionLabel."
56+
}
57+
58+
if ($preReleaseVersionIteration -ne '|default|') {
59+
$preReleaseVersionIterationElem = $xmlDoc.CreateElement('PreReleaseVersionIteration')
60+
$null = $preReleaseVersionIterationElem.SetAttribute('Condition', "'`$(StabilizePackageVersion)' != 'true'")
61+
$preReleaseVersionIterationElem.InnerText = $preReleaseVersionIteration
62+
$null = $propertyGroup1.AppendChild($preReleaseVersionIterationElem)
63+
Write-Host "Setting PreReleaseVersionIteration to $preReleaseVersionIteration."
64+
}
65+
66+
$null = $project.AppendChild($propertyGroup1)
67+
$propertyGroup2 = $xmlDoc.CreateElement('PropertyGroup')
68+
69+
$versionPrefix = $xmlDoc.CreateElement('VersionPrefix')
70+
$versionPrefix.InnerText = '$(VersionMajor).$(VersionSdkMinor)$(VersionFeature).$(VersionPatch)'
71+
$null = $propertyGroup2.AppendChild($versionPrefix)
72+
73+
$workloadsVersion1 = $xmlDoc.CreateElement('WorkloadsVersion')
74+
$workloadsVersion1.InnerText = '$(VersionMajor).$(VersionMinor).$(VersionSdkMinor)$(VersionFeature)'
75+
$null = $propertyGroup2.AppendChild($workloadsVersion1)
76+
77+
$workloadsVersion2 = $xmlDoc.CreateElement('WorkloadsVersion')
78+
$null = $workloadsVersion2.SetAttribute('Condition', "'`$(StabilizePackageVersion)' == 'true' and '`$(VersionPatch)' != '0'")
79+
$workloadsVersion2.InnerText = '$(WorkloadsVersion).$(VersionPatch)'
80+
$null = $propertyGroup2.AppendChild($workloadsVersion2)
81+
82+
$sdkFeatureBand1 = $xmlDoc.CreateElement('SdkFeatureBand')
83+
$sdkFeatureBand1.InnerText = '$(VersionMajor).$(VersionMinor).$(VersionSdkMinor)00'
84+
$null = $propertyGroup2.AppendChild($sdkFeatureBand1)
85+
86+
$sdkFeatureBand2 = $xmlDoc.CreateElement('SdkFeatureBand')
87+
$null = $sdkFeatureBand2.SetAttribute('Condition', "'`$(StabilizePackageVersion)' != 'true' and '`$(PreReleaseVersionLabel)' != 'servicing'")
88+
$sdkFeatureBand2.InnerText = '$(SdkFeatureBand)-$(PreReleaseVersionLabel).$(PreReleaseVersionIteration)'
89+
$null = $propertyGroup2.AppendChild($sdkFeatureBand2)
90+
91+
if ($createTestWorkloadSet) {
92+
$preReleaseVersionIteration1 = $xmlDoc.CreateElement('PreReleaseVersionIteration')
93+
$null = $preReleaseVersionIteration1.SetAttribute('Condition', "'`$(PreReleaseVersionLabel)' != 'servicing'")
94+
$preReleaseVersionIteration1.InnerText = '$(PreReleaseVersionIteration).0'
95+
$null = $propertyGroup2.AppendChild($preReleaseVersionIteration1)
96+
97+
$preReleaseVersionIteration2 = $xmlDoc.CreateElement('PreReleaseVersionIteration')
98+
$null = $preReleaseVersionIteration2.SetAttribute('Condition', "'`$(PreReleaseVersionLabel)' == 'servicing'")
99+
$preReleaseVersionIteration2.InnerText = '0'
100+
$null = $propertyGroup2.AppendChild($preReleaseVersionIteration2)
101+
Write-Host 'Setting PreReleaseVersionIteration for test workload set.'
102+
}
103+
104+
$null = $project.AppendChild($propertyGroup2)
105+
$null = $xmlDoc.AppendChild($project)
106+
107+
$versionOverridesPath = Join-Path -Path $PSScriptRoot -ChildPath 'Version.Overrides.props'
108+
$null = $xmlDoc.Save($versionOverridesPath)

eng/pipelines/official.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ parameters:
9393
# displayName: Set version minor
9494
# type: string
9595
# default: '|default|'
96-
- name: setSdkVersionMinor
97-
displayName: Set SDK version minor (one digit)
96+
- name: setVersionSdkMinor
97+
displayName: Set version SDK minor (one digit)
9898
type: string
9999
default: '|default|'
100100
- name: setVersionFeature

0 commit comments

Comments
 (0)