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

D
Don Syme 已提交
3 4
Follow the instructions below to build and develop the F# Compiler, Core Library and tools on Windows, macOS and Linux.

D
Don Syme 已提交
5
* [Developing the F# Compiler (Windows)](#developing-the-f-compiler-windows)
D
Don Syme 已提交
6 7
* [Developing the F# Compiler (Linux)](#developing-the-f-compiler-linux)
* [Developing the F# Compiler (macOS)](#developing-the-f-compiler-macos)
D
Don Syme 已提交
8 9
* [Developing the Visual F# IDE Tools (Windows Only)](#developing-the-visual-f-ide-tools-windows-only) 
* [Notes and Resources](#notes)
D
Don Syme 已提交
10

D
Don Syme 已提交
11
###  Developing the F# Compiler (Windows)
12

D
Don Syme 已提交
13
Install
D
Don Syme 已提交
14

D
Don Syme 已提交
15 16
- [.NET 4.5.1](http://www.microsoft.com/en-us/download/details.aspx?id=40779)
- [MSBuild 12.0](http://www.microsoft.com/en-us/download/details.aspx?id=40760)
D
Don Syme 已提交
17 18

On Windows you can build the F# compiler for .NET Framework as follows:
D
Don Syme 已提交
19

D
Don Syme 已提交
20
    build.cmd
D
Don Syme 已提交
21

D
Don Syme 已提交
22 23 24 25
This is the same as

    build.cmd net40

D
Don Syme 已提交
26
There are various qualifiers:
D
Don Syme 已提交
27

D
Don Syme 已提交
28 29
    build.cmd release         -- build release (the default)
    build.cmd debug           -- build debug instead of release
D
Don Syme 已提交
30

D
Don Syme 已提交
31
    build.cmd net40           -- build .NET Framework compiler (the default)
D
Don Syme 已提交
32
    build.cmd coreclr         -- build .NET Core compiler 
D
Don Syme 已提交
33
    build.cmd vs              -- build the Visual F# IDE Tools (see below)
D
Don Syme 已提交
34 35
    build.cmd pcls            -- build the PCL FSharp.Core libraries
    build.cmd all             -- build all 
D
Don Syme 已提交
36

D
Don Syme 已提交
37
    build.cmd proto           -- force the rebuild of the Proto bootstrap compiler in addition to other things
38

D
Don Syme 已提交
39 40 41
    build.cmd test            -- build default targets, run suitable tests
    build.cmd net40 test      -- build net40, run suitable tests
    build.cmd coreclr test    -- build coreclr, run suitable tests
D
Don Syme 已提交
42
    build.cmd vs test         -- build Visual F# IDE Tools, run all tests (see below)
D
Don Syme 已提交
43
    build.cmd all test        -- build all, run all tests
D
Don Syme 已提交
44 45

    build.cmd test-smoke      -- build, run smoke tests
D
Don Syme 已提交
46 47
    build.cmd test-net40-fsharp     -- build, run tests\fsharp suite for .NET Framework
    build.cmd test-net40-fsharpqa   -- build, run tests\fsharpqa suite for .NET Framework
D
Don Syme 已提交
48 49 50

After you build the first time you can open and use this solution:

D
Don Syme 已提交
51
    .\FSharp.sln
D
Don Syme 已提交
52 53 54

or just build it directly:

D
Don Syme 已提交
55 56 57 58 59 60
    msbuild FSharp.sln 

Building ``FSharp.sln`` builds nearly everything. However building portable profiles of 
FSharp.Core.dll is not included.  If you are just developing the core compiler and library
then building the solution will be enough.

D
Don Syme 已提交
61
###  Developing the F# Compiler (Linux)
D
Don Syme 已提交
62

D
Don Syme 已提交
63
For Linux/Mono, follow [these instructions](http://www.mono-project.com/docs/getting-started/install/linux/). Also you may need:
D
Don Syme 已提交
64

D
Don Syme 已提交
65
    sudo apt-get install mono-complete autoconf libtool pkg-config make git automake
D
Don Syme 已提交
66

D
Don Syme 已提交
67 68 69 70 71
Then:
    
    ./autoconf.sh --prefix /usr
    make
    make install
D
Don Syme 已提交
72

D
Don Syme 已提交
73
Full testing is not yet enabled on Linux, nor is a .NET Core build of the compiler.
D
Don Syme 已提交
74

D
Don Syme 已提交
75
You can alternatively use
D
Don Syme 已提交
76

D
Don Syme 已提交
77
    ./build.sh
D
Don Syme 已提交
78

D
Don Syme 已提交
79
###  Developing the F# Compiler (macOS)
D
Don Syme 已提交
80

D
Don Syme 已提交
81
Install Xamarin Studio, then
D
Don Syme 已提交
82

D
Don Syme 已提交
83 84 85
    ./autogen.sh --prefix=/Library/Frameworks/Mono.framework/Versions/Current/
    make
    sudo make install
D
Don Syme 已提交
86

D
Don Syme 已提交
87
### Developing the Visual F# IDE Tools (Windows Only)
D
Don Syme 已提交
88

D
Don Syme 已提交
89
To build and test Visual F# IDE Tools, install these requirements:
D
Don Syme 已提交
90 91 92 93 94 95
- [Visual Studio 2017](https://www.visualstudio.com/downloads/)
  - Under the "Windows" workloads, select ".NET desktop development"
    - Select "F# language support" under the optional components
  - Under the "Other Toolsets" workloads, select "Visual Studio extension development"
  - Under the "Individual components" tab select "Windows 10 SDK" as shown below (needed for compiling RC resource, see #2556): \
  ![image](https://cloud.githubusercontent.com/assets/1249087/23730261/5c78c850-041b-11e7-9d9d-62766351fd0f.png)
I
Isaac Abraham 已提交
96
  - Failing to install this will lead to error FS0193: Could not find file visualfsharp\vsintegration\src\FSharp.ProjectSystem.FSharp\obj\net40\ProjectResources.rc.res.
D
Don Syme 已提交
97

D
Don Syme 已提交
98
Steps to build:
D
Don Syme 已提交
99

L
Lukas Rieger 已提交
100 101
    build.cmd vs              -- build the Visual F# IDE Tools in Release configuration (see below)
    build.cmd vs debug        -- build the Visual F# IDE Tools in Debug configuration (see below)
D
Don Syme 已提交
102 103 104
    build.cmd vs test         -- build Visual F# IDE Tools, run all tests (see below)

Use ``VisualFSharp.sln`` if you're building the Visual F# IDE Tools.
D
Don Syme 已提交
105

D
Don Syme 已提交
106

L
Lukas Rieger 已提交
107 108
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 https://github.com/Microsoft/visualfsharp/issues/2771 and https://github.com/Microsoft/visualfsharp/pull/2773.

109 110 111 112
Note: if you face this error [#2351](https://github.com/Microsoft/visualfsharp/issues/2351):

>  error VSSDK1077: Unable to locate the extensions directory. "ExternalSettingsManager::GetScopePaths failed to initialize PkgDefManager for C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe".

113
Or hard crash on launch ("Unknown Error"), delete these folders:
114

115
* `%localappdata%\Microsoft\VisualStudio\15.0_(some number here)RoslynDev`
116
* `%localappdata%\Microsoft\VisualStudio\15.0_(some number here)`
D
Don Syme 已提交
117

D
Don Syme 已提交
118
#### [Optional] Install the Visual F# IDE Tools  (Windows Only)
D
Don Syme 已提交
119

120
At time of writing, the Visual F# IDE Tools can only be installed into the latest Visual Studio 2017 RC releases.
D
Don Syme 已提交
121 122
The new builds of the Visual F# IDE Tools can no longer be installed into Visual Studio 2015.

123
You can install Visual Studio 2017 from https://www.visualstudio.com/downloads/.
D
Don Syme 已提交
124

D
Don Syme 已提交
125
**Note:** This step will install a VSIX extension into Visual Studio "Next" that changes the Visual F# IDE Tools 
D
Don Syme 已提交
126
components installed in that VS installation.  You can revert this step by disabling or uninstalling the addin.
D
Don Syme 已提交
127

D
Don Syme 已提交
128
For **Debug**, uninstall then reinstall:
D
Don Syme 已提交
129

D
Don Syme 已提交
130 131
    VSIXInstaller.exe /u:"VisualFSharp"
    VSIXInstaller.exe debug\net40\bin\VisualFSharpOpenSource.vsix
D
Don Syme 已提交
132

D
Don Syme 已提交
133
For **Release**, uninstall then reinstall:
D
Don Syme 已提交
134

D
Don Syme 已提交
135 136
    VSIXInstaller.exe /u:"VisualFSharp"
    VSIXInstaller.exe release\net40\bin\VisualFSharpOpenSource.vsix
D
Don Syme 已提交
137

B
Brett V. Forsgren 已提交
138 139
Restart Visual Studio, it should now be running your freshly-built Visual F# IDE Tools with updated F# Interactive.

D
Don Syme 已提交
140
#### [Optional] F5 testing of local changes
B
Brett V. Forsgren 已提交
141

142 143 144 145
To test your changes locally _without_ overwriting your default installed Visual F# tools, set the `VisualFSharp\Vsix\VisualFSharpOpenSource`
project as the startup project.  When you hit F5 a new instance of Visual Studio will be started in the `RoslynDev` hive with your
changes, but the root (default) hive will remain untouched. You can also start this hive automatically using

146 147
    devenv.exe /rootsuffix RoslynDev

148 149
Because this uses the "RoslynDev" hive you can simultaneously test changes to an appropriate build of Roslyn binaries.

D
Don Syme 已提交
150

D
Don Syme 已提交
151
#### [Optional] Rapid deployment of incremental changes to Visual F# IDE Tools components
D
Don Syme 已提交
152 153 154 155 156 157 158

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:

    xcopy /y debug\net40\bin\FSharp.* "%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\15.0_7c5620b7FSharpDev\Extensions\Microsoft.VisualFSharpTools\Visual F# Tools\15.4.1.9055"

This gives a much tighter inner development loop than uninstalling/reinstalling the VSIX, as you do not have to restart VIsual Studio. Caveat emptor.

D
Don Syme 已提交
159
#### [Optional] Clobber the F# SDK on the machine
D
Don Syme 已提交
160

161
**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 15 is currently the only way to revert this step.**
D
Don Syme 已提交
162 163 164

For **Debug**:

D
Don Syme 已提交
165
    vsintegration\update-vsintegration.cmd debug
D
Don Syme 已提交
166 167 168

For **Release**:

D
Don Syme 已提交
169
    vsintegration\update-vsintegration.cmd release
D
Don Syme 已提交
170 171


D
Don Syme 已提交
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
# Notes

#### Windows: Links to  Additional frameworks

- [Git for windows](http://msysgit.github.io/)
- [.NET 3.5](http://www.microsoft.com/en-us/download/details.aspx?id=21)
- [.NET 4.5](http://www.microsoft.com/en-us/download/details.aspx?id=30653)
- [.NET 4.5.1](http://www.microsoft.com/en-us/download/details.aspx?id=40779)
- [.NET 4.6](http://www.microsoft.com/en-us/download/details.aspx?id=48137)
- [MSBuild 12.0](http://www.microsoft.com/en-us/download/details.aspx?id=40760)
- [Windows 7 SDK](http://www.microsoft.com/en-us/download/details.aspx?id=8279)
- [Windows 8 SDK](http://msdn.microsoft.com/en-us/windows/desktop/hh852363.aspx)
- [Windows 8.1 SDK](http://msdn.microsoft.com/en-us/library/windows/desktop/bg162891.aspx)
- [Windows 10 SDK](https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk)


D
Don Syme 已提交
188
#### Notes on the Windows .NET Framework build
D
Don Syme 已提交
189 190 191 192 193 194 195 196 197 198

1. The `update.cmd` script adds required strong name validation skips, and NGens the compiler and libraries. This requires admin privileges.
1. The compiler binaries produced are "private" and strong-named signed with a test key.
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.
1. The overall bootstrapping process executes as follows
 - 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.
 - 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.
 - We use the proto compiler to compile the source for `FSharp.Core.dll` in this distribution.
 - We use the proto compiler to compile the source for `FSharp.Compiler.dll`, `fsc.exe`, `fsi.exe`, and other binaries found in this distribution.

D
Don Syme 已提交
199
#### Configuring proxy server
D
Don Syme 已提交
200 201 202 203 204 205 206 207 208

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

    .nuget\nuget.exe config -set http_proxy=proxy.domain.com:8080 -ConfigFile .nuget\NuGet.Config
    .nuget\nuget.exe config -set http_proxy.user=user_name -ConfigFile .nuget\NuGet.Config
    .nuget\nuget.exe config -set http_proxy.password=user_password -ConfigFile .nuget\NuGet.Config

Where you should set proper proxy address, user name and password.

D
Don Syme 已提交
209
#### Resources
D
Don Syme 已提交
210 211 212

The primary technical guide to the core compiler code is [The F# Compiler Technical Guide](http://fsharp.github.io/2015/09/29/fsharp-compiler-guide.html).  Please read and contribute to that guide.