Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add batch file for easier launching of VS #9915

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions start-vs.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@echo off
setlocal enabledelayedexpansion

:: This command launches a Visual Studio solution with environment variables required to use a local version of the .NET Core SDK.

:: This tells .NET Core to use the same dotnet.exe that build scripts use
set DOTNET_ROOT=%~dp0.dotnet
set DOTNET_ROOT(x86)=%~dp0.dotnet\x86

:: This tells .NET Core not to go looking for .NET Core in other places
set DOTNET_MULTILEVEL_LOOKUP=0

:: Put our local dotnet.exe on PATH first so Visual Studio knows which one to use
set PATH=%DOTNET_ROOT%;%PATH%

call restore.cmd

if not exist "%DOTNET_ROOT%\dotnet.exe" (
echo [ERROR] .NET Core has not yet been installed. Run `%~dp0restore.cmd` to install tools
exit /b 1
)

:: These tasks aren't running successfully when launching VS, skipping when launching via this batch file
set RunNetFrameworkApiCompat=false
set RunRefApiCompat=false

:: Prefer the VS in the developer command prompt if we're in one, followed by whatever shows up in the current search path.
set "DEVENV=%DevEnvDir%devenv.exe"

if exist "%DEVENV%" (
:: Fully qualified works
set "COMMAND=start "" /B "%ComSpec%" /S /C ""%DEVENV%" "%~dp0Microsoft.Dotnet.Wpf.sln"""
) else (
where devenv.exe /Q
if !errorlevel! equ 0 (
:: On the PATH, use that.
set "COMMAND=start "" /B "%ComSpec%" /S /C "devenv.exe "%~dp0Microsoft.Dotnet.Wpf.sln"""
) else (
:: Can't find devenv.exe, let file associations take care of it
set "COMMAND=start /B .\Microsoft.Dotnet.Wpf.sln"
)
)

%COMMAND%