Skip to content

Commit

Permalink
start-vs.cmd will point to instructions if no sln found (#4118)
Browse files Browse the repository at this point in the history
Resolves #4116
  • Loading branch information
RussKie authored Jun 26, 2023
1 parent bb9d900 commit cb688f1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
5 changes: 4 additions & 1 deletion docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,15 @@ To find out more about the script and its parameters run: `.\build.cmd -help`.

#### TL;DR

Generating a new solution and opening it in Visual Studio is as easy as running:
Generating a new "filtered" solution and opening it in Visual Studio is as easy as running:

```powershell
> build.cmd -vs <keywords>
```

For example, to generate a solution that contains projects with "Http" and "Fakes" in their names you can run: `.\build.cmd -vs Http,Fakes`.<br />
If for some reason you wish to generate a solution with all projects you can pass `*` for the keyword, e.g.: `.\build.cmd -vs *`.

If you already have a solution you'd like to open in Visual Studio then run the following command:

```powershell
Expand Down
6 changes: 4 additions & 2 deletions start-code.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ FOR /f "delims=" %%a IN ('where.exe code') DO @SET vscode=%%a& GOTO break
:break

IF ["%vscode%"] == [""] (
echo [ERROR] Visual Studio Code is not installed or can't be found.
echo [ERROR] Visual Studio Code is not installed or can't be found.
echo.
exit /b 1
)

Expand All @@ -22,7 +23,8 @@ SET DOTNET_MULTILEVEL_LOOKUP=0
SET PATH=%DOTNET_ROOT%;%PATH%

IF NOT EXIST "%DOTNET_ROOT%\dotnet.exe" (
echo [ERROR] .NET SDK has not yet been installed. Run `%~dp0restore.cmd` to install the toolset.
echo [ERROR] .NET SDK has not yet been installed. Run %~dp0restore.cmd to install.
echo.
exit /b 1
)

Expand Down
13 changes: 10 additions & 3 deletions start-vs.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,25 @@ 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%

set SLN=SDK.sln
if not exist "%~dp0%SLN%" (
echo [ERROR] %~dp0%SLN% not found.
echo See %~dp0%docs\building.md for instructions on how to generate a solution file.
echo.
exit /b 1
)

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
echo [ERROR] .NET SDK has not yet been installed. Run %~dp0restore.cmd to install.
echo.
exit /b 1
)

:: 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"

set SLN=SDK.sln

if exist "%DEVENV%" (
:: Fully qualified works
set "COMMAND=start "" /B "%ComSpec%" /S /C ""%DEVENV%" "%~dp0%SLN%"""
Expand Down

0 comments on commit cb688f1

Please sign in to comment.