-Updated build process to embed the build number as assembly version
This commit is contained in:
+42
-1
@@ -1,6 +1,7 @@
|
|||||||
properties {
|
properties {
|
||||||
|
|
||||||
$zipFileName = "Json40r2.zip"
|
$zipFileName = "Json40r2.zip"
|
||||||
|
$majorVersion = "4.2"
|
||||||
|
$version = GetVersion $majorVersion
|
||||||
$signAssemblies = $false
|
$signAssemblies = $false
|
||||||
$signKeyPath = "D:\Development\Releases\newtonsoft.snk"
|
$signKeyPath = "D:\Development\Releases\newtonsoft.snk"
|
||||||
$buildDocumentation = $false
|
$buildDocumentation = $false
|
||||||
@@ -42,6 +43,9 @@ task Clean {
|
|||||||
|
|
||||||
# Build each solution, optionally signed
|
# Build each solution, optionally signed
|
||||||
task Build -depends Clean {
|
task Build -depends Clean {
|
||||||
|
Write-Host -ForegroundColor Green "Updating assembly version"
|
||||||
|
Write-Host
|
||||||
|
Update-AssemblyInfoFiles $sourceDir ($majorVersion + '.0.0') $version
|
||||||
|
|
||||||
foreach ($build in $builds)
|
foreach ($build in $builds)
|
||||||
{
|
{
|
||||||
@@ -169,3 +173,40 @@ function GetConstants($constants, $includeSigned)
|
|||||||
|
|
||||||
return "/p:DefineConstants=`"TRACE;$constants$signed`""
|
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
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
[assembly: AssemblyVersion("3.5.0.0")]
|
[assembly: AssemblyVersion("4.2.0.0")]
|
||||||
#if !PocketPC
|
#if !PocketPC
|
||||||
[assembly: AssemblyFileVersion("3.5.0.0")]
|
[assembly: AssemblyFileVersion("4.2.13610.1823")]
|
||||||
#endif
|
#endif
|
||||||
@@ -108,9 +108,9 @@ using System.Security;
|
|||||||
//
|
//
|
||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
[assembly: AssemblyVersion("4.0.0.0")]
|
[assembly: AssemblyVersion("4.2.0.0")]
|
||||||
#if !PocketPC
|
#if !PocketPC
|
||||||
[assembly: AssemblyFileVersion("4.0.0.0")]
|
[assembly: AssemblyFileVersion("4.2.13610.1823")]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
||||||
Reference in New Issue
Block a user