WebSharper is a Free Software project, and we welcome your contributions!
The core repository contains the F# and C#-to-JavaScript compiler and core libraries. WebSharper consists of this repository as well as a constellation of libraries and extensions, located in the dotnet-websharper GitHub organization. Don't hesitate to contribute to these too!
We welcome all types of contributions, particularly:
- Bug fixes in the issue tracker
- Standard library improvements (JavaScript APIs, etc.)
- Compiler optimizations and improvements
- Documentation: improvements to the documentation website can be contributed in the "docs" repository
- Feature suggestions are welcome on Discord and the issue tracker; we suggest that you discuss new features with the rest of the team on these channels before getting started on implementation.
It is possible to work on WebSharper on Windows, Linux, and macOS.
To compile WebSharper, you need the following installed:
- .NET SDK 9.0 (or newer in the 9.x band). You can download it here.
WebSharper can be built using the script build.cmd on Windows, or build.sh on Linux and macOS.
In the following shell snippets, a command line starting with build means .\build.cmd on Windows and ./build.sh on Linux/macOS.
Simply running build compiles the WebSharper compiler, standard libraries and tests in Debug mode. The following targets are available:
-
build ws-builddebugEquivalent to simple
build: compiles the compiler, standard libraries and tests in debug mode. -
build ws-buildreleaseCompiles the compiler, standard libraries and tests in release mode.
-
build ws-packageCompiles the compiler, standard libraries and tests in release mode, then creates NuGet packages in the
buildfolder. -
build ws-cleanDeletes temporary and output directories.
-
build ci-releaseFull build as is used for releases. Update non-fixed dependencies, build everything, run unit tests, package.
The following options are available:
-
build [TARGET] -ef verboseMakes compilation more verbose. Equivalently, set the
verboseenvironment variable totrue.
We recommend that you use one of the following development environments:
- On Windows: Visual Studio 2022.
- On all platforms: Visual Studio Code with:
ms-dotnettools.csharp(C# for VS Code)ms-dotnettools.csdevkit(C# Dev Kit)ionide-fsharp(F# support)
WebSharper defines and uses its own test framework, WebSharper.Testing. It runs on the client side and is backed by QUnit. So running the WebSharper test suite consists in running a web application which looks like this:
The recommended way to run these tests is to run the tests/Web project. It is an ASP.NET Core application hosting the test suite, under the "Client-side test suite" on its home page.
- If you are using Visual Studio, you can simply open
WebSharper.sln, settests/Webas the startup project, and Run. Check your build target. Update the build target according to your build flags. Target Debug only if you used ws-builddebug. - From the command line (Linux/macOS/Windows):
cd tests/Web dotnet run
Then open the app in the browser and choose Client-side test suite.
To find where to add tests for your code, check the project structure below.
If you’re on Linux (e.g., Ubuntu 24.04) or Windows using WSL2, here’s a minimal setup:
# 1) Install .NET 9 SDK (Ubuntu 24.04)
sudo add-apt-repository ppa:dotnet/backports -y
sudo apt-get update && sudo apt-get install -y dotnet-sdk-9.0
# 2) Install Node via nvm (LTS recommended)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
# restart your shell
nvm install --lts
# 3) Install Google Chrome (for browser tests)
sudo apt update && sudo apt upgrade -y
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install -y ./google-chrome-stable_current_amd64.deb
google-chrome --version
# 4) Verify toolchain
dotnet --version
node --version
npm --version
# 5) Build (debug first)
chmod +x build.sh
./build.sh ws-builddebug
# 6) Run the web test
cd tests/Web
dotnet runDid you encounter a WebSharper bug while working on your project, and want to implement a fix and try it locally? The easiest way is to create NuGet packages for WebSharper and use them locally.
-
In websharper, write your code fix and run
build ws-package. -
In your project, add WebSharper's build folder as a NuGet source repository and update the packages:
-
If you're using Paket (for example if you're working on one of WebSharper's libraries and extensions):
-
Add the following line to your
paket.dependencies:source /path/to/websharper-repo/build -
Run
paket update.
-
-
If you're using the standard NuGet package manager:
-
Add the following to
NuGet.configin your project repository:<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="local-websharper" value="/path/to/websharper-repo/build" /> </packageSources> </configuration>
-
Update the NuGet packages either from Visual Studio's GUI, or with the command line:
dotnet add package WebSharper dotnet add package WebSharper.FSharp # if you're using F# dotnet add package WebSharper.CSharp # if you're using C#
-
-
Here is the detail of the project structure. The repository contains multiple solutions:
-
WebSharper.Compiler.slncontains the F# and C#-to-JavaScript compilers, the MSBuild tasks for the F# and C# compilers, and their dependencies. Undersrc/compiler/:WebSharper.Core.JavaScriptcontains facilities for parsing and writing plain JavaScript.WebSharper.Corecontains most everything that is common between the compilers, user libraries and runtime: attributes and core type definitions, JSON serialization, macro API, etc.WebSharper.InterfaceGeneratorcontains the type definitions for the Interface Generator.WebSharper.Compilercontains the compiler code common between the F# and C# compilers.WebSharper.Compiler.CSharpcontains the C# compiler as a library.WebSharper.CSharpcontains the C# compiler executable.WebSharper.Compiler.FSharpcontains the F# compiler as a library.WebSharper.FSharpcontains the F# compiler executable.WebSharper.FSharp.Servicecontains F# service utilities (parsing/typing hooks, etc.).WebSharper.MSBuild.FSharpcontains the MSBuild task/targets that integrate the F# compiler.WebSharper.MSBuild.CSharpcontains the MSBuild task that invokes the C# compiler after csc.WebSharper.CSharp.Analyzercontains the Roslyn analyzer, which provides the code service for C#.
-
WebSharper.slncontains the standard libraries, tests, and their dependencies.-
Under
src/stdlib/:WebSharper.JavaScriptcontains the type definitions for the JavaScript standard libraries: ECMAScript types, DOM, HTML5 APIs, etc.WebSharper.StdLibcontains the main WebSharper client-side libraries, such as theJSmodule,OptionalandUniontypes, remoting client-side types, etc. Note: standard library proxies are included in this assembly.WebSharper.Testingcontains the WebSharper client-side unit testing framework.
-
Under
src/sitelets/:WebSharper.Webcontains the server-side remoting runtime as well as some client-side HTML types.WebSharper.Siteletscontains the Sitelets API and runtime.WebSharper.Sitelets.Offlinecontains the machinery for static HTML project compilation.WebSharper.AspNetCorecontains ASP.NET Core integration.
-
Under
tests/:WebSharper.Core.JavaScript.Testscontains tests for JavaScript parsing and writing.WebSharper.Testscontains tests forstdlib/WebSharper.StdLib(including proxies).WebSharper.Html5.Testscontains tests for HTML5 bindings instdlib/WebSharper.JavaScript.WebSharper.Collections.Testscontains tests for collection proxies.WebSharper.InterfaceGenerator.Testscontains a test interface generator. This interface is then validated inWebSharper.Tests.WebSharper.Web.Testscontains remoting, client-side routing and JSON tests.WebSharper.CSharp.Testscontains C#-specific tests.WebSharper.Sitelets.Testscontains F# server-side tests.WebSharper.CSharp.Sitelets.Testscontains C# server-side tests.WebSharper.SPA.Testsis a single-page application serving a harness for all the above client-side tests.WebSharper.StaticHtml.Testsis a static HTML application serving a harness for all the above client-side tests.Websitedefines a sitelet that includes all the above server-side, client-side and cross-tier tests.Webis a client-server application serving the sitelet defined inWebsite. Therefore it is a harness for the whole test suite.WebSharper.InterfaceGenerator.Tests.LatestFSharpcontains tests for the Interface Generator targeting the latest F# features.WebSharper.CSharp.Interop.Testscontains tests for C# interoperability scenarios.WebSharper.CSharp.StaticHtml.Testscontains a static HTML test harness specific to C# components.WebSharper.CSharp.Analyzer.Testscontains tests for the C# Roslyn analyzer.WebSharper.Module.Testscontains tests for module-related behaviors.WebSharper.Compiler.FSharp.Testscontains integration tests for the F# compiler component.WebSharper.Library.Testscontains library-level infrastructure tests.Web.FSharpcontains an F#-specific test harness.Web.TypeScriptcontains tests related to TypeScript interop or code-generation functionality.ProxyProjectTestandProxyProjectTest.Proxycontain tests for proxy project generation.Web.Giraffecontains integration tests for WebSharper with the Giraffe framework.StressTestingcontains performance and stress test scenarios.WebSharper.StaticHtml.Tests.NetStandardcontains a .NET Standard variant of the static HTML test harness.
-
-
WebSharper.Tools.slncontains developer tools and metadata inspection.- Under the
src/compiler/:WebSharper.DllBrowsercontains a Windows-only GUI tool to inspect WebSharper metadata in assemblies; the UI is minimal (no menus/Open dialog) and you load assemblies by drag-and-dropping them onto the tree view, similar to ILSpy.WebSharper.TypeScriptParsercontains a Node.js-style project (.njsproj) that provides TypeScript parsing capabilities for WebSharper tools.
- Under the
