-Updated build process to embed the build number as assembly version
This commit is contained in:
+43
-2
@@ -1,6 +1,7 @@
|
||||
properties {
|
||||
|
||||
$zipFileName = "Json40r2.zip"
|
||||
$majorVersion = "4.2"
|
||||
$version = GetVersion $majorVersion
|
||||
$signAssemblies = $false
|
||||
$signKeyPath = "D:\Development\Releases\newtonsoft.snk"
|
||||
$buildDocumentation = $false
|
||||
@@ -42,7 +43,10 @@ task Clean {
|
||||
|
||||
# Build each solution, optionally signed
|
||||
task Build -depends Clean {
|
||||
|
||||
Write-Host -ForegroundColor Green "Updating assembly version"
|
||||
Write-Host
|
||||
Update-AssemblyInfoFiles $sourceDir ($majorVersion + '.0.0') $version
|
||||
|
||||
foreach ($build in $builds)
|
||||
{
|
||||
$name = $build.Name
|
||||
@@ -168,4 +172,41 @@ function GetConstants($constants, $includeSigned)
|
||||
$signed = switch($includeSigned) { $true { ";SIGNED" } default { "" } }
|
||||
|
||||
return "/p:DefineConstants=`"TRACE;$constants$signed`""
|
||||
}
|
||||
|
||||
function GetVersion($majorVersion)
|
||||
{
|
||||
$now = [DateTime]::Now
|
||||
|
||||
$year = $now.Year - 2000
|
||||
$month = $now.Month
|
||||
$totalMonthsSince2000 = ($year * 12) + $month
|
||||
$day = $now.Day
|
||||
$minor = "{0}{1:00}" -f $totalMonthsSince2000, $day
|
||||
|
||||
$hour = $now.Hour
|
||||
$minute = $now.Minute
|
||||
$revision = "{0:00}{1:00}" -f $hour, $minute
|
||||
|
||||
return $majorVersion + "." + $minor + "." + $revision
|
||||
}
|
||||
|
||||
function Update-AssemblyInfoFiles ([string] $sourceDir, [string] $assemblyVersionNumber, [string] $fileVersionNumber)
|
||||
{
|
||||
$assemblyVersionPattern = 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'
|
||||
$fileVersionPattern = 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'
|
||||
$assemblyVersion = 'AssemblyVersion("' + $assemblyVersionNumber + '")';
|
||||
$fileVersion = 'AssemblyFileVersion("' + $fileVersionNumber + '")';
|
||||
|
||||
Get-ChildItem -Path $sourceDir -r -filter AssemblyInfo.cs | ForEach-Object {
|
||||
|
||||
$filename = $_.Directory.ToString() + '\' + $_.Name
|
||||
Write-Host $filename
|
||||
$filename + ' -> ' + $version
|
||||
|
||||
(Get-Content $filename) | ForEach-Object {
|
||||
% {$_ -replace $assemblyVersionPattern, $assemblyVersion } |
|
||||
% {$_ -replace $fileVersionPattern, $fileVersion }
|
||||
} | Set-Content $filename
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ using System.Runtime.InteropServices;
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("3.5.0.0")]
|
||||
[assembly: AssemblyVersion("4.2.0.0")]
|
||||
#if !PocketPC
|
||||
[assembly: AssemblyFileVersion("3.5.0.0")]
|
||||
#endif
|
||||
[assembly: AssemblyFileVersion("4.2.13610.1823")]
|
||||
#endif
|
||||
|
||||
@@ -108,9 +108,9 @@ using System.Security;
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("4.0.0.0")]
|
||||
[assembly: AssemblyVersion("4.2.0.0")]
|
||||
#if !PocketPC
|
||||
[assembly: AssemblyFileVersion("4.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("4.2.13610.1823")]
|
||||
#endif
|
||||
|
||||
[assembly: CLSCompliant(true)]
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
Reference in New Issue
Block a user