Refit: Refit.Generator.Tasks.GenerateStubsTask" task could not be loaded from the assembly

Created on 17 Dec 2019  路  8Comments  路  Source: reactiveui/refit

Describe the bug

If there were different version refit on my machine, dotnet build will throw the error below:

...
error MSB4062: The "Refit.Generator.Tasks.GenerateStubsTask" task could not be loaded from the assembly 
/Users/Name/.nuget/packages/refit/5.0.23/buildTransitive/netstandard2.0/../../build/MSBuildCore20/InterfaceStubGenerator.BuildTasks.dll. 
Assembly with same name is already loaded Confirm that the <UsingTask> declaration is correct, 
that the assembly and all its dependencies are available, 
and that the task contains a public class that implements Microsoft.Build.Framework.ITask. 
[/Users/Name/Projects/Solution/src/Infrastructure/Roster.ServiceAgent/Roster.ServiceAgent.csproj]
...

Steps To Reproduce

It may be caused by dotnet cache, I have to restart my machine or restart all dotnet processes to avoid this error. However, if an other project with different version refit still throw the error.

Expected behavior

I want to know the reason of this error and fixed this bug will be more excited.

Screenshots

Environment

  • OS: MacOS
  • Device: MBP
  • Version: 10.15.1
  • Working Version: dotnetcore 3.1, 3.0, 2.2

Additional context

bug

All 8 comments

I am also seeing this issue occur on Centos 7 / dotnet 3.0.100 / refit 4.7.51. Restarting the machine resolves the issue temporarily

I have the same issue on a local hosted AzureDevOps Windows 2019 build server
VSVersion: VS2019 16.4.0

It works with Refit Version: 4.7.51 but doesn't work with version 5.0.23

Cleaning the build dir does not work

Thanks @klyse , downgrading from 5.0.23 to 4.7.51 fixed the reported issue for me too.

I think this relates to https://github.com/dotnet/roslyn/issues/22688
dotnet build /nodeReuse:false solved it for me

The same issue on my side on CI build server, downgrading and dotnet build /nodeReuse:false and restarting the machine does not help, any updates to this issue ?

I added <PackageReference> to the top-level project and it worked. Seems like refit won't work as a transitive reference.

Closing due to age. Please try Refit v6 and reopen if still an issue.

@clairernovotny I just tried with Refit 6 using the latest version of MSBUILD that installed alongside .NET 5.0 SDK VErsion: 5.0.103 and this was still an issue for me.

Edit: false alarm - this is actually working with Refit v6! Turns out I had a csproj with Refit 5.0.23 that I hadn't upgraded.

Was this page helpful?
0 / 5 - 0 ratings