Contributing
January 9, 2023 ยท View on GitHub
WebSharper is a Free Software project, and we welcome your contributions!
The UI repository contains the WebSharper.UI reactive programming and HTML 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!
What to contribute?
We welcome all types of contributions, particularly:
- Bug fixes in the issue tracker
- Library improvements
- Feature suggestions are welcome on the Gitter chat 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.
How to contribute
Required software
It is possible to work on WebSharper on Windows, Linux and OSX.
To compile this project, you need the following installed:
- The .NET SDK 6.0.10 or newer. You can download it here.
Setting up your development environment
We recommend that you use one of the following development environments:
- On Windows: Visual Studio 2022.
- On all platforms: Visual Studio Code with the following extensions:
ionide-fsharpfor F# supportms-vscode.csharpfor C# support
Configure WebSharper packages
There are two options:
- WebSharper GitHub packages feed
- Locally built WebSharper packages
Configure GitHub packages feed
To get non-public builds of WebSharper, you need to access GitHub packages which requires a Personal Access Token (PAT).
Create a new token ensuring it has the read:packages scope like this.
You can test your PAT by accessing https://nuget.pkg.github.com/dotnet-websharper/index.json and providing your github user name and the PAT as the password.
Then to configure Paket source authentication, run:
dotnet tool restoredotnet paket config add-credentials https://nuget.pkg.github.com/dotnet-websharper/index.json --username <ghUser> --password <PAT>(use your GitHub user name and PAT)
To add WebSharper GitHub packages as a nuget source to browse from Visual Studio, run:
dotnet nuget add source https://nuget.pkg.github.com/dotnet-websharper/index.json --name dotnet-websharper-GitHub --username <ghUser> --password <PAT>
Use locally built WebSharper packages
- Clone
coreanduirepos under the same root, also create a third sub-directory calledlocalnuget. - Build WebSharper with
build ws-packagethen copy allbuild/*.nupkgfiles tolocalnuget. - Run
build ws-updatein theuifolder. Now it is using your local WebSharper build.
Building from the command line
This project can be built using the script build.cmd on Windows, or build.sh on Linux andr OSX.
In the following shell snippets, a command line starting with build means .\build.cmd on Windows and ./build.sh on Linux and OSX.
Simply running build compiles the UI libraries and tests in debug mode. The following targets are available:
-
build ws-builddebugEquivalent to simple
build: compiles the libraries and tests in debug mode. -
build ws-buildreleaseCompiles the libraries and tests in release mode.
-
build ws-packageCompiles the 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.
Running the tests
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:

This repository contains several test projects, detailed in the project structure. They are ASP.NET applications hosting WebSharper applications; some of them are Client-Server applications, others are SPAs. Here is how to run them:
-
If you are using Visual Studio, you can simply open
WebSharper.UI.sln, set the test project you want as the startup project, and Run. -
On Linux or OSX, you can browse into the project's folder and simply run
xsp.
Project structure
Here is the detail of the project structure:
- Libraries:
WebSharper.UIcontains the core library for both reactive programming and DOM management.WebSharper.UI.CSharpcontains the C#-friendly API forWebSharper.UI.WebSharper.UI.Templating.Commoncontains the code for HTML templating that is needed both during compilation and during server-side runtime.WebSharper.UI.Templating.Runtimecontains the server-side and client-side runtime for the HTML templating.WebSharper.UI.Templatingcontains the F# type provider for HTML templating.WebSharper.UI.CSharp.Templatingcontains the C# code generator for HTML templating.WebSharper.UI.CSharp.Templating.Analyzercontains the Roslyn analyzer that invokes the code generator on file save in Visual Studio.WebSharper.UI.CSharp.Templating.Buildcontains the MSBuild task that invokes the code generator pre-compilation.
- Tests:
WebSharper.UI.Testscontains all the F# tests that do not rely on HTML templating.WebSharper.UI.Templating.Testscontains the F# client-side HTML templating tests.WebSharper.UI.Templating.ServerSide.Testscontains the F# server-side HTML templating tests.WebSharper.UI.Routing.Testscontains the F# router tests.WebSharper.UI.CSharp.Testscontains all the C# tests.