Skip to content

Commit d7cee80

Browse files
author
dotnet-automerge-bot
authored
Merge pull request #7094 from dotnet/merges/master-to-release/dev16.3
Merge master to release/dev16.3
2 parents 787d4c5 + 4d724f2 commit d7cee80

1 file changed

Lines changed: 93 additions & 130 deletions

File tree

DEVGUIDE.md

Lines changed: 93 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,72 @@
11
# Development Guide
22

3-
## Get the Latest F# Compiler Source Code
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.
44

5-
Get the latest source code from the master branch by running this git command:
5+
## Recommended workflow
66

7-
git clone https://github.com/dotnet/fsharp.git
7+
We recommend the following overall workflow when developing for this repository:
88

9-
Before running the build scripts, ensure that you have cleaned up the visualfsharp repo by running this git command:
9+
* Fork this repository
10+
* Always work in your fork
11+
* Always keep your fork up to date
1012

11-
git clean -xfd
13+
This will make management of multiple forks and your own work easier over time.
1214

13-
This will remove any files that are not under version control. This is necessary only if you have already attempted to build the solution or have made other changes that might prevent it from building.
15+
## Updating your fork
1416

15-
## Installing Dependencies and Building
17+
We recommend the following commands to update your fork:
1618

17-
Follow the instructions below to build and develop the F# Compiler, Core Library and tools on Windows, macOS and Linux.
19+
```
20+
git checkout master
21+
git clean -xdf
22+
git fetch upstream
23+
git rebase upstream/master
24+
git push
25+
```
1826

19-
- [Developing the F# Compiler (Windows)](#developing-the-f-compiler-windows)
20-
- [Developing the F# Compiler (Linux/macOS)](#developing-the-f-compiler-linuxmacos)
21-
- [Developing the Visual F# IDE Tools (Windows Only)](#developing-the-visual-f-ide-tools-windows-only)
22-
- [Notes and Resources](#notes)
27+
Or more succinctly:
2328

24-
### Developing the F# Compiler (Windows)
29+
```
30+
git checkout master && git clean -xdf && git fetch upstream && git rebase upstream/master && git push
31+
```
2532

26-
Install
33+
This will update your fork with the latest from `dotnet/fsharp` on your machine and push those updates to your remote fork.
2734

28-
- [.NET Framework 4.7.2](https://dotnet.microsoft.com/download/dotnet-framework/net472)
29-
- [.NET Core 3 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.0)
35+
## Developing on Windows
3036

31-
**NOTE on Windows:**
37+
Install the latest released [Visual Studio](https://www.visualstudio.com/downloads/), as that is what the `master` branch's tools are synced with. Select the following workloads:
3238

33-
1. It is recommended to run `build.cmd` in a command prompt with path set to have the location of MSBuild. If you have Visual Studio, we can run using `Developer Command Prompt for Visual Studio 20xx` (depends on Visual Studio version). This developer command prompt is easier to use than normal command prompt, because it already has the correct path of Visual Studio and .NET's tooling set for us to use (including MSBuild).
39+
* .NET desktop development (also check F# desktop support, as this will install some legacy templates)
40+
* Visual Studio extension development
3441

35-
2. The command prompt must have Administrator rights (`Run as Administrator`).
42+
Building is simple:
3643

37-
On Windows you can build the F# compiler and tools as follows:
38-
39-
Build.cmd
44+
build.cmd
4045

4146
Desktop tests can be run with:
4247

43-
Build.cmd -test
48+
build.cmd -test
4449

45-
Additional options are available via:
50+
After you build the first time you can open and use this solution in Visual Studio:
4651

47-
Build.cmd /?
52+
.\VisualFSharp.sln
53+
54+
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.
4855

49-
After you build the first time you can open and use this solution:
56+
## Developing on Windows - No Visual Studio
5057

51-
.\VisualFSharp.sln
58+
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:
5259

53-
If you are just developing the core compiler and library then building ``FSharp.sln`` will be enough.
60+
* [.NET Framework 4.7.2](https://dotnet.microsoft.com/download/dotnet-framework/net472)
61+
* [.NET Core 3 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.0)
5462

55-
If you do not have Visual Studio installed and want to simply build the compiler as a .NET Core application, use this:
63+
You'll need to pass an additional flag to the build script:
5664

57-
Build.cmd -noVisualStudio
65+
build.cmd -noVisualStudio
66+
67+
You can open `FSharp.sln` in your editor of choice.
5868

59-
### Developing the F# Compiler (Linux/macOS)
69+
## Developing on Linux or macOS
6070

6171
For Linux/Mac:
6272

@@ -65,140 +75,93 @@ For Linux/Mac:
6575
Running tests:
6676

6777
./build.sh --test
78+
79+
You can then open `FSharp.sln` in your editor of choice.
6880

69-
### Developing the Visual F# IDE Tools (Windows Only)
70-
71-
To build and test Visual F# IDE Tools, install these requirements:
72-
73-
- Download [Visual Studio 2019](https://www.visualstudio.com/downloads/)
74-
- Launch the Visual Studio Installer
75-
- Under the **"Windows"** workload, select **".NET desktop development"**
76-
- Select the optional component **"F# desktop language support"**
77-
- Under the **"Other Toolsets"** workload, select **"Visual Studio extension development"**
81+
## Testing from the command line
7882

79-
Steps to build:
83+
You can find all test options as separate flags. For example:
8084

81-
Build.cmd -- build all F# components under the default configuration (Debug)
82-
Build.cmd -configuration Release -- build all F# components as Release
83-
Build.cmd -testDesktop -- build and test all net472 tests
85+
```
86+
build -testDesktop -- test all net472 target frameworks
87+
build -testCoreClr -- test all netstandard and netcoreapp target frameworks
88+
build -testFSharpQA -- test all F# Cambridge tests
89+
build -testVs -- test all VS integration points
90+
build -testFcs -- test F# compiler service components
91+
build -testAll -- all of the above
92+
```
8493

85-
All test options:
94+
Running any of the above will build the latest changes and run tests against them.
8695

87-
-testDesktop -- test all net472 target frameworks
88-
-testCoreClr -- test all netstandard and netcoreapp target frameworks
89-
-testFSharpQA -- test all F# Cambridge tests
90-
-testVs -- test all VS integration points
91-
-testFcs -- test F# compiler service components
92-
-testAll -- all of the above
96+
## Updating FSComp.fs, FSComp.resx and XLF
9397

94-
Use ``VisualFSharp.sln`` if you're building the Visual F# IDE Tools.
95-
96-
Note on Debug vs Release: ``Release`` Configuration has a degraded debugging experience, so if you want to test a change locally, it is recommended to do it in the ``Debug`` configuration. For more information see issues [#2771](https://github.com/Microsoft/visualfsharp/issues/2771) and [#2773](https://github.com/Microsoft/visualfsharp/pull/2773).
97-
98-
Note ([#2351](https://github.com/Microsoft/visualfsharp/issues/2351)): if you face this error:
99-
100-
> 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".
101-
102-
Or hard crash on launch ("Unknown Error"), delete these folders:
103-
104-
- `%localappdata%\Microsoft\VisualStudio\16.0_(some number here)RoslynDev`
105-
- `%localappdata%\Microsoft\VisualStudio\16.0_(some number here)`
106-
107-
#### [Optional] Install the Visual F# IDE Tools (Windows Only)
108-
109-
The new builds of the Visual F# IDE Tools can no longer be installed into Visual Studio 2015.
98+
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
11099

111-
You can install Visual Studio 2019 from <https://www.visualstudio.com/downloads/>.
100+
pushd src\fsharp\FSharp.Compiler.Private
101+
msbuild FSharp.Compiler.Private.fsproj /t:UpdateXlf
102+
popd
112103

113-
**Note:** This step will install a VSIX extension into Visual Studio "Next" that changes the Visual F# IDE Tools
114-
components installed in that VS installation. You can revert this step by disabling or uninstalling the addin.
104+
This only works on Windows/.NETStandard framework, so changing this from any other platform requires editing and syncing all of the XLF files manually.
115105

116-
For **Debug**, uninstall then reinstall:
106+
## Developing the F# tools for Visual Studio
117107

118-
VSIXInstaller.exe /u:"VisualFSharp"
119-
VSIXInstaller.exe artifacts\VSSetup\Debug\VisualFSharpFull.vsix
108+
As you would expect, doing this requires both Windows and Visual Studio are installed.
120109

121-
For **Release**, uninstall then reinstall:
110+
See (DEVGUIDE.md#Developing on Windows) for instructions to install what is needed; it's the same prerequisites.
122111

123-
VSIXInstaller.exe /u:"VisualFSharp"
124-
VSIXInstaller.exe artifacts\VSSetup\Release\VisualFSharpFull.vsix
112+
### Quickly see your changes locally
125113

126-
Restart Visual Studio, it should now be running your freshly-built Visual F# IDE Tools with updated F# Interactive.
114+
First, ensure that `VisualFSharpFull` is the startup project.
127115

128-
#### [Optional] F5 testing of local changes
116+
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.
129117

130-
To test your changes locally _without_ overwriting your default installed Visual F# tools, set the `VisualFSharp\Vsix\VisualFSharpFull`
131-
project as the startup project. When you hit F5 a new instance of Visual Studio will be started in the `RoslynDev` hive with your
132-
changes, but the root (default) hive will remain untouched. You can also start this hive automatically using
118+
Alternatively, you can do this entirely via the command line if you prefer that:
133119

134120
devenv.exe /rootsuffix RoslynDev
135121

136-
Because this uses the "RoslynDev" hive you can simultaneously test changes to an appropriate build of Roslyn binaries.
137-
138-
#### [Optional] Rapid deployment of incremental changes to Visual F# IDE Tools components
139-
140-
For the brave, you can rapidly deploy incrementally updated versions of Visual F# IDE Tool components such as ``FSharp.Editor.dll`` by copying them directly into the extension directory in your user AppData folder:
141-
142-
xcopy /y debug\net40\bin\FSharp.* "%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\16.0_7c5620b7FSharpDev\Extensions\Microsoft.VisualFSharpTools\Visual F# Tools\16.4.1.9055"
122+
### Install your changes into a current Visual Studio installation
143123

144-
This gives a much tighter inner development loop than uninstalling/reinstalling the VSIX, as you do not have to restart VIsual Studio. Caveat emptor.
124+
If you'd like to "run with your changes", you can produce a VSIX and install it into your current Visual Studio instance:
145125

146-
#### [Optional] Clobber the F# SDK on the machine
126+
```
127+
VSIXInstaller.exe /u:"VisualFSharp"
128+
VSIXInstaller.exe artifacts\VSSetup\Release\VisualFSharpFull.vsix
129+
```
147130

148-
**Note:** The step below will try to clobber the machine-wide installed F# SDK on your machine. This replaces the ``fsc.exe`` used by the standard install location or ``Microsoft.FSharp.Targets``. **Repairing Visual Studio 16 is currently the only way to revert this step.**
131+
It's important to use `Release` if you want to see if your changes have had a noticable performance impact.
149132

150-
For **Debug**:
133+
### Performance and debugging
151134

152-
vsintegration\update-vsintegration.cmd debug
135+
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.
153136

154-
For **Release**:
137+
### Troubleshooting a failed build of the tools
155138

156-
vsintegration\update-vsintegration.cmd release
139+
You may run into an issue with a somewhat difficult or cryptic error message, like:
157140

158-
## Debugging the F# Compiler
159-
160-
See the "Debugging The Compiler" section of this [article](https://medium.com/@willie.tetlow/f-mentorship-week-1-36f51d3812d4)
161-
162-
## Notes
163-
164-
### Windows: Links to Additional frameworks
141+
> 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".
165142
166-
- [Git for windows](https://gitforwindows.org/)
167-
- [.NET 4.6](https://www.microsoft.com/en-us/download/details.aspx?id=48137)
168-
- [Windows 8.1 SDK](https://msdn.microsoft.com/en-us/library/windows/desktop/bg162891.aspx)
169-
- [Windows 10 SDK](https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk)
143+
Or hard crash on launch ("Unknown Error").
170144

171-
### Notes on the Windows .NET Framework build
145+
To fix this, delete these folders:
172146

173-
1. The `update.cmd` script adds required strong name validation skips and NGens the compiler and libraries. This requires admin privileges.
174-
1. The compiler binaries produced are "private" and strong-named signed with a test key.
175-
1. Some additional tools are required to build the compiler, notably `fslex.exe`, `fsyacc.exe`, `FSharp.PowerPack.Build.Tasks.dll`, `FsSrGen.exe`, `FSharp.SRGen.Build.Tasks.dll`, and the other tools found in the `lkg` directory.
176-
1. The overall bootstrapping process executes as follows
177-
- We first need an existing F# compiler. We use the one in the `lkg` directory. Let's assume this compiler has an `FSharp.Core.dll` with version X.
178-
- We use this compiler to compile the source in this distribution, to produce a "proto" compiler, dropped to the `proto` directory. When run, this compiler still relies on `FSharp.Core.dll` with version X.
179-
- We use the proto compiler to compile the source for `FSharp.Core.dll` in this distribution.
180-
- We use the proto compiler to compile the source for `FSharp.Compiler.dll`, `fsc.exe`, `fsi.exe`, and other binaries found in this distribution.
147+
- `%localappdata%\Microsoft\VisualStudio\<version>_(some number here)RoslynDev`
148+
- `%localappdata%\Microsoft\VisualStudio\<version>_(some number here)`
181149

182-
### Updating FSComp.fs, FSComp.resx and XLF
150+
Where `<version>` corresponds to the latest Visual Studio version on your machine.
183151

184-
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
152+
## Additional resources
185153

186-
pushd src\fsharp\FSharp.Compiler.Private
187-
msbuild FSharp.Compiler.Private.fsproj /t:UpdateXlf
188-
popd
154+
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.
189155

190-
This only works on Windows/.NETStandard framework, so changing this from any other platform requires editing and syncing all of the XLF files manually.
156+
See the "Debugging The Compiler" section of this [article](https://medium.com/@willie.tetlow/f-mentorship-week-1-36f51d3812d4) for some examples.
191157

192-
### Configuring proxy server
158+
## Addendum: configuring a proxy server
193159

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

196-
.nuget\nuget.exe config -set http_proxy=proxy.domain.com:8080 -ConfigFile NuGet.Config
197-
.nuget\nuget.exe config -set http_proxy.user=user_name -ConfigFile NuGet.Config
198-
.nuget\nuget.exe config -set http_proxy.password=user_password -ConfigFile NuGet.Config
199-
162+
```
163+
.nuget\nuget.exe config -set http_proxy=proxy.domain.com:8080 -ConfigFile NuGet.Config
164+
.nuget\nuget.exe config -set http_proxy.user=user_name -ConfigFile NuGet.Config
165+
.nuget\nuget.exe config -set http_proxy.password=user_password -ConfigFile NuGet.Config
166+
```
200167
Where you should set proper proxy address, user name and password.
201-
202-
### Resources
203-
204-
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.

0 commit comments

Comments
 (0)