Why can't I install Microsoft.VisualStudio.Web.CodeGeneration.Tools 2.0.1 via nuget? Asp.NET CORE 2.0.1 - 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"

Go to "Manage Nuget Package for solution" in Nuget Package Manager and
In Package Source
.
Add below detail:
Name
"nuget.org"
source
"https://api.nuget.org/v3/index.json"

If this happens, the solution to the error is to run the command at the dos command prompt in the project folder directory instead of in Package manager console. Then you can scaffold your pages without the error until MS fixes this bug.
Proof:
C:\Users\username\Documents\Visual Studio 2017\Projects\ContosoUniversity\ContosoUniversity>dotnet aspnet-codegenerator razorpage -m Student -dc SchoolContext -udl -outDir Pages\Students --referenceScriptLibraries
Building project ...
Finding the generator 'razorpage'...
Running the generator 'razorpage'...
Attempting to compile the application in memory.
Attempting to figure out the EntityFramework metadata for the model and DbContext: 'Student'
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using 'C:\Users\username\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
info: Microsoft.EntityFrameworkCore.Infrastructure[100403]
Entity Framework Core 2.0.0-rtm-26452 initialized 'SchoolContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
Added Razor Page : \Pages\Students\Create.cshtml
Added PageModel : \Pages\Students\Create.cshtml.cs
Added Razor Page : \Pages\Students\Edit.cshtml
Added PageModel : \Pages\Students\Edit.cshtml.cs
Added Razor Page : \Pages\Students\Details.cshtml
Added PageModel : \Pages\Students\Details.cshtml.cs
Added Razor Page : \Pages\Students\Delete.cshtml
Added PageModel : \Pages\Students\Delete.cshtml.cs
Added Razor Page : \Pages\Students\Index.cshtml
Added PageModel : \Pages\Students\Index.cshtml.cs
RunTime 00:00:15.33

Related

Missing definition for UseSqlite in DbContextOptionsBuilder class of Microsoft.EntityFrameworkCore.Tool

I'm trying to write a simple phone app using UWP that will insert an image from a Windows folder location into a table on SQLite and view it on the Windows phone.
I found this article on technet forum that I am using for a reference:
https://social.technet.microsoft.com/wiki/contents/articles/37975.save-and-load-images-in-universal-windows-app-with-sqlite-and-entity-framework-core.aspx
While following the instructions, I ran into an issue in installing the package Microsoft.EntityFrameworkCore.Tools (latest stable ver.2.0.1):
PM> Install-Package Microsoft.EntityFrameworkCore.Tools
GET https://api.nuget.org/v3/registration3-gz/microsoft.entityframeworkcore.tools/index.json
OK https://api.nuget.org/v3/registration3-gz/microsoft.entityframeworkcore.tools/index.json 74ms
Restoring packages for c:\users\intui\documents\visual studio 2017\Projects\PicturesApp\PicturesApp\PicturesApp.csproj...
Install-Package : Package Microsoft.EntityFrameworkCore.Tools 2.0.1 is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586). Package
Microsoft.EntityFrameworkCore.Tools 2.0.1 supports: netstandard2.0 (.NETStandard,Version=v2.0)
At line:1 char:2
+ Install-Package Microsoft.EntityFrameworkCore.Tools
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Same issue also occured with the previous version (2.0.0), but the next previous version (1.1.4) was installed successfully.
However, I found that the "DbContextOptionsBuilder" class used in the code "PictureAppContext" class does not recognize the method "UseSqlite":
Severity Code Description Project File Line Suppression State Error CS1061 'DbContextOptionsBuilder' does not contain a definition for 'UseSqlite' and no extension method 'UseSqlite' accepting a first argument of type "DbContextOptionsBuilder' could be found (are you missing a using directive or an assembly reference?) PicturesApp c:\users\intui\documents\visual studio 2017\Projects\PicturesApp\PicturesApp\PictureAppContext.cs 16 Active
Anyone knows how resolve this issue?
Thanks!
I ran into this same issue using dotnet sdk 2.1.1 which was supposed to have all basic dependencies wrapped in Microsoft.AspnetCore.App. All i needed to do was run dotnet add package Microsoft.EntityFrameworkCore.Sqlite in a terminal window in the project directory (The directory that contains the Program.cs, Startup.cs, and
.csproj files)
For .NET 5, I had to install the package Microsoft.EntityFrameworkCore.Sqlite.Core
Check the link
I solved the issue by uninstalling the Nuget package Microsoft Entity Framework Core and installing Entity.Framework.Core.Sqlite.Design. I don't know why it solved the issue but the error is gone, I'm happy and that's all that matters.
I added using Microsoft.EntityFrameworkCore; as suggested in the GitHub issue (https://github.com/dotnet/AspNetCore.Docs/issues/7486#issuecomment-403117359)

Cannot install Hangfire to my existing project

I have an existing ASP.NET project and it's not in MVC. When I try to install Hangire I get this error.
PM> Install-Package Hangfire
Attempting to gather dependency information for package 'Hangfire.1.5.8' with respect to project 'FYMAS', targeting '.NETFramework,Version=v4.0'
Attempting to resolve dependencies for package 'Hangfire.1.5.8' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Hangfire.1.5.8'
Resolved actions to install package 'Hangfire.1.5.8'
Adding package 'Newtonsoft.Json.5.0.1' to folder 'C:\Users\User\Desktop\hang\packages'
Added package 'Newtonsoft.Json.5.0.1' to folder 'C:\Users\User\Desktop\hang\packages'
Added package 'Newtonsoft.Json.5.0.1' to 'packages.config'
Successfully installed 'Newtonsoft.Json 5.0.1' to FYMAS
Install failed. Rolling back...
Package 'Hangfire.Core.1.5.8 : Newtonsoft.Json [5.0.0, ), Owin [1.0.0, )' does not exist in project 'FYMAS'
Removed package 'Newtonsoft.Json.5.0.1' from 'packages.config'
Package 'Hangfire.Core.1.5.8 : Newtonsoft.Json [5.0.0, ), Owin [1.0.0, )' does not exist in folder 'C:\Users\User\Desktop\hang\packages'
Removing package 'Newtonsoft.Json.5.0.1' from folder 'C:\Users\User\Desktop\hang\packages'
Removed package 'Newtonsoft.Json.5.0.1' from folder 'C:\Users\User\Desktop\hang\packages'
Install-Package : Could not install package 'Hangfire.Core 1.5.8'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package
does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package Hangfire
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
I tried to install owin to my project using Install-Package Owin command, this installation is success but when I try to install hanfire again, I got the same error. I tried installing an older version of hangfire using Install-Package HangFire -Version 1.4.6, but got the same error.
It seems your problem is your .NET framework, you are using 4.0, then you should install hangfire for your framework, try this
Install-Package Hangfire_net40
When you use Install-Package Hangfire, this will install the latest stable version (in your case Hangfire.1.5.8, this requires newer .net framework ~ 4.5). For more details, Hangfire (.Net 4.0) 1.1.1

ASP .NET MVC 6 Without DNX

I'm trying to install MVC 6 beta in a regular .NET 4.5.2 web project (not DNX). It gives me an error. Is this possible? Or will it eventually be supported?
PM> install-package Microsoft.AspNet.Mvc -pre
Attempting to gather dependencies information for package 'Microsoft.AspNet.Mvc.6.0.0-beta5' with respect to project '6 - Entry Points\Sample.Web', targeting '.NETFramework,Version=v4.5.1'
Attempting to resolve dependencies for package 'Microsoft.AspNet.Mvc.6.0.0-beta5' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Microsoft.AspNet.Mvc.6.0.0-beta5'
Resolved actions to install package 'Microsoft.AspNet.Mvc.6.0.0-beta5'
Install failed. Rolling back...
Package 'Microsoft.AspNet.Mvc 6.0.0-beta5' does not exist in project 'Sample.Web'
Package 'Microsoft.AspNet.Mvc 6.0.0-beta5' does not exist in folder 'C:\Dev\Sample\packages'
Install-Package : Could not install package 'Microsoft.AspNet.Mvc 6.0.0-beta5'. You are trying to install this
package into a project that targets '.NETFramework,Version=v4.5.1', but the package does not contain any assembly
references or content files that are compatible with that framework. For more information, contact the package
author.At line:1 char:1
+ install-package Microsoft.AspNet.Mvc -pre
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackage
Command
No, you can't. And no, it won't be eventually supported.

How do I install ServiceStack.Interfaces?

I have tried installing the ServiceStack Framework on both .Net 4.0 and .Net 4.5 applications. I have gotten the same error both times:
Install failed. Rolling back...
Install-Package : Could not install package 'ServiceStack.Interfaces 4.0.31'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any
assembly references that are compatible with that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package Servicestack
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
and
Install failed. Rolling back...
Install-Package : Could not install package 'ServiceStack.Interfaces 4.0.31'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', but the package does not contain any
assembly references that are compatible with that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package Servicestack
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
What gives?
The major change to happen to ServiceStack.Interfaces is that it's now a portable library as of v4.0.30 supporting most supported platforms (Profile136):
.NET 4.0+
Xamarin.iOS
Xamarin.Android
Windows Store
Silverlight 5
If NuGet is reporting that it can't find the necessary assembly references for a supported platform than it's likely that you're using an older version of NuGet that doesn't include PCL support, which can be resolved by upgrading to the latest NuGet.
The "upgrade Nuget" option was not working for me. Turns out that versions of ServiceStack do have .NET limits. Our application is .NET 4.0, so ServiceStack.Interfaces 4.062 was the highest version we could install.

Error installating MVVM Light libraries only (PCL)

I create a new PCL project, select Store app + Phone 8 + .Net 4.5
Then, from pakage manager console, I do:
Install-Package Portable.MvvmLightLibs -Pre
but it is not installed, I get an error. What I am doing wrong?
Thank you
The error message is:
Install-Package : Could not install package 'Portable.MvvmLightLibs 4.1.24-beta3'. You are trying to install this package into a project that
targets '.NETPortable,Version=v4.5,Profile=Profile78', but the package does not contain any assembly references that are compatible with that
framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package Portable.MvvmLightLibs -Pre
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
I had the same problem, but upgrading NuGet (currently 2.2) seems to have done the trick.

Resources