forked from microsoft/qsharp-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.ps1
59 lines (49 loc) · 1.85 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
param(
[string]
$AssemblyVersion = $Env:ASSEMBLY_VERSION,
[string]
$SemverVersion = $Env:SEMVER_VERSION,
[string]
$NuGetVersion = $Env:NUGET_VERSION,
[string]
$VsixVersion = $Env:VSIX_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.0.$Year$Month.$Hour$Minute";
}
if ("$SemverVersion".Trim().Length -eq 0) {
$pieces = "$AssemblyVersion".split(".");
$SemverVersion = "$($pieces[0]).$($pieces[1]).$($pieces[2])$($pieces[3])";
}
if ("$NuGetVersion".Trim().Length -eq 0) {
$NuGetVersion = "$AssemblyVersion-alpha";
}
if ("$VsixVersion".Trim().Length -eq 0) {
$VsixVersion = "$AssemblyVersion";
}
$Telemetry = "$($Env:ASSEMBLY_CONSTANTS)".Contains("TELEMETRY").ToString().ToLower();
Write-Output("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("#ASSEMBLY_VERSION#", $AssemblyVersion).
Replace("#NUGET_VERSION#", $NuGetVersion).
Replace("#VSIX_VERSION#", $VsixVersion).
Replace("#SEMVER_VERSION#", $SemverVersion).
Replace("#ENABLE_TELEMETRY#", $Telemetry)
} `
| Set-Content $Target -NoNewline
}
Push-Location (Join-Path $PSScriptRoot 'src/QsCompiler/Compiler')
.\FindNuspecReferences.ps1;
Pop-Location