Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I install Microsoft.VisualStudio.Web.CodeGeneration.Tools 2.0.1 via nuget? Asp.NET CORE 2.0.1

Tags:

asp.net

I have added the reference to my project.csproj file as indicated on S.O. and in the ms docs tutorial:

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

running dotnet restore claims to succeed. But the dotnet aspnet-codegenerator command can't be found and in the manage nuget packages, the CodeGeneration.Tools isn't installed and manually installing gives the error: Package restore failed. Rolling back package changes for 'ContosoUniversity'.


This appears to be from a version compatibility issue that I don't understand or know how to fix. I have installed in my dependencies Microsoft.NETCore.App 2.0.3 and Microsoft.NETCore.APP 2.0.3 and everything else is 2.0.1. (CodeGeneration.Design, CodeGeneration.Utils etc... and running at Package Management Console Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Tools Throws the error:

 GET https://api.nuget.org/v3/registration3-gz-semver2/microsoft.visualstudio.web.codegeneration.tools/index.json
  OK https://api.nuget.org/v3/registration3-gz-semver2/microsoft.visualstudio.web.codegeneration.tools/index.json 166ms
Restoring packages for C:\Users\sticker592\Documents\Visual Studio 2017\Projects\ContosoUniversity\ContosoUniversity\ContosoUniversity.csproj...
Install-Package : Detected package downgrade: Microsoft.NETCore.App from 2.0.3 to 2.0.0. Reference the package directly from the project to 
select a different version. 
 ContosoUniversity -> Microsoft.VisualStudio.Web.CodeGeneration.Tools 2.0.1 -> Microsoft.NETCore.App (>= 2.0.3) 
 ContosoUniversity -> Microsoft.NETCore.App (>= 2.0.0)
At line:1 char:1
+ Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Tools
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
 
Install-Package : Package restore failed. Rolling back package changes for 'ContosoUniversity'.
At line:1 char:1
+ Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Tools
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Downgrading everything to 2.0.0 allows me to install CodeGeneration.Tools in Nuget but I still get the error: dotnet : No executable found matching command "dotnet-aspnet-codegenerator"

like image 960
user5389726598465 Avatar asked Dec 12 '17 04:12

user5389726598465


Video Answer


1 Answers

Go to "Manage Nuget Package for solution" in Nuget Package Manager and

In Package Source  image description here.

Add below detail: Name "nuget.org"

source "https://api.nuget.org/v3/index.json"

like image 108
Kipl_Aneji Avatar answered Dec 09 '22 17:12

Kipl_Aneji