fsprojects / FsXaml

F# Tools for working with XAML Projects
http://fsprojects.github.io/FsXaml/
MIT License
171 stars 48 forks source link

.NET Core 3 support request #80

Open dam5s opened 4 years ago

dam5s commented 4 years ago

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

ReedCopsey commented 4 years ago

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 4 years ago

Awesome thanks!

miegir commented 4 years ago

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.

TheJayMann commented 4 years ago

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

allykzam commented 4 years ago

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.

ReedCopsey commented 4 years ago

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"

allykzam commented 4 years ago

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

Kavignon commented 4 years ago

What's the current progress on this? @dam5s

mattstermiller commented 4 years ago

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:

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

BillHally commented 4 years ago

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

mattstermiller commented 4 years ago

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.

MatthijsPrent commented 1 year ago

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.

xp44mm commented 1 year ago

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>