-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The Get-AssemblyInfo function retrieves version, branch, build/revision number, and SHA information from an assembly file. This commit adds the function to the project, which is a new feature for the user. This commit will trigger a release bumping a MINOR version.
- Loading branch information
1 parent
5a295f5
commit fbc0a14
Showing
1 changed file
with
14 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,36 @@ | ||
function Get-AssemblyInfo { | ||
[CmdletBinding()] | ||
Param ( | ||
[Parameter(Mandatory=$true)] | ||
[Parameter(Mandatory = $true)] | ||
[string]$assemblyInfoPath | ||
) | ||
|
||
if (Test-Path $assemblyInfoPath) { | ||
$content = Get-Content $assemblyInfoPath -Raw | ||
|
||
# Adjusted regex pattern to capture version, optional branch, and build/revision number | ||
$assemblyVersionPattern = '\[assembly: AssemblyVersion\("(\d+\.\d+\.\d+)(?:-([^\.\"]+))?(?:\.(\d+))?"\)\]' | ||
# Adjusted regex pattern to capture version, branch, build/revision number, and SHA | ||
$assemblyInformationalVersionPattern = '\[assembly: AssemblyInformationalVersion\("(\d+\.\d+\.\d+)-([^.]+)\.(\d+)\.Sha\.([a-fA-F0-9]+)"\)\]' | ||
|
||
$assemblyVersionMatch = [regex]::Match($content, $assemblyVersionPattern) | ||
$assemblyInformationalVersionMatch = [regex]::Match($content, $assemblyInformationalVersionPattern) | ||
|
||
if ($assemblyVersionMatch.Success) { | ||
$version = $assemblyVersionMatch.Groups[1].Value | ||
$branch = $assemblyVersionMatch.Groups[2].Success ? $assemblyVersionMatch.Groups[2].Value : "N/A" | ||
$buildOrRevision = $assemblyVersionMatch.Groups[3].Success ? $assemblyVersionMatch.Groups[3].Value : "N/A" | ||
if ($assemblyInformationalVersionMatch.Success) { | ||
$version = $assemblyInformationalVersionMatch.Groups[1].Value | ||
$branch = $assemblyInformationalVersionMatch.Groups[2].Value | ||
$buildOrRevision = $assemblyInformationalVersionMatch.Groups[3].Value | ||
$sha = $assemblyInformationalVersionMatch.Groups[4].Value | ||
|
||
[PSCustomObject]@{ | ||
Version = $version | ||
Branch = $branch | ||
Version = $version | ||
Branch = $branch | ||
BuildOrRevision = $buildOrRevision | ||
Sha = $sha | ||
} | ||
} | ||
else { | ||
Write-Warning "Version information not found in the file." | ||
} | ||
} else { | ||
} | ||
else { | ||
Write-Error "File $assemblyInfoPath not found." | ||
} | ||
} |