-
Notifications
You must be signed in to change notification settings - Fork 231
/
Copy pathinstall.ps1
52 lines (41 loc) · 1.67 KB
/
install.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
param($installPath, $toolsPath, $package, $project)
$invalidVsVersion = $false
if ('14.0', '15.0', '16.0' -notcontains $project.DTE.Version) {
$invalidVsVersion = $true
}
if ($project.DTE.Version -eq '14.0') {
$currentAppDomainBaseDir = [System.AppDomain]::CurrentDomain.BaseDirectory
$path = Join-Path $currentAppDomainBaseDir "msenv.dll"
if (Test-Path $path) {
$versionInfo = (Get-Item $path).VersionInfo
$fullVersion = New-Object System.Version -ArgumentList @(
$versionInfo.FileMajorPart
$versionInfo.FileMinorPart
$versionInfo.FileBuildPart
$versionInfo.FilePrivatePart
)
$minVersion = [version]"14.0.25420.00"
if ($fullVersion -lt $minVersion) {
$invalidVsVersion = $true
}
} else {
$invalidVsVersion = $true
}
}
if ($invalidVsVersion) {
throw 'This package can only be installed on Visual Studio 2015 Update 3 or later.'
}
if ($project.Object.AnalyzerReferences -eq $null) {
throw 'This package cannot be installed without an analyzer reference.'
}
if ($project.Type -ne "VB.NET") {
throw 'This package can only be installed on VB.NET projects.'
}
$analyzersPath = Split-Path -Path $toolsPath -Parent
$analyzersPath = Join-Path $analyzersPath "analyzers"
$analyzerFilePath = Join-Path $analyzersPath "Google.Protobuf.dll"
$project.Object.AnalyzerReferences.Add($analyzerFilePath)
$analyzerFilePath = Join-Path $analyzersPath "SonarAnalyzer.dll"
$project.Object.AnalyzerReferences.Add($analyzerFilePath)
$analyzerFilePath = Join-Path $analyzersPath "SonarAnalyzer.VisualBasic.dll"
$project.Object.AnalyzerReferences.Add($analyzerFilePath)