MVC 4 project does not resolve reference to System.Web.Helpers in VS 2015 - asp.net-mvc-4

It works in VS2013, where the reference is found on the system at "C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Assemblies\System.Web.Helpers.dll". This is not found on my clean Win10 install with VS2015.
Any ideas why?

It's because MVC 4 is not installed with VS 2015. You can install it from here.
Note that, strangely, you cannot install the nuget package microsoft-web-helpers, which contains this assembly. It will have a version conflict for one of it's dependencies with MVC 4.
Install-package : Unable to find a version of 'Microsoft.AspNet.WebPages' that is compatible with 'microsoft-web-helpers 2.1.20710.2 constraint: Microsoft.AspNet.WebPages (≥ 2.0.0 && < 2.1.0)', 'Microsoft.AspNet.Mvc 5.2.2 constraint: Microsoft.AspNet.WebPages (≥ 3.2.2 && < 3.3.0)'.
At line:1 char:1

Related

'MySql.Data' already has a dependency defined for 'System.Text.Encoding.CodePages' [duplicate]

I'm trying to add AutoMapper as a dependency to a project using NuGet on Visual Studio Premium 2012, but it fails.
It says:
Operation failed
'AutoMapper' already has a dependency defined for
'Microsoft.CSharp'.
I'm able to add other dependencies.
I'm using the last version of the package manager for VS 2012:
NuGet Package Manager 2.8.60318.667
Any ideas what should I check?
The problem is that your NuGet Package Manager is too old. You need NuGet 2.12 since this supports the newer .NETStandard frameworks that the AutoMapper 5.0.1 NuGet package is using.
The AutoMapper has a group dependency which specifies a target framework of .NETStandard. Since your version of NuGet Package Manager is too old it does not recognise this target framework and converts it to an Unknown target framework and you end up with duplicate frameworks since there .NETStandard is used a few times in that NuGet package. This causes the error:
'AutoMapper' already has a dependency defined for 'Microsoft.CSharp'
Unfortunately NuGet 2.12 is not available for Visual Studio 2012 but is available for Visual Studio 2013.
So either you need to update to Visual Studio 2013 or above, or you will have to use the older AutoMapper NuGet package which does not support .NETStandard.
Seems to be a problem with the current version of automapper:
AutoMapper 5.0.0 Tuesday, June 28, 2016
I tried with the previous version and it works:
PM> Install-Package AutoMapper -Verbose
Install-Package : 'AutoMapper' already has a dependency defined for 'Microsoft.CSharp'.
At line:1 char:16
+ Install-Package <<<< AutoMapper -Verbose
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
PM> Install-Package AutoMapper -Version 4.2.1
Installing 'AutoMapper 4.2.1'.
Successfully installed 'AutoMapper 4.2.1'.
So, if you can't update NuGet Package Manager, the answer is:
PM> Install-Package AutoMapper -Version 4.2.1
I ended up needing to update NuGet.exe that was included in the solution to be able to build NuGet packages by running:
nuget.exe update -self
I had the same issue on VS2013. I had to update to VS2013 Update 5 and get the latest nuget distro for VS2013 at
https://dist.nuget.org/visualstudio-2013-vsix/v2.12.0/NuGet.Tools.vsix
Once that was done, I rebooted Visual Studio. After that I was able to use the Automapper 5.0.2 package
Go to Visual Studio > Tools > Extension and Updates
Find Updates in left accordion menu, Go to Visual Studio Gallery.
You will find a update for Nuget.
Update the nuget package and try installing or builing the project.
Thanks,
GT
An other workaround if you're stuck with VS2012 and the old Nuget version:
Find the Cache folder of VS 2012's Nuget Package Manager (with Tools - Options - Nuget Package Manager)
Open AutoMapper.5.x.x.nupkg with your favorite Zip Tool
Modify the file AutoMapper.nuspec - I simply deleted all dependencies except .NETFramework4.5
Add the cache folder as a Nuget source (also in Tools - Options - Nuget Package Manager)
Install Automapper either with the console or the GUI but make sure to choose first the newly added cache folder as package source.
Of course, the next version of Automapper probably needs to be adapted, too, in order to install it.
This looks like a mismatch between the .NET version used by the Automapper package and your project. Can you confirm the .NET version that your project is using?
Automapper 6.0.2 - nuget 2.8.8 gives this error. Needed to update to 3.4.4 to get this working.
Removed both CSharp and AutoMapper. Installed CSharp (4.0.0.0) first and then added Automapper (6.1.1.0). This resolved the problem for me.
I observed this exact problem when opening a project with Visual Studio 2010.
After opening with VS2017, I was able to install AutoMapper without any error.

How to update version of Microsoft.NETCore.App SDK in VS 2017

I have ASP.NET Core API project which was initially developed using VS 2015. I installed VS 2017 and let it convert the project.
Then i goto Project Properties -> Application ->Target framework and change the target framework to .NETCoreApp 1.1.
as soon as i do that i get 2 errors
Error One or more projects are incompatible with
.NETCoreApp,Version=v1.0.
Error Project Api is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Project Api supports: netcoreapp1.1
(.NETCoreApp,Version=v1.1)
when i checked Dependencies -> SDK -> Microsoft.NETCore.App -> Properties it shows version 1.0.4 and SDK Root to C:\Users\username\.nuget\packages\microsoft.netcore.app\1.0.4
I have already installed Microsoft.NETCore.App SDK version 1.1.2 on my machine.
When i goto Nuget Package Manager to update SDK version, it shows its Autoreferenced and update button is disabled.
How do i update project's SDK's version to 1.1.2?
Also why VS studio reference SDK from C:\Users\username\.nuget\packages\microsoft.netcore.app instead of from C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2
Update 1
Actually 1.1.2 is not SDK version. As of 7/20/2017 the latest SDK version is 1.0.4 and Runtime version is 1.1.2 On my machine I have C:\Program Files\dotnet\sdk\1.0.4 SDK and C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2 runtime installed.
So as i mentioned erlier, when i open converted project in VS 2017, I see Dependencies -> SDK ->Microsoft.NETCore.App - Properties version is 1.0.4 and SDK Root is C:\Users\username\.nuget\packages\microsoft.netcore.app\1.0.4
Now I added new project in the same solution, however new project's Dependencies -> SDK ->Microsoft.NETCore.App -> Properties version is 1.1.2 and SDK root C:\Users\username\.nuget\packages\microsoft.netcore.app\1.1.2
I am not sure which is correct here, the SDK version of the converted project or SDK version of the newly added project?
Infact if create a brand new project in VS 2017 i see its Dependencies -> SDK ->Microsoft.NETCore.App -> Properties version is 1.1.2
1.1.2 SDK not even SDK available. Why VS 2017 shows runtime version as SDK version
is this a bug in VS 2017?
Right click your project and edit your csproj file.
If you see a line like this:
<RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>
Then update it to 1.1.2 or just remove this line. Then restore the packages (maybe using command line dotnet restore, I don't know whether VS will do this automatically).
This way you can update Microsoft.NETCore.App to 1.1.2 and this should fix your problem.
I`d suggest you to update every of your project dependencies at least to version 1.1.0, then try to change the version once again. Make sure to clean and rebuild your solution after all.
In my case, I had a project using .NET Core 3.1 and I wanted to update to 5.0, which is the latest version at the moment. In the csproj file, I deleted the line preceded by the minus symbol and added the line preceded by the plus symbol, as shown below 1:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
- <TargetFramework>netcoreapp3.1</TargetFramework>
+ <TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>
Then, I created a file called global.json whose content was the following:
{
"sdk": {
"version": "5.0.103"
}
}
For this, I used the command: dotnet new globaljson --sdk-version 5.0.103 2
Finally, I compiled and run the application and worked!

Unable to install MySql.Data.EntityFrameworkCore into .NET Core App

When trying to install the 'MySql.Data.EntityFrameworkCore' package, I get the following error:
Microsoft (R) Build Engine version 15.1.548.43366 Copyright (C)
Microsoft Corporation. All rights reserved.
Writing /tmp/tmpiXrULm.tmp info : Adding PackageReference for
package 'MySql.Data.EntityFrameworkCore' into project
'/media/xxx/xxx.csproj'. log
: Restoring packages for
/media/xxx/xxx.csproj...
info : CACHE
https://api.nuget.org/v3-flatcontainer/mysql.data.entityframeworkcore/index.json
error: Unable to resolve 'MySql.Data.EntityFrameworkCore' for
'.NETCoreApp,Version=v1.1'.
error: Package
'MySql.Data.EntityFrameworkCore' is incompatible with 'all' frameworks
in project
'/media/xxx/xxx.csproj'.
I'm targeting Asp.NetCore 1.1.1
Is this the correct MySql EF package for .NET core?
Install given nuget package using package manager console:
Install-Package MySql.Data.EntityFrameworkCore -Version 8.0.9-dmr
OR
Using .NET CLI:
dotnet add package MySql.Data.EntityFrameworkCore --version 8.0.9-dmr
Then add this to .csproj file and restore your project:
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.8-dmr" />

Why is package restore failing when I upgrade to ASP.NET Core 1.0.1?

I am attempting to install ASP.NET Core 1.0.1 on my windows 7 dev box which already has ASP.NET Core 1.0 working in Visual Studio Community 2015 Update 3.
To accomplish this I installed .NET Core 1.0.1 - VS 2015 Tooling Preview 2 from https://www.microsoft.com/net/core#windows as indicated by https://blogs.msdn.microsoft.com/dotnet/2016/09/13/announcing-september-2016-updates-for-net-core-1-0/
I then updated several version numbers in my existing project.json file from 1.0.0 to 1.0.1 so that my web application would use the new 1.0.1 components.
As expected this triggers a package restore, but unfortunately it fails. I can't figure out why the packages restore is failing. Any help would be greatly appreciated.
Here are the errors from the output window:
Errors in C:\Users\Ron Clabo\Documents\Visual Studio 2015\Projects\wwwGiftOasisResponsive\src\wwwGiftOasisResponsive\wwwGiftOasisResponsive.xproj
Unable to resolve 'Microsoft.AspNetCore.Server.IISIntegration (>= 1.0.1)' for '.NETFramework,Version=v4.5.2'.
PATH=.\node_modules.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\git
C:\Program Files\dotnet\dotnet.exe restore "C:\Users\Ron Clabo\Documents\Visual Studio 2015\Projects\wwwGiftOasisResponsive.vs\restore.dg"
log : Restoring packages for C:\Users\Ron Clabo\Documents\Visual Studio 2015\Projects\wwwGiftOasisResponsive\src\wwwGiftOasisResponsive\project.json...
error: Unable to resolve 'Microsoft.AspNetCore.Server.IISIntegration (>= 1.0.1)' for '.NETFramework,Version=v4.5.2'.
log : Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in C:\Users\Ron Clabo\Documents\Visual Studio 2015\Projects\wwwGiftOasisResponsive\src\wwwGiftOasisResponsive\project.json...
log : Writing lock file to disk. Path: C:\Users\Ron Clabo\Documents\Visual Studio 2015\Projects\wwwGiftOasisResponsive\src\wwwGiftOasisResponsive\project.lock.json
log : C:\Users\Ron Clabo\Documents\Visual Studio 2015\Projects\wwwGiftOasisResponsive\src\wwwGiftOasisResponsive\wwwGiftOasisResponsive.xproj
log : Restore failed in 2895ms.
Errors in C:\Users\Ron Clabo\Documents\Visual Studio 2015\Projects\wwwGiftOasisResponsive\src\wwwGiftOasisResponsive\wwwGiftOasisResponsive.xproj
Unable to resolve 'Microsoft.AspNetCore.Server.IISIntegration (>= 1.0.1)' for '.NETFramework,Version=v4.5.2'.
My understanding is that the upgrade from ASP.NET Core 1.0 to 1.0.1 is suppose to be pretty easy so I must be missing something simple but after hours of looking I could really use some advice.
You didn't read the upgrade instructions (and here) correctly.
This is not a global version bump. Only the listed packages were upgraded to 1.0.1. All remaining ASP.NET Core packages stay at 1.0.0, this includes Microsoft.AspNetCore.Server.IISIntegration.
The affected packages are:
Microsoft.EntityFrameworkCore
Microsoft.AspNetCore.Server.Kestrel
Microsoft.AspNetCore.Mvc
Microsoft.AspNetCore.Antiforgery
Microsoft.AspNetCore.Routing
Not every package got version bumped to 1.0.1. There is no 1.0.1 version of IIS Integration on nuget. That component should be left at 1.0.0 in your project.json.

entity framework 5 install on win8 MSVC2012 RTM

I have recently installed the Latest Win8 OS (RTM) and installed MSVC 2012 RTM as well (I also have MSVC 2010 installed as I am porting from Win7 Phone to Win 8 Tablet and need to refer to the old code (not sure if this may affect outcome)). I need to install Entity Framework in MSVC 2012 and when I look at the NuGet Package Manager it tells me version 5.0.0. is available. However it never installs correctly, it says it has installed successfully then, says it can't and uninstalls it. I have tried using the NuGet Package Manager and the PM console, the results from the PM console are below :
PM> Install-Package EntityFramework
You are downloading EntityFramework from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkId=253898&clcid=0x409. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'EntityFramework 5.0.0'.
Successfully uninstalled 'EntityFramework 5.0.0'.
Install failed. Rolling back...
Install-Package : Could not install package 'EntityFramework 5.0.0'. 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 that are compatible with that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package EntityFramework
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
When I look at the packages folder during the install it all seems present and then it is deleted. I have admin rights set on my user Account.
What is going wrong? pls help.
Brenda
You are adding EntityFramework package to Windows 8 Application or class library project (= to Metro application). That is not supported. You must use full .NET Framework 4.5 (= desktop application, web application, etc.) to use Entity Framework.
I had this problem. This is what I did:
From the package manager console:
PM> Uninstall-Package EntityFramework -Force
This threw an error. I then went to the "packages" folder under the solution folder and removed the Entity Framework subfolder. I then ran
PM> Install-Package EntityFramework
And then right-clicked my project where I wanted to install EF and installed it from the NuGet dialog.