Skip to content

Commit 4be5393

Browse files
authored
Merge pull request #6819 from dotnet/dev/maryamariyan/contributing-md
Updates the CONTRIBUTING.md file
2 parents a46f078 + 26d9328 commit 4be5393

File tree

1 file changed

+124
-25
lines changed

1 file changed

+124
-25
lines changed

CONTRIBUTING.md

Lines changed: 124 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,150 @@
1-
## Local development
1+
## Table of Contents
22

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+
- [Configuring Local Language Servers](#configuring-local-language-servers)
11+
- [Finding the `settings.json` file for your workspace](#finding-the-settingsjson-file-for-your-workspace)
12+
- [Configuring Roslyn Language Server](#configuring-roslyn-language-server)
13+
- [Configuring Razor Language Server](#configuring-razor-language-server)
14+
- [Creating VSIX Packages for the Extension](#creating-vsix-packages-for-the-extension)
15+
- [Updating the `Roslyn` Language Server Version](#updating-the-roslyn-language-server-version)
416

5-
First install:
17+
## Setting Up Local Development Environment
18+
19+
Setting up your local development environment for the vscode-csharp repository involves several steps. This guide will walk you through the process.
20+
21+
### Prerequisites for Development
22+
23+
Before you start, make sure you have the following software installed on your machine:
624

725
* Node.js ([v18.17.0 LTS](https://nodejs.org/en/blog/release/v18.17.0) is recommended).
826
* Npm (The version shipped with node is fine)
927
* .NET 7.0 SDK (dotnet should be on your path)
1028

11-
### Build and run the extension
29+
Once you have these installed, you can navigate to the cloned vscode-csharp repository to proceed with building, running, and testing the repository.
30+
31+
### Building, Running, and Testing the Repository
32+
33+
Follow these steps to build, run, and test the repository:
34+
35+
#### Building
36+
37+
1. Run `npm i` - This command installs the project dependencies.
38+
2. Run `npm i -g gulp` - This command installs Gulp globally.
39+
3. Run `gulp installDependencies` - This command downloads the various dependencies as specified by the version in the [package.json](package.json) file.
40+
4. Run `code .` - This command opens the project in Visual Studio Code.
41+
42+
#### Running
43+
44+
After completing the build steps:
45+
46+
1. Run `npm run watch` (Optional) - This command watches for code changes.
47+
2. Press <kbd>Ctrl+Shift+D</kbd> to open the Run view in VS Code and ensure `Launch Extension` is selected.
48+
3. Start debugging by pressing <kbd>F5</kbd>.
49+
50+
#### Testing
51+
52+
To run tests:
53+
54+
1. Execute `npm run test` or press <kbd>F5</kbd> in VS Code with the "Launch Tests" debug configuration selected.
55+
2. For integration tests, select either of the two 'current file' integration tests (one for roslyn and one for razor), from the drop-down and press <kbd>F5</kbd> to start debugging:
56+
- For Roslyn Server: `Launch Current File slnWithCsproj Integration Tests`
57+
- For Razor Server: `Launch Current File BasicRazorApp2_1 Integration Tests`
58+
59+
These will allow you to actually debug the test, but the 'Razor integration tests' configuration does not.
60+
61+
### Setting Up Local Language Servers
62+
63+
This section shows how to set up local Razor or Roslyn language servers for debugging with the VSCode C# extension.
64+
65+
#### Roslyn
66+
67+
1. Clone the [Roslyn repository](https://github.com/dotnet/roslyn). This repository contains the Roslyn server implementation.
68+
2. Follow the build instructions provided in the repository.
69+
70+
The server DLL is typically at `$roslynRepoRoot/artifacts/bin/Microsoft.CodeAnalysis.LanguageServer/Debug/net7.0/Microsoft.CodeAnalysis.LanguageServer.dll`, but this may vary based on the built configuration.
71+
72+
#### Razor
73+
74+
1. Clone the [Razor repository](https://github.com/dotnet/razor). This repository contains the Razor server implementation.
75+
2. Follow the build instructions provided in the repository.
76+
77+
The server DLL is typically at `$razorRepoRoot/artifacts/bin/rzls/Debug/net8.0`.
78+
79+
### Debugging Local Language Servers
80+
81+
Before running the language servers, familiarize yourself with the steps in the [Configuring Local Language Servers](#configuring-local-language-servers) section to configure either the Roslyn or Razor language servers for debugging .
82+
83+
**Note**: You would only need to configure this for the workspace you wish to debug, NOT for the repo root of vscode-csharp repo.
84+
85+
Follow these steps to enable debugging:
86+
87+
1. Press `Ctrl+Shift+D` and then `F5` to launch the extension. This will open a new VS Code instance for `vscode-csharp` repo.
88+
2. In the new VS Code instance, open the project or solution you want to debug.
89+
3. Follow instructions in [Configuring Local Language Servers](#configuring-local-language-servers) to find and configure the workspace settings for the language server you want to debug.
90+
4. Ensure the language server is fully built in Debug mode.
91+
5. Meanwhile in a Visual Studio instance open the `.sln` solution file for the language server you want to debug. Keep this instance open for use in a later step.
92+
6. Back on VS Code, press `Ctrl+Shift+P` and select `Reload Window`. This ensures the changes made in step 3 are applied.
93+
7. After reloading, a window will pop up prompting you to select or open a Visual Studio instance. Now, select the instance you opened in step 5.
94+
8. The language server will now trigger a breakpoint on `Debugger.Launch()` when it starts.
95+
96+
### Configuring Local Language Servers
97+
98+
This section provides instructions on how to debug locally built Roslyn and Razor language servers. You can do this by either directly editing the `settings.json` file of your workspace or through the VSCode settings interface.
1299

13-
To run and develop the extension do the following:
100+
#### Finding the `settings.json` file for your workspace
101+
- Open the Command Palette with `Ctrl+Shift+P` (or `Cmd+Shift+P` on macOS)
102+
- Type "Preferences: Open Workspace Settings"
103+
- Select the option that appears.
104+
- In the Workspace Settings tab, in the upper right corner, you'll see an icon that looks like a document with an arrow, which is the "Open Settings (JSON)" button.
105+
- Click on this button to open the `settings.json` file.
14106

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
107+
#### Configuring Roslyn Language Server
21108

22-
To **test** do the following: `npm run test` or <kbd>F5</kbd> in VS Code with the "Launch Tests" debug configuration.
109+
In your workspace `settings.json` file, add the following lines:
23110

24-
### Using a locally developed Roslyn server
111+
```json
112+
"dotnet.server.waitForDebugger": true,
113+
"dotnet.server.path": "<roslynRepoRoot>/artifacts/bin/Microsoft.CodeAnalysis.LanguageServer/Debug/net7.0/Microsoft.CodeAnalysis.LanguageServer.dll"
114+
```
25115

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
116+
Replace <roslynRepoRoot> with the actual path to your Roslyn repository.
27117

28-
`$roslynRepoRoot/artifacts/bin/Microsoft.CodeAnalysis.LanguageServer/Debug/net7.0/Microsoft.CodeAnalysis.LanguageServer.dll`
118+
Or, in VSCode settings (`Ctrl+,`):
29119

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.
120+
1. Search for `dotnet server`.
121+
2. Set `dotnet.server.path` to the path of your Roslyn DLL.
122+
3. Enable `dotnet.server.waitForDebugger`.
31123

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.
124+
#### Configuring Razor Language Server
33125

34-
### Using a locally developed Razor server
126+
In your workspace settings.json file, add the following lines:
35127

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
128+
```json
129+
"razor.languageServer.debug": true,
130+
"razor.languageServer.directory": "<razorRepoRoot>/artifacts/bin/rzls/Debug/net8.0",
131+
"razor.server.trace": "Debug"
132+
```
37133

38-
`$razorRepoRoot/artifacts/bin/rzls/Debug/net7.0`
134+
Replace `$razorRepoRoot` with your actual values.
39135

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.
136+
Or, in VSCode settings (`Ctrl+,`):
41137

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
138+
1. Search for `Razor`.
139+
2. Set `razor.languageServer.directory` to the path of your Razor DLL.
140+
3. Enable `razor.languageServer.debug`.
141+
4. Set `razor.server.trace` to `Debug`. This gives you more detailed log messages in the output window.
43142

44-
### Creating VSIXs
143+
## Creating VSIX Packages for the Extension
45144

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.
145+
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.
47146

48-
## Updating the Roslyn server version
147+
## Updating the `Roslyn` Language Server Version
49148

50149
To update the version of the roslyn server used by the extension do the following:
51150
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

Comments
 (0)