Uh oh!
There was an error while loading. Please reload this page.
forked from msgpack/msgpack-cli
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetFileVersions.ps1
More file actions
Latest commit
31 lines (26 loc) · 1.79 KB
/
Copy pathSetFileVersions.ps1
File metadata and controls
31 lines (26 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
$assemblyInfoVersionRegex= New-Object Text.RegularExpressions.Regex("^\s*\[\s*assembly\s*:\s*AssemblyInformationalVersion\(\s*`"(?<Version>[0-9\.]+)`"\s*\)\s*\]\s*$", ( [Text.RegularExpressions.RegexOptions]::Compiled -bor [Text.RegularExpressions.RegexOptions]::ExplicitCapture -bor [Text.RegularExpressions.RegexOptions]::CultureInvariant -bor [Text.RegularExpressions.RegexOptions]::MultiLine ) );
$versionMatch=$assemblyInfoVersionRegex.Match([IO.File]::ReadAllText( ".\src\CommonAssemblyInfo.Pack.cs" ));
if ( !$versionMatch.Success )
{
Write-Error"Cannot extract AssemblyInformationalVersion from CommonAssemblyInfo.Pack.cs."
return
}
$version=New-Object Version( $versionMatch.Groups[ "Version" ].Value );
# Major = Informational-Major, Minor = Informational-Minor,
# Build = Epoc days from 2010/1/1, Revision = Epoc minutes from 00:00:00
$today= [DateTime]::UtcNow;
$build= [int]( ( $today.Date- ( New-Object DateTime( 2010,1,1 ) ).ToUniversalTime() ).TotalDays );
$revision= [int]( ( $today-$today.Date ).TotalMinutes );
$newVersion=New-Object Version( $version.Major,$version.Minor,$build,$revision );
$newVersionString="[assembly: AssemblyFileVersion( `"{0}`" )]`r`n"-f$newVersion
$assemblyFileVersionRegex=New-Object Text.RegularExpressions.Regex( "\[\s*assembly\s*:\s*AssemblyFileVersion\([^)]+\)\s*\]\r\n", ( [Text.RegularExpressions.RegexOptions]::Compiled -bor [Text.RegularExpressions.RegexOptions]::ExplicitCapture -bor [Text.RegularExpressions.RegexOptions]::CultureInvariant -bor [Text.RegularExpressions.RegexOptions]::MultiLine ) );
foreach( $assemblyInfoin ( ls "src"-Recurse AssemblyInfo.cs ) )
{
[IO.File]::WriteAllText(
$assemblyInfo.FullName,
$assemblyFileVersionRegex.Replace(
[IO.File]::ReadAllText( $assemblyInfo.FullName ),
$newVersionString
)
);
}