-
Notifications
You must be signed in to change notification settings - Fork 1
/
core.psm1
86 lines (77 loc) · 1.94 KB
/
core.psm1
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
$PSDefaultParameterValues['*:Verbose'] = $true;
Function Remove-Folder {
Param (
[String] $FolderName
)
If (Test-Path $FolderName) {
Remove-Item $FolderName -Recurse -Force | Out-Null;
}
}
Export-ModuleMember -Function Remove-Folder;
Function New-Folder {
Param (
[String] $FolderName
)
If (-Not (Test-Path $FolderName)) {
New-Item -Path . -Name $FolderName -ItemType "directory" | Out-Null;
}
}
Export-ModuleMember -Function New-Folder;
Function Test-CommandExists {
Param (
[String]$command
)
$oldPreference = $ErrorActionPreference
$ErrorActionPreference = 'stop';
Try {
If (Get-Command $command) {
Return $True;
}
}
Catch {
Return $False;
}
Finally {
$ErrorActionPreference = $oldPreference;
}
}
Export-ModuleMember -Function Test-CommandExists;
Function Install-PSModule {
Param (
[String] $Name
)
If (-Not $(Get-Module -ListAvailable -Name PowerShellGet)) {
Write-Host "Setting up module PowerShellGet...";
Find-Module -Name PowerShellGet | Install-Module;
}
If (-Not $(Get-Module -ListAvailable -Name $Name)) {
Write-Host "Installing module $Name...";
Install-Module $Name -Scope CurrentUser -Force;
}
Else {
Write-Host "Module $Name already Installed";
}
}
Export-ModuleMember -Function Install-PSModule;
Function Get-NuGet {
Param ()
If (-Not (Test-CommandExists nuget)) {
If (-Not (Test-Path -Path "./nuget.exe" -PathType Leaf)) {
$nugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe";
Invoke-WebRequest $nugetUrl -OutFile $destination;
}
$destination = "$(get-Location)/nuget.exe";
Set-Alias nuget "$destination" -Scope Global -Force;
}
}
Export-ModuleMember -Function Get-NuGet;
Function Install-BuildTools {
Param ()
# Install VSSetup module
Install-PSModule VSSetup;
# Install Build utils command
Install-PSModule BuildUtils;
Set-Alias msbuild $(Get-LatestMsbuildLocation) -Scope Global -Force;
Get-NuGet;
}
Export-ModuleMember -Function Install-BuildTools;