forked from eduardomozart/OLWPasteAs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
67 lines (54 loc) · 2.16 KB
/
build.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
# setup a .net framework dev environment in vs code terminal
function Install-ModuleToDirectory {
[CmdletBinding()]
[OutputType('System.Management.Automation.PSModuleInfo')]
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
$Name,
[Parameter(Mandatory = $true)]
#[ValidateScript({ Test-Path $_ })]
[ValidateNotNullOrEmpty()]
$Destination
)
# does directory exist?
if (-not (Test-Path $Destination)) {
# create dir
New-Item -ItemType Directory -Force -Path $Destination
}
# Is the module already installed?
if (-not (Test-Path (Join-Path $Destination $Name))) {
# Install the module to the custom destination.
Find-Module -Name $Name -Repository 'PSGallery' | Save-Module -Path $Destination
}
# Import the module from the custom directory.
Import-Module -FullyQualifiedName (Join-Path $Destination $Name)
return (Get-Module)
}
function Get-LatestMsbuildLocation
{
Param
(
[bool] $allowPreviewVersions = $false
)
if ($allowPreviewVersions) {
$latestVsInstallationInfo = Get-VSSetupInstance -All -Prerelease | Sort-Object -Property InstallationVersion -Descending | Select-Object -First 1
} else {
$latestVsInstallationInfo = Get-VSSetupInstance -All | Sort-Object -Property InstallationVersion -Descending | Select-Object -First 1
}
Write-Host "Latest version installed is $($latestVsInstallationInfo.InstallationVersion)"
if ($latestVsInstallationInfo.InstallationVersion -like "15.*") {
$msbuildLocation = "$($latestVsInstallationInfo.InstallationPath)\MSBuild\15.0\Bin\msbuild.exe"
Write-Host "Located msbuild for Visual Studio 2017 in $msbuildLocation"
} else {
$msbuildLocation = "$($latestVsInstallationInfo.InstallationPath)\MSBuild\Current\Bin\msbuild.exe"
Write-Host "Located msbuild in $msbuildLocation"
}
return $msbuildLocation
}
Install-ModuleToDirectory -Name 'VSSetup' -Destination '.\PSModules'
$msbuildLocation = Get-LatestMsbuildLocation
set-alias msb $msbuildLocation
# run msbuild.exe and restore nuget packages referenced
msb -t:restore
msb