Skip to content

Fails opening project with "Could not load file or assembly NuGet.ProjectModel" #150

@fredericDelaporte

Description

@fredericDelaporte

I have removed VS 2017 and installed VS 2019 today, and now the async generation of NHIbernate fails with this error log (some parts, put between {}, have been translated to English by me):

     [exec] Generating async code started
     [exec] Opening project 'E:\Projets\nhibernate\nhibernate-core\src\NHibernate\NHibernate.csproj' started
     [exec] System.InvalidOperationException: One or more errors occurred while opening the project:
     [exec] MSBuild {has failed processing the file} 'E:\Projets\nhibernate\nhibernate-core\src\NHibernate\NHibernate.csproj' {with message} : C:\Program Files\dotnet\sdk\3.1.302\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets: (234, 5): The "ResolvePackageAssets" task
failed unexpectedly.
     [exec] System.IO.FileNotFoundException: Could not load file or assembly 'NuGet.ProjectModel, Version=5.6.0.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. {The specified file is not found.}
     [exec] File name: 'NuGet.ProjectModel, Version=5.6.0.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ---> System.IO.FileNotFoundException: Could not load the specified file.
     [exec] File name: 'NuGet.ProjectModel'
     [exec]    at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
     [exec]    at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
     [exec]    at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.CreateReaderFromMemory(ResolvePackageAssets task, Byte[] settingsHash)
     [exec]    at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader..ctor(ResolvePackageAssets task)
     [exec]    at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups()
     [exec]    at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore()
     [exec]    at Microsoft.NET.Build.Tasks.TaskBase.Execute()
     [exec]    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
     [exec]    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
     [exec]
     [exec]
     [exec] MSBuild {has failed processing the file} 'E:\Projets\nhibernate\nhibernate-core\src\NHibernate\NHibernate.csproj' {with message} : C:\Program Files\dotnet\sdk\3.1.302\Roslyn\Microsoft.CSharp.Core.targets: (59, 5): The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from
 the assembly C:\Program Files\dotnet\sdk\3.1.302\Roslyn\Microsoft.Build.Tasks.CodeAnalysis.dll. Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. {The specified file is not found.} 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.
     [exec] Hint: For suppressing irrelevant errors use SuppressDiagnosticFailures option.
     [exec]    at AsyncGenerator.AsyncCodeGenerator.CheckForErrors(MSBuildWorkspace workspace, String itemType, ImmutableArray`1 supressFailuresPredicates, ILogger logger)
     [exec]    at AsyncGenerator.AsyncCodeGenerator.OpenProject(MSBuildWorkspace workspace, String filePath, ImmutableArray`1 supressFailuresPredicates, ILogger logger, CancellationToken cancellationToken)
     [exec]    at AsyncGenerator.AsyncCodeGenerator.GenerateAsync(AsyncCodeConfiguration configuration, CancellationToken cancellationToken)
     [exec]    at AsyncGenerator.CommandLine.Program.Main(String[] args)

I have seen #146 about adding support for .Net Core 3.1. But I still have .Net Core 2.1 installed too. And attempting to remove 3.1 from the Visual Studio Installer asks for removing almost all of VS2019.

Is #146 required for being able to use the async generator when .Net Core 3.1 is installed? Or is there anything else to do to fix this trouble, like a way to instruct the generator to use the 2.1 SDK instead of 3.1?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions