当我右键单击文件夹Add-> View以添加Razor View时:
我收到以下错误:
No executable found matching the command dotnet-aspnet-codegenerator
从最初的在线搜索中,我找不到解决方案。我曾经在一些项目上工作 - 但无法弄清楚如何解决这个问题!我重新安装了VS2017,但问题仍然存在。
我怀疑这是项目中的内容。我尝试过阅读与代码生成相关的软件包,但问题仍然存在。
这是我的csproj包和工具参考:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<RuntimeIdentifier>win7-x86</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0" PrivateAssets="All" />
<PackageReference Include="SimpleInjector.Integration.AspNetCore.Mvc" Version="3.3.2" />
<PackageReference Include="Telerik.UI.for.AspNet.Core" Version="2017.1.223" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>
我使用右键单击Add-&gt; Controller添加Controllers
也有同样的问题,所以这不仅限于Razor Views。
这可以从上下文菜单Add-&gt; New Item ...-&gt; MVC View Page或Add-&gt; New Item ...-&gt; MVC Controller Class。
答案 0 :(得分:1)
Currenly我的目标是netcoreapp 1.1,它对我有用。在我粘贴你的csproj后,vs17自动想要安装WPF和桌面的东西,实际上非常糟糕。你能试试我的csproj它适合你吗?我正在调查也许我能找到一些东西:)
更新:向David Kean(https://twitter.com/davkean)发送推文的最简单方法。他会知道这个问题是什么,他们什么时候会修复它。
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Areas\A\Controllers\" />
</ItemGroup>
</Project>
答案 1 :(得分:1)
我今晚也有同样的事情发生了。
我在几乎空的ASP NET核心应用程序中添加了Razor View
。我被提示选择一个选项,为项目添加最小的依赖项或完全依赖项。
我选择了最小的依赖项,然后出现了ScaffoldingReadMe.txt。它写着:
ASP.NET MVC核心依赖项已添加到项目中。 但是,您可能仍需要对项目进行更改。
1. Add Scaffolding CLI tool to the project:
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
</ItemGroup>
我尝试通过脚手架添加视图,它像以前一样失败了。但是,接受文本文件所说的内容,将上述XML添加到csproj文件中 - 该视图已成功搭建。