DEVGUIDE.md 6.5 KB
Newer Older
D
Don Syme 已提交
1
# Development Guide
2

3
This document details more advanced options for developing in this codebase. It is not quite necessary to follow it, but it is likely that you'll find something you'll need from here.
4

5
## Recommended workflow
6

7
We recommend the following overall workflow when developing for this repository:
V
Volker Milbrandt 已提交
8

9 10 11
* Fork this repository
* Always work in your fork
* Always keep your fork up to date
12

13 14 15 16 17
Before updating your fork, run this command:
```
git remote add upstream https://github.com/dotnet/fsharp.git
```

18
This will make management of multiple forks and your own work easier over time.
19

20
## Updating your fork
21

22
We recommend the following commands to update your fork:
23

24
```
B
Brett V. Forsgren 已提交
25
git checkout main
26 27
git clean -xdf
git fetch upstream
B
Brett V. Forsgren 已提交
28
git rebase upstream/main
29 30
git push
```
D
Don Syme 已提交
31

32
Or more succinctly:
D
Don Syme 已提交
33

34
```
B
Brett V. Forsgren 已提交
35
git checkout main && git clean -xdf && git fetch upstream && git rebase upstream/main && git push
36
```
37

38
This will update your fork with the latest from `dotnet/fsharp` on your machine and push those updates to your remote fork.
D
Don Syme 已提交
39

40
## Developing on Windows
41

B
Brett V. Forsgren 已提交
42
Install the latest released [Visual Studio](https://www.visualstudio.com/downloads/), as that is what the `main` branch's tools are synced with. Select the following workloads:
J
John Wostenberg 已提交
43

44 45
* .NET desktop development (also check F# desktop support, as this will install some legacy templates)
* Visual Studio extension development
J
John Wostenberg 已提交
46

47
Building is simple:
48

49
    build.cmd
D
Don Syme 已提交
50

B
Brett V. Forsgren 已提交
51
Desktop tests can be run with:
D
Don Syme 已提交
52

53
    build.cmd -test -c Release
D
Don Syme 已提交
54

55
After you build the first time you can open and use this solution in Visual Studio:
D
Don Syme 已提交
56

57 58 59
    .\VisualFSharp.sln
    
If you don't have everything installed yet, you'll get prompted by Visual Studio to install a few more things. This is because we use a `.vsconfig` file that specifies all our dependencies.
D
Don Syme 已提交
60

D
Don Syme 已提交
61
If you are just developing the core compiler and library then building ``FSharp.sln`` will be enough.
D
Don Syme 已提交
62

63
We recommend installing the latest released Visual Studio and using that if you are on Windows. However, if you prefer not to do that, you will need to install the following:
D
Don Syme 已提交
64

65 66
* [.NET Framework 4.7.2](https://dotnet.microsoft.com/download/dotnet-framework/net472)
* [.NET Core 3 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.0)
D
Don Syme 已提交
67

68
You'll need to pass an additional flag to the build script:
69

70 71 72
    build.cmd -noVisualStudio
    
You can open `FSharp.sln` in your editor of choice.
73

74
## Developing on Linux or macOS
D
Don Syme 已提交
75

B
Brett V. Forsgren 已提交
76
For Linux/Mac:
D
Don Syme 已提交
77

B
Brett V. Forsgren 已提交
78
    ./build.sh
D
Don Syme 已提交
79

B
Brett V. Forsgren 已提交
80
Running tests:
D
Don Syme 已提交
81

82
    ./build.sh --test
83 84
    
You can then open `FSharp.sln` in your editor of choice.
D
Don Syme 已提交
85

86
## Testing from the command line
D
Don Syme 已提交
87

88
You can find all test options as separate flags. For example `build -testAll`:
D
Don Syme 已提交
89

90
```
91 92 93 94 95 96 97 98 99 100
  -testAll                  Run all tests
  -testCambridge            Run Cambridge tests
  -testCompiler             Run FSharpCompiler unit tests
  -testCompilerService      Run FSharpCompilerService unit tests
  -testDesktop              Run tests against full .NET Framework
  -testCoreClr              Run tests against CoreCLR
  -testFSharpCore           Run FSharpCore unit tests
  -testFSharpQA             Run F# Cambridge tests
  -testScripting            Run Scripting tests
  -testVs                   Run F# editor unit tests
101
```
B
Brett V. Forsgren 已提交
102

103
Running any of the above will build the latest changes and run tests against them.
B
Brett V. Forsgren 已提交
104

105
## Updating FSComp.fs, FSComp.resx and XLF
D
Don Syme 已提交
106

107
If your changes involve modifying the list of language keywords in any way, (e.g. when implementing a new keyword), the XLF localization files need to be synced with the corresponding resx files. This can be done automatically by running
D
Don Syme 已提交
108

109 110 111
    pushd src\fsharp\FSharp.Compiler.Private
    msbuild FSharp.Compiler.Private.fsproj /t:UpdateXlf
    popd
D
Don Syme 已提交
112

113
This only works on Windows/.NETStandard framework, so changing this from any other platform requires editing and syncing all of the XLF files manually.
D
Don Syme 已提交
114

115
## Developing the F# tools for Visual Studio
D
Don Syme 已提交
116

117
As you would expect, doing this requires both Windows and Visual Studio are installed.
D
Don Syme 已提交
118

119
See (DEVGUIDE.md#Developing on Windows) for instructions to install what is needed; it's the same prerequisites.
D
Don Syme 已提交
120

121
### Quickly see your changes locally
D
Don Syme 已提交
122

123
First, ensure that `VisualFSharpFull` is the startup project.
B
Brett V. Forsgren 已提交
124

125
Then, use the **f5** or **ctrl+f5** keyboard shortcuts to test your tooling changes. The former will debug a new instance of Visual Studio. The latter will launch a new instance of Visual Studio, but with your changes installed.
B
Brett V. Forsgren 已提交
126

127
Alternatively, you can do this entirely via the command line if you prefer that:
128

129 130
    devenv.exe /rootsuffix RoslynDev

131
### Install your changes into a current Visual Studio installation
D
Don Syme 已提交
132

133
If you'd like to "run with your changes", you can produce a VSIX and install it into your current Visual Studio instance:
D
Don Syme 已提交
134

135 136 137 138
```
VSIXInstaller.exe /u:"VisualFSharp"
VSIXInstaller.exe artifacts\VSSetup\Release\VisualFSharpFull.vsix
```
D
Don Syme 已提交
139

J
jb 已提交
140
It's important to use `Release` if you want to see if your changes have had a noticeable performance impact.
D
Don Syme 已提交
141

142
### Performance and debugging
D
Don Syme 已提交
143

144
Use the `Debug` configuration to test your changes locally. It is the default. Do not use the `Release` configuration! Local development and testing of Visual Studio tooling is not designed for the `Release` configuration.
D
Don Syme 已提交
145

146
### Troubleshooting a failed build of the tools
D
Don Syme 已提交
147

148
You may run into an issue with a somewhat difficult or cryptic error message, like:
D
Don Syme 已提交
149

150
> error VSSDK1077: Unable to locate the extensions directory. "ExternalSettingsManager::GetScopePaths failed to initialize PkgDefManager for C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe".
D
Don Syme 已提交
151

152
Or hard crash on launch ("Unknown Error").
D
Don Syme 已提交
153

154
To fix this, delete these folders:
D
Don Syme 已提交
155

156 157
- `%localappdata%\Microsoft\VisualStudio\<version>_(some number here)RoslynDev`
- `%localappdata%\Microsoft\VisualStudio\<version>_(some number here)`
D
Don Syme 已提交
158

159
Where `<version>` corresponds to the latest Visual Studio version on your machine.
D
Don Syme 已提交
160

161
## Additional resources
D
Don Syme 已提交
162

163
The primary technical guide to the core compiler code is [The F# Compiler Technical Guide](https://fsharp.github.io/2015/09/29/fsharp-compiler-guide.html). Please read and contribute to that guide.
D
Don Syme 已提交
164

165
See the "Debugging The Compiler" section of this [article](https://medium.com/@willie.tetlow/f-mentorship-week-1-36f51d3812d4) for some examples.
D
Don Syme 已提交
166

167
## Addendum: configuring a proxy server
D
Don Syme 已提交
168 169 170

If you are behind a proxy server, NuGet client tool must be configured to use it:

171 172 173 174 175
```
.nuget\nuget.exe config -set http_proxy=proxy.domain.com:8080 -ConfigFile NuGet.Config
.nuget\nuget.exe config -set http_proxy.user=user_name -ConfigFile NuGet.Config
.nuget\nuget.exe config -set http_proxy.password=user_password -ConfigFile NuGet.Config
```
D
Don Syme 已提交
176
Where you should set proper proxy address, user name and password.