Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on build - dependency to Microsoft.Bcl.AsyncInterfaces #233

Closed
folbrecht opened this issue Dec 7, 2023 · 15 comments · Fixed by #247
Closed

Error on build - dependency to Microsoft.Bcl.AsyncInterfaces #233

folbrecht opened this issue Dec 7, 2023 · 15 comments · Fixed by #247
Assignees
Labels
bug Something isn't working

Comments

@folbrecht
Copy link

REFITTER000 System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Systém nemůže nalézt uvedený soubor.

I tried to install package Microsoft.Bcl.AsyncInterfaces, but it did not help. VS 2022, MAUI app project.
Thanks for help

@folbrecht folbrecht added the bug Something isn't working label Dec 7, 2023
@christianhelle
Copy link
Owner

@folbrecht thanks for taking the time to report this.

I haven't tried using Refitter with a MAUI project, but I'll try that myself over the weekend and see if I can reproduce it, and even better, see what could be wrong...

As a workaround, have you tried using the Refitter CLI tool?

@christianhelle
Copy link
Owner

@all-contributors please add @folbrecht for bugs

Copy link
Contributor

@christianhelle

I've put up a pull request to add @folbrecht! 🎉

@christianhelle
Copy link
Owner

@folbrecht I could easily reproduce your problem, but I haven't figured out why this happens with MAUI projects.

One good thing is that Refit itself works fine with MAUI but the Refitter.SourceGenerator package reference is causing the problems.

As a workaround, you can remove the Refitter.SourceGenerator package reference and add the Refit package reference. Then you can keep the generated file as it is or re-generate it using the Refitter CLI tool

My schedule is a bit packed these days leading up to the holidays. I'll eventually, and hopefully, figure out what's wrong when working with MAUI, and work on a fix for the problem. Until then, I apologize for the inconvenience and the delays

@folbrecht
Copy link
Author

folbrecht commented Dec 13, 2023 via email

@manuel-fernandez-rodriguez

REFITTER000 System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Systém nemůže nalézt uvedený soubor.

I tried to install package Microsoft.Bcl.AsyncInterfaces, but it did not help. VS 2022, MAUI app project. Thanks for help

I have run into exactly the same problem on compiling, but it seems not be MAUI related (or, at least, not exclusively), because my project was a Web API and the build error occurred when building a class library, which was the project the nuget package was added to.

@christianhelle
Copy link
Owner

christianhelle commented Dec 13, 2023

REFITTER000 System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Systém nemůže nalézt uvedený soubor.
I tried to install package Microsoft.Bcl.AsyncInterfaces, but it did not help. VS 2022, MAUI app project. Thanks for help

I have run into exactly the same problem on compiling, but it seems not be MAUI related (or, at least, not exclusively), because my project was a Web API and the build error occurred when building a class library, which was the project the nuget package was added to.

@manuel-fernandez-rodriguez Interesting... I primarily use this myself on Web API (Minimal API) projects. What version of .NET do you target and what version of Refitter do you use?

I just put this little Minimal API project together to test it out:
MinimalApi.zip

I could build and run it without any issues

@manuel-fernandez-rodriguez

REFITTER000 System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Systém nemůže nalézt uvedený soubor.
I tried to install package Microsoft.Bcl.AsyncInterfaces, but it did not help. VS 2022, MAUI app project. Thanks for help

I have run into exactly the same problem on compiling, but it seems not be MAUI related (or, at least, not exclusively), because my project was a Web API and the build error occurred when building a class library, which was the project the nuget package was added to.

@manuel-fernandez-rodriguez Interesting... I primarily use this myself on Web API (Minimal API) projects. What version of .NET do you target and what version of Refitter do you use?

I just put this little Minimal API project together to test it out: MinimalApi.zip

I could build and run it without any issues

I have downloaded the zip, and the openapi definition for the PetStore was missing, so I downloaded it from https://petstore3.swagger.io/api/v3/openapi.json.

The Refit interface was successfully generated, but I get exactly the same error that we have been mentioning from the start:

Build started at 20:44...
1>------ Build started: Project: MinimalApi, Configuration: Debug Any CPU ------
1>CSC : error REFITTER000: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
1>Done building project "MinimalApi.csproj" -- FAILED.

Surprisingly, if I build it from the command line:

> dotnet build
MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
  MinimalApi -> C:\Users\mfernandezr\Downloads\MinimalApi\bin\Debug\net8.0\MinimalApi.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:08.75

So I have to presume the problem is not the code itself, but something related to Visual Studio or its interaction with the code generation.

My Visual Studio version is:

Microsoft Visual Studio Enterprise 2022 (64-bit) - Current
Version 17.8.3

And I have the following SDK and runtimes installed:

> dotnet --list-sdks && dotnet --list-runtimes

8.0.100 [C:\Program Files\dotnet\sdk]
Microsoft.AspNetCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]```

@christianhelle
Copy link
Owner

@manuel-fernandez-rodriguez Thanks for all the input! This will be very helpful.

My excuse for not running into this - I spend most of my day in JetBrains Rider and the CLI 😞

I'll see what I can do

@christianhelle
Copy link
Owner

@manuel-fernandez-rodriguez Good news is that I found the line of code that throws an exception. The bad news is that I don't understand why it does, and why it doesn't...

For now, I think I'll add a try/catch around the deserialization code in the source generator project and just jump out if anything unexpected happens

@christianhelle
Copy link
Owner

@all-contributors please add @manuel-fernandez-rodriguez for bugs

Copy link
Contributor

@christianhelle

I've put up a pull request to add @manuel-fernandez-rodriguez! 🎉

@christianhelle
Copy link
Owner

I released a preview version to NuGet

<PackageReference Include="Refitter.SourceGenerator" Version="0.8.6.38-preview" />

It works for me in my Visual Studio setup. Can you also try it on your machines @manuel-fernandez-rodriguez @folbrecht ?

@manuel-fernandez-rodriguez

@christianhelle
Checked and, apparently it works flawlessly when building :)

Thank you SO much for the quick workaround.

@christianhelle
Copy link
Owner

@folbrecht I tested the latest release preview on a new MAUI app and it seems to work fine.

I'm closing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants