forked from microsoft/qsharp-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.ps1
73 lines (61 loc) · 2.53 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
param(
[string]
$AssemblyVersion = $Env:ASSEMBLY_VERSION,
[string]
$SemverVersion = $Env:SEMVER_VERSION,
[string]
$NuGetVersion = $Env:NUGET_VERSION,
[string]
$VsVsixVersion = $Env:VSVSIX_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";
}
$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("#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" }
Write-Host "##vso[task.setvariable variable=VsVsix.Version]$VsVsixVersion"
Push-Location (Join-Path $PSScriptRoot 'src/QsCompiler/Compiler')
.\FindNuspecReferences.ps1;
Pop-Location