mono / monodevelop

MonoDevelop is a cross platform .NET IDE
http://www.monodevelop.com
2.85k stars 1.02k forks source link

"ResolvePackageAssets" Task Failed Unexpectedly Error While Building #9645

Open poggersplayzyt opened 4 years ago

poggersplayzyt commented 4 years ago

I cannot Build/Run my project because I keep running into this error

/usr/share/dotnet/sdk/3.1.401/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(5,5): Error MSB4018: The "ResolvePackageAssets" task failed unexpectedly.
System.MissingFieldException: Field not found: string NuGet.ProjectModel.LockFileItem.AliasesProperty Due to: Could not find field in class
  at Microsoft.NET.Build.Tasks.ResolvePackageAssets+CacheWriter.WriteItems[T] (NuGet.ProjectModel.LockFileTarget target, System.Func`2[T,TResult] getAssets, System.Func`2[T,TResult] filter, System.Action`2[T1,T2] writeMetadata) [0x000bd] in <e2105f8d2d53417f87c9f890d4ef82d8>:0 
  at Microsoft.NET.Build.Tasks.ResolvePackageAssets+CacheWriter.WriteCompileTimeAssemblies () [0x00000] in <e2105f8d2d53417f87c9f890d4ef82d8>:0 
  at Microsoft.NET.Build.Tasks.ResolvePackageAssets+CacheWriter.WriteItemGroup (System.Action writeItems) [0x0000e] in <e2105f8d2d53417f87c9f890d4ef82d8>:0 
  at Microsoft.NET.Build.Tasks.ResolvePackageAssets+CacheWriter.WriteItemGroups () [0x00024] in <e2105f8d2d53417f87c9f890d4ef82d8>:0 
  at Microsoft.NET.Build.Tasks.ResolvePackageAssets+CacheWriter.Write () [0x00006] in <e2105f8d2d53417f87c9f890d4ef82d8>:0 
  at Microsoft.NET.Build.Tasks.ResolvePackageAssets+CacheWriter.WriteToCacheFile () [0x00040] in <e2105f8d2d53417f87c9f890d4ef82d8>:0 
  at Microsoft.NET.Build.Tasks.ResolvePackageAssets+CacheReader.CreateReaderFromDisk (Microsoft.NET.Build.Tasks.ResolvePackageAssets task, System.Byte[] settingsHash) [0x00049] in <e2105f8d2d53417f87c9f890d4ef82d8>:0 
  at Microsoft.NET.Build.Tasks.ResolvePackageAssets+CacheReader..ctor (Microsoft.NET.Build.Tasks.ResolvePackageAssets task) [0x00015] in <e2105f8d2d53417f87c9f890d4ef82d8>:0 
  at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups () [0x00000] in <e2105f8d2d53417f87c9f890d4ef82d8>:0 
  at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore () [0x00018] in <e2105f8d2d53417f87c9f890d4ef82d8>:0 
  at Microsoft.NET.Build.Tasks.TaskBase.Execute () [0x0002e] in <e2105f8d2d53417f87c9f890d4ef82d8>:0 
  at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in /build/msbuild-16.6+xamarinxplat.2020.04.29.14.43/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:575 
  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) [0x002a9] in /build/msbuild-16.6+xamarinxplat.2020.04.29.14.43/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:818  (MSB4018) (IronBrew2)

Dotnet Version 3.1.401 [/usr/share/dotnet/sdk]

Mono Version Mono JIT compiler version 6.10.0.104 (tarball Fri Jun 26 19:40:42 UTC 2020)

I am on Debian 10

mrward commented 4 years ago

Unfortunately this is a mismatch between the NuGet dlls that ship with MSBuild in Mono and those in the .NET Core SDK. If you update to Mono 6.13 I believe this will work - https://github.com/mono/mono

NuGet 5.7 (which is used by the .NET Core SDK 3.1.401) introduced a breaking change. Mono 6.10 and 6.12 still ship an older NuGet 5.6 version with MSBuild which is not compatible.

In VS Mac we worked around this by copying the NuGet.Build.Tasks.dll version 5.7 to the MonoDevelop MSBuilder directory.

poggersplayzyt commented 4 years ago

Where can I find Mono 6.13? I tried to find where I can get Mono 6.13 but I could not find it.

mrward commented 4 years ago

There are CI builds available from GitHub https://github.com/mono/mono - the main branch is Mono 6.13 currently.

poggersplayzyt commented 4 years ago

The builds dont show up for me. I also tried to do sudo cp /usr/lib/mono/msbuild/Current/bin/NuGet.Build.Tasks.dll /usr/lib/monodevelop/bin/MSBuild than tried to build again but to no avail. (I had the same error)

mrward commented 4 years ago

Copying the NuGet.Build.Tasks.dll to the monodevelop/bin/MSBuild directory will not do anything. MonoDevelop does not copy files from that location to the folder where it runs the MSBuild host.

steveeri commented 4 years ago

I recieved the same error after trying to import and use xUnit packages from nuget. I'm running elementary based on Ubuntu 20.04 on a macbook. When I load the same project into macos using visual studio rather than monodevelop under linux it loads OK. Obviously I want to use linux and monodevelop rather than vs. I'm pulling monodevelop using the ppa package download instructions, so would be awesome if this fix could be updates in vs-focal version so I could update my installation in linux.

lindexi commented 4 years ago

See https://lastexitcode.com/blog/2020/08/15/NuGetSupportInVisualStudioMac8-7/

See https://github.com/microsoft/reverse-proxy/issues/266

macoslinux commented 3 years ago

In my case i solved it just now @poggersplayzyt, I have ubuntu 20.04.2, $ mono --version Mono JIT compiler version 6.12.0.122 (tarball Mon Feb 22 17:33:28 UTC 2021) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com, $ dotnet --version 3.1.407

just is to make this:

to every project solucion go to -> project -> $yourProjectnameSolucionOption (show project option windows) -> on: Build -> custom command -> select: Build and add this to: Command: dotnet build Working directory: ${ProjectDir}

add other: select: Clean and add this to: Command: dotnet clean Working directory: ${ProjectDir} in the same custom Commands

click ok, if you have more projects in that solution you have to do the same. example:

image

now yow can press F8 (Build all) and enjoy it!