forked from scriptcs/scriptcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchocolateyInstall.ps1
More file actions
46 lines (35 loc) · 1.54 KB
/
chocolateyInstall.ps1
File metadata and controls
46 lines (35 loc) · 1.54 KB
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
try {
$oldpaths = @(
"$env:APPDATA\scriptcs"
)
$oldpaths | foreach {
if (Test-Path $_) {
Remove-Item $_ -Recurse -Force
}
Write-Host "'$_' has been removed." -ForegroundColor DarkYellow
}
$tools = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$nuget = "$env:ChocolateyInstall\ChocolateyInstall\nuget"
$binPath = "$env:LOCALAPPDATA\scriptcs"
$nugetPath = "$tools\nugets"
New-Item $binPath -ItemType Directory -Force | Out-Null
Copy-Item "$tools\scriptcs\*" $binPath -Force
Write-Host "Retrieving NuGet dependencies..." -ForegroundColor DarkYellow
$dependencies = @{
"Roslyn.Compilers.CSharp" = "1.2.20906.2";
}
$dependencies.GetEnumerator() | %{ &nuget install $_.Name -version $_.Value -o $nugetPath }
Get-ChildItem $nugetPath -Filter "*.dll" -Recurse | %{ Copy-Item $_.FullName $binPath -Force }
Remove-Item $nugetPath -Recurse -Force
New-Item "$tools\scriptcs\scriptcs.exe.ignore" -ItemType File -Force | Out-Null
if (Test-Path "$tools\..\lib") {
Remove-Item "$tools\..\lib" -Recurse -Force
}
Install-ChocolateyPath $binPath
Write-Host "scriptcs.exe has been installed to $binpath and has been added to your path." -ForegroundColor DarkYellow
Write-Host "You may need to open a new console for the new path to take effect. Happy scripting!" -ForegroundColor DarkYellow
Write-ChocolateySuccess 'scriptcs'
} catch {
Write-ChocolateyFailure 'scriptcs' "$($_.Exception.Message)"
throw
}