Skip to content

Commit 86e46aa

Browse files
committed
added setVersion script; tested successfully
1 parent 7b6904d commit 86e46aa

7 files changed

Lines changed: 52 additions & 6 deletions

File tree

Synapse.NodeService.HttpClient/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Reflection;
1+
using System.Reflection;
22
using System.Runtime.CompilerServices;
33
using System.Runtime.InteropServices;
44

@@ -33,4 +33,4 @@
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion( "0.1.0.0" )]
36-
[assembly: AssemblyFileVersion( "0.1.0.1" )]
36+
[assembly: AssemblyFileVersion( "0.1.17034.2" )]

Synapse.NodeService.HttpClient/Synapse.NodeService.HttpClient.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
<Compile Include="Properties\AssemblyInfo.cs" />
5353
</ItemGroup>
5454
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
55+
<PropertyGroup>
56+
<PreBuildEvent>powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(SolutionDir)scripts\setVersion.ps1 -path $(ProjectDir)Properties\AssemblyInfo.cs -major 0 -minor 1</PreBuildEvent>
57+
</PropertyGroup>
5558
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
5659
Other similar extension points exist, see Microsoft.Common.targets.
5760
<Target Name="BeforeBuild">

Synapse.NodeService.cli/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Reflection;
1+
using System.Reflection;
22
using System.Runtime.CompilerServices;
33
using System.Runtime.InteropServices;
44

@@ -33,4 +33,4 @@
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion( "0.1.0.0" )]
36-
[assembly: AssemblyFileVersion( "0.1.0.1" )]
36+
[assembly: AssemblyFileVersion( "0.1.17034.2" )]

Synapse.NodeService.cli/Synapse.NodeService.cli.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
<Content Include="syn_logo_icon.ico" />
7676
</ItemGroup>
7777
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
78+
<PropertyGroup>
79+
<PreBuildEvent>powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(SolutionDir)scripts\setVersion.ps1 -path $(ProjectDir)Properties\AssemblyInfo.cs -major 0 -minor 1</PreBuildEvent>
80+
</PropertyGroup>
7881
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
7982
Other similar extension points exist, see Microsoft.Common.targets.
8083
<Target Name="BeforeBuild">

Synapse.NodeService/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Reflection;
1+
using System.Reflection;
22
using System.Runtime.CompilerServices;
33
using System.Runtime.InteropServices;
44

@@ -35,4 +35,4 @@
3535
// by using the '*' as shown below:
3636
// [assembly: AssemblyVersion("1.0.*")]
3737
[assembly: AssemblyVersion( "0.1.0.0" )]
38-
[assembly: AssemblyFileVersion( "0.1.0.1" )]
38+
[assembly: AssemblyFileVersion( "0.1.17034.2" )]

Synapse.NodeService/Synapse.NodeService.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@
9191
<Content Include="syn_logo_icon.ico" />
9292
</ItemGroup>
9393
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
94+
<PropertyGroup>
95+
<PreBuildEvent>powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(SolutionDir)scripts\setVersion.ps1 -path $(ProjectDir)Properties\AssemblyInfo.cs -major 0 -minor 1</PreBuildEvent>
96+
</PropertyGroup>
9497
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
9598
Other similar extension points exist, see Microsoft.Common.targets.
9699
<Target Name="BeforeBuild">

scripts/setVersion.ps1

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
param (
2+
[string]$path = "c:\Users\$($env:username)\desktop\AssemblyInfo.cs",
3+
[int]$major = 1,
4+
[int]$minor = 0
5+
)
6+
7+
#$file = Get-Content $path | Out-String
8+
$file = [System.IO.File]::ReadAllText( $path )
9+
10+
#adjust AssemblyVersion
11+
$pattern = 'AssemblyVersion\( \"(?<v>\d.\d.\d.\d)\" \)'
12+
$vers = ([regex]::Match( $file, $pattern )).Groups
13+
[Version]$version = [Version]$vers.Groups[1].Value
14+
$v = 'AssemblyVersion( "{0}.{1}.{2}.{3}" )' -f $major, $minor, $version.Build, $version.Revision
15+
$file = ([regex]::Replace( $file, $pattern, $v ))
16+
17+
18+
#adjust AssemblyFileVersion
19+
$pattern = 'AssemblyFileVersion\( \"(?<v>.*)\" \)'
20+
$vers = ([regex]::Match( $file, $pattern )).Groups
21+
[Version]$version = [Version]$vers.Groups[1].Value
22+
23+
$now = [DateTime]::Now
24+
$build = '{0}{1}' -f $now.ToString( 'yy' ), $now.DayOfYear.ToString( 'D3' )
25+
[int]$revision = [int]$version.Revision
26+
if( $version.Build.ToString() -eq $build )
27+
{
28+
$revision = [int]$version.Revision + 1
29+
}
30+
31+
$v = 'AssemblyFileVersion( "{0}.{1}.{2}.{3}" )' -f $major, $minor, $build, $revision
32+
$file = ([regex]::Replace( $file, $pattern, $v ))
33+
34+
Write-Host $file
35+
[System.IO.File]::SetAttributes( $path, [System.IO.FileAttributes]::Normal );
36+
[System.IO.File]::WriteAllText( $path, $file )
37+
#Set-Content -Path $path -Value $file.Trim()

0 commit comments

Comments
 (0)