|
1 |
| -## Local development |
| 1 | +## Table of Contents |
2 | 2 |
|
3 |
| -### Pre-requisites |
| 3 | +- [Setting Up Local Development Environment](#setting-up-local-development-environment) |
| 4 | + - [Prerequisites for Development](#prerequisites-for-development) |
| 5 | + - [Building, Running, and Testing the Repository](#building-running-and-testing-the-repository) |
| 6 | + - [Setting Up Local Language Servers](#setting-up-local-language-servers) |
| 7 | + - [Roslyn](#roslyn) |
| 8 | + - [Razor](#razor) |
| 9 | + - [Debugging Local Language Servers](#debugging-local-language-servers) |
| 10 | + - [Roslyn](#roslyn-1) |
| 11 | + - [Razor](#razor-1) |
| 12 | + - [Creating VSIX Packages for the Extension](#creating-vsix-packages-for-the-extension) |
| 13 | +- [Updating the `Roslyn` Language Server Version](#updating-the-roslyn-language-server-version) |
4 | 14 |
|
5 |
| -First install: |
| 15 | +## Setting Up Local Development Environment |
| 16 | + |
| 17 | +Setting up your local development environment for the vscode-csharp repository involves several steps. This guide will walk you through the process. |
| 18 | + |
| 19 | +### Prerequisites for Development |
| 20 | + |
| 21 | +Before you start, make sure you have the following software installed on your machine: |
6 | 22 |
|
7 | 23 | * Node.js ([v18.17.0 LTS](https://nodejs.org/en/blog/release/v18.17.0) is recommended).
|
8 | 24 | * Npm (The version shipped with node is fine)
|
9 |
| -* .NET 7.0 SDK (dotnet should be on your path) |
| 25 | +* .NET 8.0 SDK (dotnet should be on your path) |
| 26 | + |
| 27 | +Once you have these installed, you can proceed to clone the vscode-csharp repository: |
| 28 | + |
| 29 | +```bash |
| 30 | +git clone https://github.com/your-username/vscode-csharp.git |
| 31 | +cd vscode-csharp |
| 32 | +``` |
| 33 | + |
| 34 | +Next, install the necessary npm packages: |
| 35 | + |
| 36 | +```bash |
| 37 | +npm install |
| 38 | +``` |
| 39 | + |
| 40 | +Now, you're ready to start building, running, and testing the repository. |
| 41 | + |
| 42 | +### Building, Running, and Testing the Repository |
| 43 | + |
| 44 | +Follow these steps to build, run, and test the repository: |
| 45 | + |
| 46 | +#### Building |
| 47 | + |
| 48 | +1. Run `npm i` - This command installs the project dependencies. |
| 49 | +2. Run `npm i -g gulp` - This command installs Gulp globally. |
| 50 | +3. Run `gulp installDependencies` - This command downloads the various dependencies as specified by the version in the [package.json](package.json) file. |
| 51 | +4. Run `code .` - This command opens the project in Visual Studio Code. |
| 52 | +5. Run `npm run watch` (Optional) - This command watches for code changes. |
| 53 | + |
| 54 | +#### Running |
| 55 | + |
| 56 | +After completing the build steps: |
| 57 | + |
| 58 | +1. Press <kbd>Ctrl+Shift+D</kbd> to open the Run view in VS Code and ensure `Launch Extension` is selected. |
| 59 | +2. Start debugging by pressing <kbd>F5</kbd>. |
| 60 | + |
| 61 | +#### Testing |
| 62 | + |
| 63 | +To run tests: |
| 64 | + |
| 65 | +1. Execute `npm run test` or press <kbd>F5</kbd> in VS Code with the "Launch Tests" debug configuration selected. |
| 66 | +2. For integration tests, select `Razor Integration Tests` and press <kbd>F5</kbd> to start debugging. |
10 | 67 |
|
11 |
| -### Build and run the extension |
| 68 | +### Setting Up Local Language Servers |
12 | 69 |
|
13 |
| -To run and develop the extension do the following: |
| 70 | +This section provides a step-by-step guide on setting up locally developed Razor or Roslyn language servers for debugging. This setup is beneficial when troubleshooting the behavior of these language servers with the VSCode C# extension. |
14 | 71 |
|
15 |
| -* Run `npm i` |
16 |
| -* Run `npm i -g gulp` |
17 |
| -* Run `gulp installDependencies` (this will download the various dependencies as specified by the version in the [package.json](package.json)) |
18 |
| -* Open in Visual Studio Code (`code .`) |
19 |
| -* _Optional:_ run `npm run watch`, make code changes |
20 |
| -* Press <kbd>F5</kbd> to debug |
| 72 | +#### Roslyn |
21 | 73 |
|
22 |
| -To **test** do the following: `npm run test` or <kbd>F5</kbd> in VS Code with the "Launch Tests" debug configuration. |
| 74 | +1. Clone the [Roslyn repository](https://github.com/dotnet/roslyn) locally. This repository contains the Roslyn server implementation. |
| 75 | +2. Follow the build instructions provided in the repository. |
23 | 76 |
|
24 |
| -### Using a locally developed Roslyn server |
| 77 | +After building, you can find the server DLL in the build output directory. The typical location is `$roslynRepoRoot/artifacts/bin/Microsoft.CodeAnalysis.LanguageServer/Debug/net8.0/Microsoft.CodeAnalysis.LanguageServer.dll`, but this may vary based on the built configuration. |
25 | 78 |
|
26 |
| -https://github.com/dotnet/roslyn contains the server implementation. Follow the instructions there to build the repo as normal. Once built, the server DLL will be located in the build output directory, typically |
| 79 | +#### Razor |
27 | 80 |
|
28 |
| -`$roslynRepoRoot/artifacts/bin/Microsoft.CodeAnalysis.LanguageServer/Debug/net7.0/Microsoft.CodeAnalysis.LanguageServer.dll` |
| 81 | +1. Clone the [Razor repository](https://github.com/dotnet/razor) locally. This repository contains the Razor server implementation. |
| 82 | +2. Follow the build instructions provided in the repository. |
29 | 83 |
|
30 |
| -depending on which configuration is built. Then, launch the extension here and change the VSCode setting `dotnet.server.path` to point to the Roslyn dll path you built above and restart the language server. |
| 84 | +Similar to Roslyn, after building, the server DLL will be in the build output directory. The typical location is `$razorRepoRoot/artifacts/bin/rzls/Debug/net8.0`, but this may vary based on the built configuration. |
31 | 85 |
|
32 |
| -If you need to debug the server, you can set the VSCode setting `dotnet.server.waitForDebugger` to true. This will trigger a `Debugger.Launch()` on the server side as it starts. |
| 86 | +### Debugging Local Language Servers |
33 | 87 |
|
34 |
| -### Using a locally developed Razor server |
| 88 | +This section provides instructions on how to debug locally developed Roslyn and Razor language servers. |
35 | 89 |
|
36 |
| -https://github.com/dotnet/razor contains the server implementation. Follow the instructions there to build the repo as normal. Once built, the server will be located in the build output directory, typically |
| 90 | +#### Roslyn |
37 | 91 |
|
38 |
| -`$razorRepoRoot/artifacts/bin/rzls/Debug/net7.0` |
| 92 | +1. Open the VSCode settings by using the shortcut `Ctrl+,`. |
| 93 | +2. Enter `dotnet server` in the search box to display Roslyn-related settings. |
| 94 | +3. Update the `dotnet.server.path` setting to the path of the Roslyn DLL you built earlier, then restart the language server. |
| 95 | +4. If you need to debug the server, enable the `dotnet.server.waitForDebugger` setting. This action triggers a `Debugger.Launch()` on the server side when it starts. |
39 | 96 |
|
40 |
| -depending on which configuration is built. Then, launch the extension here and change the VSCode setting `razor.languageServer.directory` to point to the Razor executable path you built above and reload the window. |
| 97 | +#### Razor |
41 | 98 |
|
42 |
| -If you need to debug the server, you can set the VSCode setting `razor.languageServer.debug` to true. This will trigger a `Debugger.Launch()` on the server side as it starts. You can also set `razor.server.trace` to `Debug` to get more log messages in the output window |
| 99 | +1. Open the VSCode settings by using the shortcut `Ctrl+,`. |
| 100 | +2. Enter `Razor` in the search box to display Razor-related settings. |
| 101 | +3. Update the `razor.languageServer.directory` setting to the path of the Razor DLL you built earlier, then restart the language server. |
| 102 | +4. If you need to debug the server, enable the `razor.languageServer.debug` setting. This action triggers a `Debugger.Launch()` on the server side when it starts. |
| 103 | +5. For more detailed log messages in the output window, set `razor.server.trace` to `Debug`. |
43 | 104 |
|
44 |
| -### Creating VSIXs |
| 105 | +### Creating VSIX Packages for the Extension |
45 | 106 |
|
46 |
| -VSIXs can be created using the gulp command `gulp vsix:release:package`. This will create all the platform specific VSIXs that you can then install manually in VSCode. |
| 107 | +To package this extension, we need to create VSIX Packages. The VSIX packages can be created using the gulp command `gulp vsix:release:package`. This will create all the platform specific VSIXs that you can then install manually in VSCode. |
47 | 108 |
|
48 |
| -## Updating the Roslyn server version |
| 109 | +## Updating the `Roslyn` Language Server Version |
49 | 110 |
|
50 | 111 | To update the version of the roslyn server used by the extension do the following:
|
51 | 112 | 1. Find the the Roslyn signed build you want from [here](https://dnceng.visualstudio.com/internal/_build?definitionId=327&_a=summary). Typically the latest successful build of main is fine.
|
|
0 commit comments