Wednesday, November 08, 2023

F# and OpenSilver v2.0 (Continued)

An update to the previous series of posts.

Building while NuGetting

While I stand by my assertion that the previous post showed the simplest way to build (by not using NuGet to get the package, but referencing the key assembly the old-fashioned way) here is how to build with OpenSilver 2.0.1 as a NuGet reference. First, add properties

    <SkipXamlPreprocessor>true</SkipXamlPreprocessor>
    <OpenSilverGenerateAssemblyInfo>false</OpenSilverGenerateAssemblyInfo>

then if there isn't already a $(ProjectName).OpenSilver.XamlDesigner.fs file in the root of the project (generated there by the OpenSilver compiler taking some untested path before it was switched off), it should look like this:

// <auto-generated>
//     Generated by the FSharp WriteCodeFragment class.
// </auto-generated>
namespace FSharp

open System
open System.Reflection


[<assembly: System.Runtime.CompilerServices.InternalsVisibleTo("XamlDesignerBackground")>]
do()

added with Compile Action of None, and then see it's copied into the appropriate place by

  <Target Name="FixUp" BeforeTargets="BeforeCompile;CoreCompile">
    <ItemGroup>
        <MisgeneratedFiles Include="$(ProjectName).AssemblyInfo.OpenSilver.XamlDesigner.fs"/>
    </ItemGroup>
    
    <Copy SourceFiles="@(MisgeneratedFiles)"
          DestinationFolder="$(IntermediateOutputPath)"
        />
  </Target>

Publishing less

In the browser project, rather than enabling AOT, which saves time, and not space, have properties

    <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
    <BlazorEnableCompression>false</BlazorEnableCompression>
    <!-- Uncomment to enable AOT compilation when publishing -->
    <!--<RunAOTCompilation>true</RunAOTCompilation>-->

and it doesn't hurt to switch of satellites in the Presentation project, either.

That takes us from

to

No comments :