FsXaml icon indicating copy to clipboard operation
FsXaml copied to clipboard

.NET Core 3 support request

Open dam5s opened this issue 6 years ago • 13 comments

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

dam5s avatar Aug 20 '19 19:08 dam5s

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.

ReedCopsey avatar Aug 20 '19 19:08 ReedCopsey

Awesome thanks!

dam5s avatar Aug 20 '19 19:08 dam5s

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.

miegir avatar Oct 27 '19 15:10 miegir

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

TheJayMann avatar Dec 27 '19 16:12 TheJayMann

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.

allykzam avatar Jan 09 '20 19:01 allykzam

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"

ReedCopsey avatar Jan 09 '20 20:01 ReedCopsey

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

allykzam avatar Jan 09 '20 21:01 allykzam

What's the current progress on this? @dam5s

Kavignon avatar Apr 08 '20 13:04 Kavignon

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 avatar May 07 '20 13:05 mattstermiller

@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.

BillHally avatar May 07 '20 21:05 BillHally

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.

mattstermiller avatar May 12 '20 03:05 mattstermiller

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.

MatthijsPrent avatar Jan 20 '23 13:01 MatthijsPrent

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>

xp44mm avatar Jan 28 '23 12:01 xp44mm