-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathrelease.ps1
61 lines (53 loc) · 1.57 KB
/
release.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
[CmdletBinding()]
param(
[Parameter(Position = 0)]
[string] $Configuration = 'Release'
)
$msBuild = "msbuild"
try
{
& $msBuild /version
Write-Host "Likely on Linux/macOS."
$solution = "SharpSnmpLib.Samples.sln"
& dotnet restore $solution -c $Configuration
& dotnet clean $solution -c $Configuration
& dotnet build $solution -c $Configuration
}
catch
{
Write-Host "MSBuild doesn't exist. Use VSSetup instead."
Install-Module VSSetup -Scope CurrentUser -Force
Update-Module VSSetup
$instance = Get-VSSetupInstance -All -Prerelease
$installDir = $instance.installationPath
Write-Host "Found VS in " + $installDir
$msBuild = $installDir + '\MSBuild\Current\Bin\MSBuild.exe'
if (![System.IO.File]::Exists($msBuild))
{
$msBuild = $installDir + '\MSBuild\15.0\Bin\MSBuild.exe'
if (![System.IO.File]::Exists($msBuild))
{
Write-Host "MSBuild doesn't exist on Windows. Exit."
exit 1
}
else
{
Write-Host "Likely on Windows with VS2017."
}
}
else
{
Write-Host "Likely on Windows with VS2019."
}
Write-Host "MSBuild found. Compile the projects."
$solution = "SharpSnmpLib.Samples.Windows.sln"
& $msBuild $solution /p:Configuration=$Configuration /t:restore
& $msBuild $solution /p:Configuration=$Configuration /t:clean
& $msBuild $solution /p:Configuration=$Configuration
}
if ($LASTEXITCODE -ne 0)
{
Write-Host "Compilation failed. Exit."
exit $LASTEXITCODE
}
Write-Host "Compilation finished."