35
votes

I tried to compile my new application in MonoDevelop and I got this error:

/usr/share/dotnet/sdk/2.2.203/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(5,5): Error MSB4018: The "GenerateDepsFile" task failed unexpectedly. System.TypeLoadException: Could not load type of field 'Microsoft.NET.Build.Tasks.DependencyContextBuilder:_filteredPackages' (12) due to: Could not resolve type with token 01000027 from typeref (expected class 'NuGet.Packaging.Core.PackageIdentity' in assembly 'NuGet.Packaging, Version=5.0.0.6, Culture=neutral, PublicKeyToken=31bf3856ad364e35') assembly:NuGet.Packaging, Version=5.0.0.6, Culture=neutral, PublicKeyToken=31bf3856ad364e35 type:NuGet.Packaging.Core.PackageIdentity member:(null) at Microsoft.NET.Build.Tasks.TaskBase.Execute () [0x00000] in :0 at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00029] in <58f0218f988743a48dd7c84cbe933f4e>:0 at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x001f6] in <58f0218f988743a48dd7c84cbe933f4e>:0 (MSB4018) (passcracker)

I cannot compile any application. Please help.

11

11 Answers

69
votes

I had the same problem using .Net Standard 2.1, and I solved it for myself by cleaning the solution and then rebuilding it.

15
votes

Just moved my projects to a new machine (copying, not pulling from GIT) and started getting this. Deleting the bin and obj folders in each project solved this issue.

4
votes

Your combination of Mono MSBuild and .NET Core SDK is incompatible because they use different versions of the internal NuGet library. To resolve this problem, you can:

  • Downgrade .NET Core SDK to 2.1.5xx or 2.2.1xx (for example, 2.1.505 or 2.2.108)
  • Upgrade Mono to 6.0

You can find a detailed explanation of this problem and possible solutions here: https://rider-support.jetbrains.com/hc/en-us/articles/360004180039

3
votes

This appears to be a known issue.

The only fix at this stage seems to be to downgrade to .NET Core v2.2.105.

To downgrade:

0
votes

Change the name of the file. For instance, Add prefix _ or #; so, it cannot be used.

Restart Visual Studio, then try to build. If still problem is there, needs to restart the machine.

0
votes

I had this error happen and the slove for me was correcting the Package version number in .csproj file .

   <Version>2.0.7.</Version> <!--casued the error-->

   <Version>2.0.7</Version> <!--this fixed the error-->

Removing the trailing '.' fixed this for me.

0
votes

I had .net standard project built on .net standard 2.0. Yesterday I updated my Visual Studio 2019 to 16.3.0 to leverage .Net Core 3.0. But all of sudden build of project targeting on standard 2.0 started throwing "GenerateDepsFile" task failed unexpectedly error.

I was able to resolve this issue by changing the target framework to 2.1.

0
votes

If you have <DelaySign>false</DelaySign> in your .csproj file remove it to solve this Problem.

0
votes

in vs code i got this error, after trying some solution from forms, i found solution in deleting bin and obj foldersfrom project and build again. this solved my problem. vs code version: 1.53.1 dotnet version : 5

0
votes

Run the following CMD in the *.sln folder. This will delete all your OBJ and BIN folders automatically. And your issue will be solved.

FOR /d /r . %%d in (bin,obj) DO ( IF EXIST "%%d" ( ECHO %%d | FIND /I "\node_modules\" > Nul && ( ECHO.Skipping: %%d ) || ( ECHO.Deleting: %%d rd /s/q "%%d" )))
0
votes

I had it after updating vs 2019 community, Delete bin & obj folders, then clean & build the solution.