Skip to content

Commit f1cabd2

Browse files
committed
Centralize the project's version too
1 parent 9699f9f commit f1cabd2

File tree

8 files changed

+42
-207
lines changed

8 files changed

+42
-207
lines changed

Directory.Build.props

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<Project>
22
<PropertyGroup>
3+
<ModuleVersion>1.22.0</ModuleVersion>
34
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
45
</PropertyGroup>
56
</Project>

Engine/Engine.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<VersionPrefix>1.22.0</VersionPrefix>
4+
<VersionPrefix>$(ModuleVersion)</VersionPrefix>
55
<TargetFrameworks>net6;net462</TargetFrameworks>
66
<AssemblyName>Microsoft.Windows.PowerShell.ScriptAnalyzer</AssemblyName>
7-
<AssemblyVersion>1.22.0</AssemblyVersion>
7+
<AssemblyVersion>$(ModuleVersion)</AssemblyVersion>
88
<PackageId>Engine</PackageId>
99
<RootNamespace>Microsoft.Windows.PowerShell.ScriptAnalyzer</RootNamespace> <!-- Namespace needs to match Assembly name for ressource binding -->
1010
<LangVersion>9.0</LangVersion>

Engine/PSScriptAnalyzer.psd1

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Author = 'Microsoft Corporation'
1111
RootModule = 'PSScriptAnalyzer.psm1'
1212

1313
# Version number of this module.
14-
ModuleVersion = '1.22.0'
14+
ModuleVersion = '{{ModuleVersion}}'
1515

1616
# ID used to uniquely identify this module
1717
GUID = 'd6245802-193d-4068-a631-8863a4342a18'

PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Microsoft.PowerShell.CrossCompatibility.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<VersionPrefix>1.22.0</VersionPrefix>
4+
<VersionPrefix>$(ModuleVersion)</VersionPrefix>
55
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
6-
<AssemblyVersion>1.22.0</AssemblyVersion>
6+
<AssemblyVersion>$(ModuleVersion)</AssemblyVersion>
77
</PropertyGroup>
88

99
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">

Rules/Rules.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<VersionPrefix>1.22.0</VersionPrefix>
4+
<VersionPrefix>$(ModuleVersion)</VersionPrefix>
55
<TargetFrameworks>net6;net462</TargetFrameworks>
66
<AssemblyName>Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules</AssemblyName>
7-
<AssemblyVersion>1.22.0</AssemblyVersion>
7+
<AssemblyVersion>$(ModuleVersion)</AssemblyVersion>
88
<PackageId>Rules</PackageId>
99
<RootNamespace>Microsoft.Windows.PowerShell.ScriptAnalyzer</RootNamespace> <!-- Namespace needs to match Assembly name for ressource binding -->
1010
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <!-- Needed in order for Pluralize.NET DLL to appear in bin folder - https://github.com/NuGet/Home/issues/4488 -->

Utils/ReleaseMaker.psm1

-198
This file was deleted.

build.psm1

+10-2
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,17 @@ function Start-ScriptAnalyzerBuild
159159
throw "Not in solution root"
160160
}
161161

162+
# "Copy" the module file with the version placeholder replaced
163+
[xml]$xml = Get-Content "$projectRoot/Directory.Build.props"
164+
$moduleVersion = $xml.Project.PropertyGroup.ModuleVersion
165+
$manifestContent = Get-Content -LiteralPath "$projectRoot\Engine\PSScriptAnalyzer.psd1" -Raw
166+
$newManifestContent = $manifestContent -replace '{{ModuleVersion}}', $moduleVersion
167+
Set-Content -LiteralPath "$script:destinationDir\PSScriptAnalyzer.psd1" -Encoding utf8 -Value $newManifestContent
168+
162169
$itemsToCopyCommon = @(
163-
"$projectRoot\Engine\PSScriptAnalyzer.psd1", "$projectRoot\Engine\PSScriptAnalyzer.psm1",
164-
"$projectRoot\Engine\ScriptAnalyzer.format.ps1xml", "$projectRoot\Engine\ScriptAnalyzer.types.ps1xml"
170+
"$projectRoot\Engine\PSScriptAnalyzer.psm1",
171+
"$projectRoot\Engine\ScriptAnalyzer.format.ps1xml",
172+
"$projectRoot\Engine\ScriptAnalyzer.types.ps1xml"
165173
)
166174

167175
switch ($PSVersion)

tools/updateVersion.ps1

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
param(
5+
[Parameter(Mandatory)]
6+
[semver]$Version,
7+
8+
[Parameter(Mandatory)]
9+
[string]$Changes
10+
)
11+
12+
git diff --staged --quiet --exit-code
13+
if ($LASTEXITCODE -ne 0) {
14+
throw "There are staged changes in the repository. Please commit or reset them before running this script."
15+
}
16+
17+
$Path = "Directory.Build.props"
18+
$f = Get-Content -Path $Path
19+
$f = $f -replace '^(?<prefix>\s+<ModuleVersion>)(.+)(?<suffix></ModuleVersion>)$', "`${prefix}${Version}`${suffix}"
20+
$f | Set-Content -Path $Path
21+
git add $Path
22+
23+
git commit --edit --message v${Version}: $Changes"
24+
"

0 commit comments

Comments
 (0)