It brings .NET Standard/Core 2.0 support, templates for
dotnet new, and compiler options configurable by a
Documentation pages has been updated for 4.2:
- Install VS or dotnet templates
- Project templates overview
- Configure WebSharper compilation via wsconfig.json
The release notes are also found on GitHub.
.NET Standard and .NET Core support
This is the first version of WebSharper compiled for .NET Standard 2.0, and therefore compatible with .NET Core 2.0.
The compiler itself still runs on .NET Framework, due to the F# compiler's current limitations in particular when dealing with type providers. So having .NET 4.6.1 or Mono installed on development machine is still required; however the runtime is 100% .NET Standard 2.0 compatible.
ASP.NET Core support
WebSharper can now run on top of ASP.NET Core thanks to WebSharper.AspNetCore. The server-side runtime, including Sitelets as well as RPC functions, can be run on top of ASP.NET Core.
C# and F#
dotnet project templates
Templates for .NET Core are now available for both C# and F#. They can be installed with the following command:
dotnet new -i WebSharper.Templates
There are four templates for each language (add
-lang c# or
-lang f# to choose, default is C#):
dotnet new websharper-webcreates an ASP.NET Core application with a WebSharper client-server site.
dotnet new websharper-spacreates an ASP.NET Core application containing a WebSharper Single-Page Application.
dotnet new websharper-htmlcreates a WebSharper-generated static HTML website.
By default, the project is named based on current folder. Add the
-n ProjectName flag to override this.
dotnet run after creating a web, SPA or Html template to immediately see it compile and run. Web and SPA uses Kestrel, while Html opens up an Explorer window for the output folder.
Build configuration via
wsconfig.json file is found next to a WebSharper project, build settings are read from it, overriding project variable setting if one exists in both places. Existing project variables all have equivalents: these are
"Project": WebSharper project type (see documentation).
"OutputDir": Output directory for web, SPA and Html projects.
"DCE": dead code elimination on/off (shortened from
"SourceMap": source map generation on/off.
"WarnOnly": give WebSharper errors only as warnings (shortened from
"DownloadResources": download all remote js/css resources for web projects.
"AnalyzeClosures": give warnings on unintended captures in JS closures.
"MinJSOutput": write out
.min.jsto given file paths.
In parallel to the new .NET Standard 2.0, the minimum requirement for running WebSharper on the .NET Framework has been bumped to v4.6.1.