-
Notifications
You must be signed in to change notification settings - Fork 676
/
PowershellEnvironment.ps1
68 lines (57 loc) · 1.74 KB
/
PowershellEnvironment.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
Param([string]$TfsWorkspace='')
function Get-Batchfile ($file) {
$cmd = "`"$file`" & set"
cmd /c $cmd | Foreach-Object {
$p, $v = $_.split('=')
if($p -ne '') {
Set-Item -path env:$p -value $v
}
}
}
function VsVars32()
{
#Scan for the most recent version of Visual Studio
#Order:
# Visual Studio 2015
# Visual Studio 2013
# Visual Studio 2012
# Visual Studio 2010
#
$vscomntools = (Get-ChildItem env:VS140COMNTOOLS).Value
if([string]::IsNullOrEmpty($vscomntools)) {
"Visual Studio 2015 not installed, Falling back to 2013"
$vscomntools = (Get-ChildItem env:VS120COMNTOOLS).Value
if([string]::IsNullOrEmpty($vscomntools))
{
"Visual Studio 2013 not installed, Falling back to 2012"
$vscomntools = (Get-ChildItem env:VS110COMNTOOLS).Value
if([string]::IsNullOrEmpty($vscomntools))
{
"Visual Studio 2012 not installed, Falling back to 2010"
$vscomntools = (Get-ChildItem env:VS100COMNTOOLS).Value
}
}
}
$batchFile = [System.IO.Path]::Combine($vscomntools, "vsvars32.bat")
Get-Batchfile $BatchFile
}
"Initializing Python Powershell Environment"
# determine enlistment root
$pnjsRoot = $script:MyInvocation.MyCommand.Path | Split-Path -parent;
"Python Tools Root = " + $pnjsRoot;
# get VS tools
"Calling vsvars32"
VsVars32
# ensure prerequisites are available
& "$pnjsRoot\Build\PreBuild.ps1"
$env:PTVS_DEV="true"
# set environment var for codereview.bat
if ( $TfsWorkspace -ne '' )
{
$Env:TfsWorkspace = $TfsWorkspace
}
""
"Environment Ready"
""
# Update the title of Window
(Get-Host).UI.RawUI.WindowTitle = "Python Powershell Environment"