1

I have Visual Studio 2017 Enterprise 15.3.2 and rather old project made in dotnet core 1.1.

If I publish my project in console using 'dotnet publish ....' It works perfectly.

But when I use Visual Studio, I can restore, build, run my project absolutely without problems. Only an issue I have when I try to publish using 'Publish..' context menu in the project. I publish the project simply into the folder.

Once I make publishing I have suddenly a error and cannot assembly a project. Here is a error I have:

System.InvalidCastException: [A]NuGet.ProjectModel.LockFile cannot be cast to [B]NuGet.ProjectModel.LockFile. Type A originates from 'NuGet.ProjectModel, Version=4.3.0.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'LoadFrom' at location 'C:\Program Files\dotnet\sdk\2.0.0\Sdks\Microsoft.NET.Sdk\tools\net46\NuGet.ProjectModel.dll'. Type B originates from 'NuGet.ProjectModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'LoadFrom' at location 'C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\tools\net46\NuGet.ProjectModel.dll'.


  at Microsoft.NET.Build.Tasks.LockFileCache.GetLockFile(String path)
   at Microsoft.NET.Build.Tasks.GenerateRuntimeConfigurationFiles.ExecuteCore()
   at Microsoft.NET.Build.Tasks.TaskBase.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

Help needed.

2 Answers 2

3

Another way is:

Simply delete/rename global.json file from your Core 2.0 project :) .

Sign up to request clarification or add additional context in comments.

1 Comment

global.json is deprecated, that was part of older dotnet core tooling, it is dead and should be deleted along with .xproj files
1

I found a solution. In global.json change sdk version for:

"sdk": { "version": "2.0.0" },

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.