fsprojects/FsXaml

.NET Core 3 support request

dam5s opened this issue · 13 comments

dam5s commented

Description

I would like to use FsXaml with .NET Core 3
.NET Core 3 brings support for WPF, but it doesn't seem to work with FsXaml

Repro steps

Please provide the steps required to reproduce the problem

Using the latest preview for .NET Core 3 -

  1. Create a new dotnet core 3.0 application with WPF support -

project.fsproj

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

    <PropertyGroup>
        <OutputType>WinExe</OutputType>
        <TargetFramework>netcoreapp3.0</TargetFramework>
        <RootNamespace>MyNamespace</RootNamespace>
        <UseWPF>true</UseWPF>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Elmish.WPF" Version="3.1.0"/>
        <PackageReference Include="FsXaml.Wpg" Version="3.1.6"/>
    </ItemGroup>
</Project>
  1. Add a XAML file to the project.

  2. Build the project.

Expected behavior

Project builds and I can start using the Type provider for the XAML file in my code.

Actual behavior

Build outputs an error as follows

C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(243,9): error MC1000: Unknown build error, 'Object reference not set to an instance of an object.'  [C:\Users\dam5s\workspace\epub-desktop\epub-desktop\epub-desktop.fsproj]  

Known workarounds

None that I know of. I'm using a C# project with my XAML files instead.

Related information

  • Windows 10 Pro
  • Latest stable version
  • 3.0.100-preview8-013656

The plan was to update this after .net core 3 RTM is released. I'm open to a PR in a branch in the meantime, however.

dam5s commented

Awesome thanks!

By the way, this error message is the MS XAML compiler bug. It is going to throw error that F# is not supported, but on the way to do so this error occurs.

looking at the network for this project, I found this branch which appears to add .NET Core 3 support. The branch is listed as testing, so I don't know how complete it is. Assuming it isn't yet complete, it appears to at least be a good starting point.

https://github.com/amazingant/FsXaml/tree/net-core-3-testing

Came here looking for something else and noticed @TheJayMann had linked my test branch. It's been ages since I touched that branch, so I'm not sure how well I had it working -- but I did have a separate repository that successfully runs a ported .NET Framework 4.5 application.

@ReedCopsey: I can pass along my working code if you want to dig around at it, but due to typical corporate restrictions, I'm not able to share my changes in a PR.

I'd definitely be curious to see what you did - though I'm happy to poke around your repo, as well. Right now, I don't have the bandwidth to do this port (even though I do want to make it happen at some point), but am hoping I can work on it "soonish"

Stripped out all of my compiled binaries and left out the sample application I mentioned (internal application from work), and put what was left here: https://github.com/amazingant/FsXamlAgain

What's the current progress on this? @dam5s

I took the project files and other changes from @amazingant 's repo that he linked above, applied them in a branch on my fork, and worked with it to get as far as I could.

Here is the progress I was able to make:

  • The core projects of this library, FsXaml.Wpf and FsXaml.Wpf.TypeProvider, have the new sdk project file format and target both netcoreapp3.0 and net45. They build and pass tests.
  • The FsXaml.Wpf.Blend project has the new sdk project file format but only targets net45 since its dependency System.Windows.Interactivity.WPF is only compatible with .NET framework. It was last updated in 2013.
  • 3 of the demo projects build with Visual Studio 2019 and run. 1 more builds but crashes on startup with a XamlParseException. The other 2 fail to build with "The provided method is marked as an abstract method; therefore, it should not define an implementation" and "Cannot inherit a sealed type" errors. I don't know how to fix these since the TypeProviders SDK seems to have changed quite a bit since the last release of FsXaml and I don't know if there were fundamental design changes regarding generating sealed vs. abstract types.

I need guidance on how to fix the demo apps or possibly the library to get this working.

Also, I noticed that the FAKE build script is very out-of-date. I was unable to use it and resorted to using paket, the dotnet SDK, and VS (and for building the demo projects, manually copying the library DLLs to the bin folder).

@mattstermiller You need to replace the use of System.Windows.Interactivity with Microsoft.Xaml.Behaviors.Wpf.

See https://devblogs.microsoft.com/dotnet/open-sourcing-xaml-behaviors-for-wpf for details.

Thank you, @BillHally! That resolves the issue with upgrading the Blend project and now I've got all 3 library projects targeting netcoreapp3.0 and net45.

I still need help with the demo projects.

Hallo,

Is there any progress on this, or any plan to finish the upgrade to .Net Core? We would like to upgrade our project to .Net Core, but FsXaml seems to be a blockage at this moment.

request to support latest version, the fsproj file like this:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net7.0-windows</TargetFramework>
    <UseWPF>true</UseWPF>
    <UseWindowsForms>False</UseWindowsForms>
  </PropertyGroup>

  <ItemGroup>
    <Resource Include="FirstMetroWindow.xaml" />
    <Resource Include="App.xaml" />
    <Compile Include="FirstMetroWindow.fs" />
    <Compile Include="App.fs" />
  </ItemGroup>


  <ItemGroup>
    <PackageReference Include="FsXaml.Wpf" Version="3.1.6" />
    <PackageReference Include="MahApps.Metro" Version="2.4.9" />
    <PackageReference Include="System.Reactive" Version="5.0.0" />
  </ItemGroup>

</Project>