This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
/
bootstrap.ps1
95 lines (79 loc) · 3.27 KB
/
bootstrap.ps1
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
[CmdletBinding()]
param(
[string]
$AssemblyVersion = $Env:ASSEMBLY_VERSION,
[string]
$SemverVersion = $Env:SEMVER_VERSION,
[string]
$NuGetVersion = $Env:NUGET_VERSION,
[string]
$VsVsixVersion = $Env:VSVSIX_VERSION,
[string]
$VsCodeVsixVersion = $Env:VSCODEVSIX_VERSION
);
if ("$AssemblyVersion".Trim().Length -eq 0) {
$Date = Get-Date;
$Year = $Date.Year.ToString().Substring(2);
$Month = $Date.Month.ToString().PadLeft(2, "0");
$Hour = (Get-Date).Hour.ToString().PadLeft(2, "0");
$Minute = (Get-Date).Minute.ToString().PadLeft(2, "0");
$AssemblyVersion = "0.9999.$Year$Month.$Hour$Minute";
}
Write-Host "Assembly version: $AssemblyVersion";
$pieces = "$AssemblyVersion".split(".");
$MajorVersion = "$($pieces[0])";
$MinorVersion = "$($pieces[1])";
$patch = "$($pieces[2])"
$rev = "$($pieces[3])".PadLeft(4, "0");
if ("$SemverVersion".Trim().Length -eq 0) {
$SemverVersion = "$MajorVersion.$MinorVersion.$patch$rev";
}
if ("$NuGetVersion".Trim().Length -eq 0) {
$NuGetVersion = "$AssemblyVersion-alpha";
}
if ("$VsVsixVersion".Trim().Length -eq 0) {
$VsVsixVersion = "$MajorVersion.$MinorVersion.$patch.$rev";
}
if ("$VsCodeVsixVersion".Trim().Length -eq 0) {
$VsCodeVsixVersion = "$SemverVersion".split('-')[0];
}
$Telemetry = "$($Env:ASSEMBLY_CONSTANTS)".Contains("TELEMETRY").ToString().ToLower();
Write-Host "Enable telemetry: $Telemetry";
Get-ChildItem -Recurse *.v.template `
| ForEach-Object {
$Source = $_.FullName;
$Target = $Source.Substring(0, $Source.Length - 11);
Write-Verbose "Replacing ASSEMBLY_VERSION with $AssemblyVersion in $Source and writing to $Target.";
Get-Content $Source `
| ForEach-Object {
$_.
Replace("#MAJOR_VERSION#", $MajorVersion).
Replace("#MINOR_VERSION#", $MinorVersion).
Replace("#ASSEMBLY_VERSION#", $AssemblyVersion).
Replace("#NUGET_VERSION#", $NuGetVersion).
Replace("#VSVSIX_VERSION#", $VsVsixVersion).
Replace("#VSCODEVSIX_VERSION#", $VsCodeVsixVersion).
Replace("#SEMVER_VERSION#", $SemverVersion).
Replace("#ENABLE_TELEMETRY#", $Telemetry)
} `
| Set-Content $Target
}
If ($Env:ASSEMBLY_VERSION -eq $null) { $Env:ASSEMBLY_VERSION ="$AssemblyVersion" }
If ($Env:NUGET_VERSION -eq $null) { $Env:NUGET_VERSION ="$NuGetVersion" }
If ($Env:SEMVER_VERSION -eq $null) { $Env:SEMVER_VERSION ="$SemverVersion" }
If ($Env:VSVSIX_VERSION -eq $null) { $Env:VSVSIX_VERSION ="$VsVsixVersion" }
If ($Env:VSCODEVSIX_VERSION -eq $null) { $Env:VSCODEVSIX_VERSION ="$VsCodeVsixVersion" }
Write-Host "##vso[task.setvariable variable=VsVsix.Version]$VsVsixVersion"
Write-Host "##vso[task.setvariable variable=VsCodeVsixVersion]$VsCodeVsixVersion"
Write-Host "##[info]Finding NuSpec references..."
Push-Location (Join-Path $PSScriptRoot 'src/QsCompiler/Compiler')
.\FindNuspecReferences.ps1;
Pop-Location
Push-Location (Join-Path $PSScriptRoot 'src/QsCompiler/CSharpGeneration')
.\FindNuspecReferences.ps1;
Pop-Location
Push-Location (Join-Path $PSScriptRoot 'src/QsCompiler/QirGeneration')
.\FindNuspecReferences.ps1;
Pop-Location
git submodule init
git submodule update