Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- reg.exe query "HKLMSOFTWAREMicrosoftMSBuildToolsVersions14.0" /v MSBuildToolsPath > nul 2>&1
- if ERRORLEVEL 1 goto MissingMSBuildRegistry
- for /f "skip=2 tokens=2,*" %%A in ('reg.exe query "HKLMSOFTWAREMicrosoftMSBuildToolsVersions14.0" /v MSBuildToolsPath') do SET "MSBUILDDIR=%%B"
- echo.
- echo MSBuildToolsPath: %MSBUILDDIR%
- echo.
- IF NOT EXIST "%MSBUILDDIR%" goto MissingMSBuildToolsPath
- IF NOT EXIST "%MSBUILDDIR%msbuild.exe" goto MissingMSBuildExe
- IF EXIST "%MSBUILDDIR%Microsoft.Common.targets.bak" goto AlreadyPatched
- ::-------------------------------------
- REM --> Check for permissions
- >nul 2>&1 "%SYSTEMROOT%system32cacls.exe" "%SYSTEMROOT%system32configsystem"
- REM --> If error flag set, we do not have admin.
- if '%errorlevel%' NEQ '0' (
- echo Requesting administrative privileges...
- goto UACPrompt
- ) else ( goto gotAdmin )
- :UACPrompt
- echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%getadmin.vbs"
- echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%getadmin.vbs"
- "%temp%getadmin.vbs"
- exit /B
- :gotAdmin
- if exist "%temp%getadmin.vbs" ( del "%temp%getadmin.vbs" )
- pushd "%CD%"
- CD /D "%~dp0"
- ::--------------------------------------
- :: Replace MSBuild 14.0 Microsoft.Common.targets file with MSBuild 15.0 file.
- rename "%MSBUILDDIR%Microsoft.Common.targets" "Microsoft.Common.targets.bak"
- copy "MSBuil15.Microsoft.Common.targets" "%MSBUILDDIR%Microsoft.Common.targets"
- exit /b 0
- goto:eof
- ::ERRORS
- ::---------------------
- :MissingMSBuildRegistry
- echo Cannot obtain path to MSBuild tools from registry
- goto:eof
- :MissingMSBuildToolsPath
- echo The MSBuild tools path from the registry '%MSBUILDDIR%' does not exist
- goto:eof
- :MissingMSBuildExe
- echo The MSBuild executable could not be found at '%MSBUILDDIR%'
- goto:eof
- :AlreadyPatched
- echo The Microsoft.Common.targets file is already patched
- goto:eof
Add Comment
Please, Sign In to add comment