使用VS2017在ASP.NET Core 1.1中添加脚手架控制器时出错 [英] Error adding scaffolded controller in asp.net core 1.1 using VS2017

查看:75
本文介绍了使用VS2017在ASP.NET Core 1.1中添加脚手架控制器时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在全新的ASP.net核心Web应用程序(版本1.1)上使用VS2017,当我尝试添加使用实体框架进行操作的api控制器"时,出现以下错误消息:

I'm using VS2017 on a brand new ASP.net core web application (version 1.1) and when I try to add 'api controller with actions using entity framework' I get the following error message:

运行所选代码生成器时发生错误:'Version for包'Microsoft.VisualStudio.Web.CodeGeneration.Tools'不能为解决."

There was an error running the selected code generator: 'Version for package 'Microsoft.VisualStudio.Web.CodeGeneration.Tools' could not be resolved.'

我在Google上进行了一些搜索,发现了一些建议,其中之一是在.csproj文件中添加CLI工具引用,因此我添加了以下内容:

I've googled a bit and found a few suggestions, one of which was to add a CLI tool reference in the .csproj file, so I have added the following:

<ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" 
         Version="1.0.1" />
</ItemGroup>

根据NuGet软件包管理器,此版本与已安装的版本匹配.但是问题仍然存在.请问如何解决此问题的任何建议?

This version matched the installed version according to the NuGet package manager. However the problem still persists. Any suggestions on how to fix this please?

推荐答案

几个小时的猛烈抨击后,我偶然发现了这篇文章:

After a few hours of headbanging, I stumbled across this post: System could not be found Visual Studio 2017 ASP.NET Core project

我按照建议启用了自动检查丢失的包裹的方法,终于成功了!

I followed the advice to enable automatic check for missing packages and it finally worked!

我遇到了同样的问题,首先是将VS2015净核心mvc Web项目转换为2017,然后是在2017年尝试创建新的核心Web应用程序时.

I had the same problem, first when converting a VS2015 net core mvc web project to 2017 and then when trying to create a new core web application in 2017.

进入工具| NuGet软件包管理器|软件包管理器设置-选中允许NuGet下载丢失的软件包"和在VS构建过程中自动检查丢失的软件包",然后单击清除所有NuGet缓存".然后重新构建解决方案-找到并加载了所有必需的软件包,然后运行OK.

Went to Tools|NuGet Package Manager|Package Manager Settings - checked 'Allow NuGet to download missing packages' and 'Automatically check for missing packages during build in VS' and then clicked 'Clear All NuGet Cache(s)'. Then re-built the solution - it found and loaded all the required packages and ran OK.

可能无法在所有情况下都起作用,但简单却值得尝试.

May not work for all cases but simple and worth a try.

这篇关于使用VS2017在ASP.NET Core 1.1中添加脚手架控制器时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆