JasperFx / jasper

Next generation application development framework for .Net
http://jasperfx.github.io/
MIT License
417 stars 55 forks source link

System.IO.FileNotFoundException: Could not load file or assembly 'JasperFx.Core, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. #758

Closed nkosi23 closed 11 months ago

nkosi23 commented 11 months ago

When running a basic empty ASP.NET Core project in F# configured to use a library calling JasperFx under the hoods (Oakton, Wolverine, etc...) I get the following exception on application startup:

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'JasperFx.Core, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

File name: 'JasperFx.Core, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null'
   at Oakton.CommandFactory..ctor()
   at Oakton.CommandLineHostingExtensions.ApplyOaktonExtensions(IHostBuilder builder)

What is strange is that the dll is correctly copied to the output directory, however its metadata are a bit strange: namely the version is set to 0.0.0.0, here is what JetBrains Rider displays about the assembly referenced by the project

Name: JasperFx.Core
Full name: JasperFx.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Location: /home/username/.nuget/packages/jasperfx.core/1.5.1/lib/net7.0/JasperFx.Core.dll
Mvid: 0726d806-ac4a-4c0f-8c5e-398ba3a43e29
Platform: net7.0

Needless to say that this issue is quite blocking, running a project with something as basic as the below should reproduce the exception:


    let exitCode = 0
    let builder = WebApplication.CreateBuilder(args)
    builder.Host.ApplyOaktonExtensions()

    builder.Services.AddControllers()
    builder.Services.AddResourceSetupOnStartup()

   let app = builder.Build()

  app.RunOaktonCommands(args) |> Async.AwaitTask 

  exitCode

If I remove the lines regarding oakton and try to configure Wolverine using the UseWolverine method of the hostbuilder, this exception will be thrown at that point instead. I've seen people succefully boostrap JasperFx-based projects using F# like here so I'm a bit puzzled.

Everything works properly in the C# version but I am in the process of migrating all the projects to F#. Any idea or pointers? Cleaning/Rebuilding does not help unfortunately. The project targets .NET 7:

<PropertyGroup>
        <TargetFramework>net7.0</TargetFramework>
        <GenerateDocumentationFile>true</GenerateDocumentationFile>
        <OutputType>Exe</OutputType>
    </PropertyGroup>

 <ItemGroup>
        <PackageReference Include="FSharp.SystemTextJson" Version="1.2.42"/>
        <PackageReference Include="JasperFx.Core" Version="1.5.1"/>
        <PackageReference Include="MailKit" Version="4.2.0"/>
        <PackageReference Include="Marten" Version="6.4.0"/>
        <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0"/>
        <PackageReference Include="WolverineFx" Version="1.8.0"/>
        <PackageReference Include="WolverineFx.Http" Version="1.8.0"/>
    </ItemGroup>
nkosi23 commented 11 months ago

Closing in favor of this since it looks like it may be related to Wolverine and I'm really not sure this repo is the right place for posting issues.