-
Notifications
You must be signed in to change notification settings - Fork 0
/
.install.cmd
46 lines (36 loc) · 1.68 KB
/
.install.cmd
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
@echo off
set DOT_POWERSHELL_CMD="%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command
echo Checking prerequisites...
call .prerequisites check
if %ERRORLEVEL% equ 0 goto build
echo Installing prerequisites...
%DOT_POWERSHELL_CMD% "$process = (Start-Process -Wait -PassThru -FilePath 'cmd.exe' -ArgumentList '/c \"%~dp0\.prerequisites.cmd\"' -Verb runAs); exit $process.ExitCode"
if %ERRORLEVEL% equ 350 echo Computer restart is required to complete prerequisites installation. & exit %ERRORLEVEL%
if %ERRORLEVEL% neq 0 echo Prerequisites are incomplete. Re-open command prompt and try again. & exit %ERRORLEVEL%
call :refresh_env
:build
call :add_dots_path "%%USERPROFILE%%\.dots"
call :add_dots_path "%%ALLUSERSPROFILE%%\chocolatey\bin"
call :add_nuget_source "%USERPROFILE%\.nuget\local" nuget.local
git rev-parse --is-inside-work-tree 1>nul 2>nul
if %ERRORLEVEL% equ 0 (call .pack) else (call .clone)
call :refresh_env
echo Installation complete.
goto :eof
:add_nuget_source
dotnet nuget list source | find "%~1" >nul
if %ERRORLEVEL% equ 0 goto :eof
echo Adding %~2 source "%~1"
dotnet nuget add source "%~1" -n nuget.local
goto :eof
:add_dots_path
set INSTALL_PATH=%~1
set PATH | find "%INSTALL_PATH%" > nul
if %ERRORLEVEL% equ 0 goto :eof
echo Adding %INSTALL_PATH% to PATH environment
%DOT_POWERSHELL_CMD% "$path=[Environment]::GetEnvironmentVariable('path', 'user'); if (!$path.contains('%INSTALL_PATH%')) { $path+=';%INSTALL_PATH%'; [Environment]::SetEnvironmentVariable('path', $($path -join ';'), 'user'); }"
call :refresh_env
exit /b %ERRORLEVEL%
:refresh_env
call %ALLUSERSPROFILE%\chocolatey\bin\RefreshEnv
goto :eof