Visual Studio 2017发布asp.net核心 [英] visual studio 2017 publish asp.net core
问题描述
我有Visual Studio 2017 Enterprise 15.3.2,以及用dotnet core 1.1制作的相当老的项目.
I have Visual Studio 2017 Enterprise 15.3.2 and rather old project made in dotnet core 1.1.
如果我使用"dotnet publish ...."在控制台中发布我的项目,则效果很好.
If I publish my project in console using 'dotnet publish ....' It works perfectly.
但是当我使用Visual Studio时,我可以毫无问题地还原,生成,运行我的项目.当我尝试使用项目中的发布.."上下文菜单进行发布时,只有一个问题.我只是将项目发布到文件夹中.
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()
需要帮助.
推荐答案
另一种方法是:
只需从您的Core 2.0项目中删除/重命名global.json文件:).
Simply delete/rename global.json file from your Core 2.0 project :) .
这篇关于Visual Studio 2017发布asp.net核心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!