Installing Microsoft.AspNetCore.Mvc - c#

I use Visual Studio Community 2015
Version 14.0.25123.00 Update 2
NuGet Package Manager 3.4.4
When trying to install Microsoft.AspNetCore.Mvc package in a .NET 4.6.1 console Application project, I get the following error:
install-package : Could not install package 'runtime.native.System 4.0.0-rc2-24027'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.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.AspNetCore.Mvc -pre
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Can anyone help me out ?

Basically you can not install Microsoft.AspNetCore.Mvc in a console Application. In a console application from Microsoft.AspNetCore.* you can install only Microsoft.AspNetCore.Authentication.ActiveDirectory.
To prove this try this way:
Right click in the references
Chose Manage Nuget Packages...
From 3 tabs (Browse, Installed, Updates) choose Browse tab.
Write in the search box Microsoft.AspNetCore.
The reason you can not install that your application is simply a console app not MVC structure.

Related

Stuck in asp.net core tutorial. Trying to use package manager console to add EF Core SQL Server provider does not work

I am following this beginners tutorial on Microsoft's site.
At this step...
In the PMC, run the following command:
Install-Package Microsoft.EntityFrameworkCore.SqlServer
When I enter that command I get these messages and errors..
PM> Install-Package Microsoft.EntityFrameworkCore.SqlServer
Restoring packages for C:\projects\LazerbaseASPNET\LazerbaseASPNET\LazerbaseASPNET.csproj...
GET https://api.nuget.org/v3-flatcontainer/microsoft.entityframeworkcore.sqlserver/index.json
OK https://api.nuget.org/v3-flatcontainer/microsoft.entityframeworkcore.sqlserver/index.json 208ms
GET https://api.nuget.org/v3-flatcontainer/microsoft.entityframeworkcore.sqlserver/6.0.7/microsoft.entityframeworkcore.sqlserver.6.0.7.nupkg
OK https://api.nuget.org/v3-flatcontainer/microsoft.entityframeworkcore.sqlserver/6.0.7/microsoft.entityframeworkcore.sqlserver.6.0.7.nupkg 71ms
Installed Microsoft.EntityFrameworkCore.SqlServer 6.0.7 from https://api.nuget.org/v3/index.json with content hash D9YV3hc3VSN1qrfdrZcKtMcRLT6bUqj8KtaUdkmO1CH/+meL+8z3Rge5iPhwQ4ol2AwPQlQYVPTTajf9ulSFGg==.
Install-Package : NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 6.0.7 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package
Microsoft.EntityFrameworkCore.SqlServer 6.0.7 supports: net6.0 (.NETCoreApp,Version=v6.0)
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore.SqlServer
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Install-Package : Package restore failed. Rolling back package changes for 'LazerbaseASPNET'.
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore.SqlServer
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Time Elapsed: 00:00:03.2286177
Seems the important one is this...
Package Microsoft.EntityFrameworkCore.SqlServer 6.0.7 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package
Microsoft.EntityFrameworkCore.SqlServer 6.0.7 supports: net6.0
This tutorial is for asp.net core 3.1.. It seems to be the one they recommend for beginners also. I am at a impass and have no idea how to proceed.
EDIT:
I think this is cus I used Visual Studio 2019 which I already had installed for Unity.. asp.net core 3.1 was the only option available for a new project... I think I need to wipe the existing server from azure, download Visual Studio 2022 and start again with a asp.net core 6 app ?
You can try to install entity framework core through the nuget package manager.
Rightclick on your project -> Manage Nuget packages. Before installing select the correct version from the dropdown for the netcore app version you are running.
I think this is cus I used Visual Studio 2019 which I already had installed for Unity.. asp.net core 3.1 was the only option available for a new project.
The solution is wipe the existing server from azure, download Visual Studio 2022 and start again with a asp.net core 6 app.
FML.
I also want to point out that this tutorial is wrong. Earlier in it it says requirement is Visual Studio 2019 16.4 or later.
I did read this and checked the version of Visual studio I had installed, I met the requirements so I kept going.

Unable to install a Nuget Package in a .NET Framework 4.7.2 project

In my WPF project using .NET Framework 4.7.2 in VS2017, I'm trying to install Interop.MSUtil.dll NuGet package as suggested here. I do need this package installed, so could someone please help me installing it or providing a workaround.
Error:
Install-Package : Could not install package 'Interop.MSUtil.dll 1.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2',
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 Interop.MSUtil.dll -Version 1.0.0
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
It appears that the NuGet package for Interop.MSUtil.dll is not compatible with the .NET 4.7.2 Framework.
However, if you have LogParser installed on your machine and you have administrator access, you can recreate it locally.
Locate your copy of LogParser. The most likely place is in C:\Program Files (x86)\Log Parser 2.2.
Locate your Developer Command Prompt. In Windows 10, just type developer command prompt into the Windows search bar.
Run it as Administrator. Generally this can be done by right-clicking on the Developer Command Prompt item for the context menu.
cd to the location where LogParser is installed.
Run the following command:
tlbimp LogParser.dll /out:Interop.MSUtil.dll
This should build a new version of Interop.MSUtil.dll which will be friendly to your version of the Framework.
Now you can add it as a reference manually by browsing to the LogParser directory and selecting the new DLL.
Don't forget you may need to set Embed Interop Types to False.
Note that this draws heavily from this previous answer.
If Nuget package is not declared to be installed it can't be installed through the package manager.
However you can install a .dll file. First install it on the some project where it can be installed. Then in packages folder of the project find some .dll file that you find appropriate. Finally add it as the reference to the project. It may or may not work depending on the package itself but that is the only way if it has any chance to work.

Nuget package installation fails although package should be supported

I am trying to install the package Microsoft.Extensions.DependencyInjection.Abstractions in my Visual Studio 2013 solution as part of a Sitecore installation. The solution has .NET target framework 4.5.2.
The installation fails with
Install-Package : Could not install package 'Microsoft.Extensions.DependencyInjection.Abstractions 1.0.0'. You are trying to install this package into a project that targets
'.NETFramework,Version=v4.5.2', 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.Extensions.DependencyInjection.Abstractions -Version 1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
I have tried performing the installation in a completely new, empty solution but the installation still fails.
According to the link, there is a dependency to .NETStandard 1.0 but this should be supported by 4.5 according to this.
JaCraig's commment helped me solve this: I upgraded Nuget Package Manager from 2.8 to 2.12. Afterwards, there were no problems with the installation.

Unable to install package UnmanagedExports

In the NuGet Package Manager Console in Visual Studio Express 2012 for Windows 8, I hit
PM > Install-Package UnmanagedExports
I get the following error :
Installing 'UnmanagedExports 1.2.7'.
Successfully installed 'UnmanagedExports 1.2.7'.
Adding 'UnmanagedExports 1.2.7' to JNAExample.
Uninstalling 'UnmanagedExports 1.2.7'.
Successfully uninstalled 'UnmanagedExports 1.2.7'.
Install failed. Rolling back...
Install-Package : Could not install package 'UnmanagedExports 1.2.7'.
You are trying to install this package into a project that
targets'.NETCore,Version=v4.5', 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 UnmanagedExports
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo :
NotSpecified: (:[InstallPackage],InvalidOperationException
+ FullyQualifiedErrorId :
NuGetCmdletUnhandledExceptionNuGet.PowerShell.Commands.InstallPackageCommand
I created a New Project under Visual C# as Class Library.
How to solve this issue ?
The UnmanagedExports NuGet package has an assembly in the lib/net folder inside the NuGet package. Which means it supports projects that target the full .NET Framework, any version. So it does not support UWP projects.
You would need to find another NuGet package, or find the source, if it is available, and compile that in a UWP project or a project that is compatible.

'System.Net.Http' already has a dependency defined for 'System.Runtime'

I'm trying to install the MaxMind MinFraud package via NuGet. Whenever I try, I get the following back -
PM> install-package MaxMind.MinFraud
Attempting to resolve dependency 'System.Net.Http (≥ 4.0.0)'.
install-package : 'System.Net.Http' already has a dependency defined for 'System.Runtime'.
At line:1 char:1
+ install-package MaxMind.MinFraud
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
A few other similar questions here suggested restarting VS, manually adding a reference to System.Net.Http and clearing NuGet Package Cache, and changing the target framework to 4.6.2 (originally 4.5), all of which did not work for me.
Any ideas on what I can try next?
I installed this package successful in my Visual Studio 2015 Update 3 project with NuGet Package Manager 3.4.4.
So please make sure your are using the latest version of Visual Studio 2015 and NuGet Package Manager.

Categories