VS2017 ASP.NET Core error while adding Razor view

When I right-click on the Add-> View folder to add a Razor View:

Add browse dialog

I get the following error:

No executable found matching the command dotnet-aspnet-codegenerator

Error

Of the first searches on the Internet, I did not find a solution. I worked on some projects, but I can’t figure out how to solve this! I reinstalled VS2017, but the problem still exists.

I suspect this is something in the project. I tried reading packages related to code generation, but the problem remains.

Here are my csproj Package and Tool links:

<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>

I have the same problem adding Controllersusing the right mouse button Add-> Controller, so this is not limited to Razor Views.

This works from the context menu Add-> New item ...-> MVC view page or Add-> New item ...-> MVC controller class.

+4
2

.

Razor View ASP NET Core. .

, 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 - .

0

Currenly netcoreapp 1.1, . , , csproj vs17 WPF , . csproj, ? , , -:)

: (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

Source: https://habr.com/ru/post/1674359/


All Articles