F# and OpenSilver v1.0
An update to the previous series of posts following the first stable release of OpenSilver.
While the details of which lines of code in the Browser and Simulator projects
need to be redirected at the F# types have changed since the earlier posts at
alpha-7 release, the principle remains the same -- where the generated code
refers to the C#/XAML App
type, replace that with the derived F#
type. The F# (logic) and C# (just the XAML, reified as abstract base types)
are set up exactly as before.
If you're porting an old solution, from a pre-release OpenSilver, unless you've been staying on the bleeding edge, it's simpler to start by creating a new one, copying the F# project and the XAML project from old to overwrite the new, and otherwise starting from scratch, remembering to check in all the as-generated files before making the edits.
At this point, provided that all the repointing to the F# project and types is done correctly, it should all "just work".
There is one gotcha, though, that has appeared in the updates for publishing
the Browser WASM since my alpha-7 exploration, in that some potentially very
long file paths can now be invoked that point deep under the project's default
obj
subfolder. If your project is already down a few layers from
the drive root it will run foul of the Copy
MSBuild task which
appears to still labour under the old DOS MAX_PATH
of 255
characters. Copying to an overlong path fails by timing out, so breaking the
build. In that case add
<IntermediateOutputPath>shorter file path here</IntermediateOutputPath> <BaseIntermediateOutputPath>$(IntermediateOutputPath)</BaseIntermediateOutputPath>
where a suitable up-tree location is specified e.g. starting at the top of the repo, or in a shallow build output directory outside the repo, rather than as a child of a project directory. Note that both values need to be set and aligned, lest defaults be assumed during the process.