Skip to content

Commit 343990d

Browse files
Merge pull request #9915 from JeremyKuhne/startvs
Add batch file for easier launching of VS
2 parents e11f0e8 + 65f081f commit 343990d

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

start-vs.cmd

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@echo off
2+
setlocal enabledelayedexpansion
3+
4+
:: This command launches a Visual Studio solution with environment variables required to use a local version of the .NET Core SDK.
5+
6+
:: This tells .NET Core to use the same dotnet.exe that build scripts use
7+
set DOTNET_ROOT=%~dp0.dotnet
8+
set DOTNET_ROOT(x86)=%~dp0.dotnet\x86
9+
10+
:: This tells .NET Core not to go looking for .NET Core in other places
11+
set DOTNET_MULTILEVEL_LOOKUP=0
12+
13+
:: Put our local dotnet.exe on PATH first so Visual Studio knows which one to use
14+
set PATH=%DOTNET_ROOT%;%PATH%
15+
16+
call restore.cmd
17+
18+
if not exist "%DOTNET_ROOT%\dotnet.exe" (
19+
echo [ERROR] .NET Core has not yet been installed. Run `%~dp0restore.cmd` to install tools
20+
exit /b 1
21+
)
22+
23+
:: These tasks aren't running successfully when launching VS, skipping when launching via this batch file
24+
set RunNetFrameworkApiCompat=false
25+
set RunRefApiCompat=false
26+
27+
:: Prefer the VS in the developer command prompt if we're in one, followed by whatever shows up in the current search path.
28+
set "DEVENV=%DevEnvDir%devenv.exe"
29+
30+
if exist "%DEVENV%" (
31+
:: Fully qualified works
32+
set "COMMAND=start "" /B "%ComSpec%" /S /C ""%DEVENV%" "%~dp0Microsoft.Dotnet.Wpf.sln"""
33+
) else (
34+
where devenv.exe /Q
35+
if !errorlevel! equ 0 (
36+
:: On the PATH, use that.
37+
set "COMMAND=start "" /B "%ComSpec%" /S /C "devenv.exe "%~dp0Microsoft.Dotnet.Wpf.sln"""
38+
) else (
39+
:: Can't find devenv.exe, let file associations take care of it
40+
set "COMMAND=start /B .\Microsoft.Dotnet.Wpf.sln"
41+
)
42+
)
43+
44+
%COMMAND%

0 commit comments

Comments
 (0)