Abp 5.0 Template Issue with EF on VS2017 - entity-framework

everyone,
I downloaded the template with the following features
Abp 5.0.0.0
Asp.Net MVC 5.x
Web application with server rendered HTML; ASP.NET MVC & jQuery
Entity Framework
VS2017 Community as Development Environment
The problem lies in the Entity Framework or the version of Nuget
Running the Update-Database command from the Nuget console always returns the same error
Update-Database not recognized cmdlet
My Nuget Version is 4.9.3.5777
I tried both to clear nuget cache, restore solution packages, restart vs2017 and computer (Windows 7 Enterprise 64) without success
There is some issue on download packages?

There is some issue on download packages?
I think this issue stands that the EF package is not installed successfully in your current project.
1.Please check if you have yellow warnings in Solution Explorer like this issue. If there's any warning, resolve it or share it here and I'll check it for you.
2.I know you've cleaned the nuget cache, but see this, there's one copy of the EF package locates in your Solution folder's packages folder when you're in project that uses Packages.config format. So though you've cleaned the nuget cache in %userprofile%\.nuget\packages, your project is still using the old copy in solutionDirectory\packages folder.
Suggestion(The order is important, please follow the steps one by one):
#1 For this, you should right-click your project=>Manage Nuget Packages(UI)=>Uninstall the EntityFramework package.(Or manually delete the EF package folder within SolutionDir\packages folder)
#2 Then clean the nuget cache by Tools=>Nuget Package Manager=>Package Manager Settings=>Clear All Nuget Cache.
#3 Close Package Manager Console if it's open. => Close VS instance.
#4 Then restart VS and reinstall that EF package by package manager UI. And manually open the Package Manager Console and type Update-Database to check if this issue goes away.
Hope it helps:)

Related

Nuget install failed: the package does not contain any assembly references or content files that are compatible with that framework

If I understand Scott Hanselman's post here correctly then I should be able to reference a .net standard library from a framework 4.7.2 solution.
I want to use Nuget to install such a reference.
I am using Azure DevOps Artifacts for the Nuget package. When I push my .net standard solution I can see that the package does create and that the Nuget install command is
Install-Package SBD.Standard -version 2.0.0-CI-etc
However when I try this at the PM console for my framework 4.7.2 project I get
Could not install package 'SBD.Standard 2.0.0-etc'. 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
moreover I do not see SBD.Standard as an avialable package in the relevant feed from within VS2019 -> Manage nuget packages for solution.
I think I need packages.config
I was able to create a new 4.7.2 project and add the nuget package that used .net standard 2.0 (but not 2.1)
When I tried to add the nuget package I got a dialog asking me to select the Nuget package manager format
so I chose Packages.config and that worked.
I am not sure I have it right. I solved my problem but am not sure whether this was it after all. SInce PackageReference is more recent it should work.
Some additional explanations for this issue.
There is an issue for NuGet restore when you using new SDK-based project type or PackageReference in the .net framework:
https://github.com/NuGet/Home/issues/5461
https://github.com/dotnet/sdk/issues/1755
When we use packages.config projects or non-SDK based project type, NuGet do not check compatibility during install/restore.
So, to resolve this issue, we need make sure the referenced project is an old style csproj or use packages.config.
That the reason why the packages.config works for you.
Hope this helps.

Assets file project.assets.json not found. Run a NuGet package restore

I'm trying to use nopCommerce(Which is written in .NET Core) but when I want to run the project I face 52 Errors telling me Run a nuget package restore
Assets file ~\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. Nop.Web.MVC.Testsote
when I use the right click on the solution and selecting Restore Nuget Packages I get this message:
All packages are already installed and there is nothing to restore.
but those 52 Errors are still there and in Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution there is nothing installed on the solution,also I Recently updated my VS2017 to 15.5.4
To fix this error from Tools > NuGet Package Manager > Package Manager Console simply run:
dotnet restore
The error occurs because the dotnet cli does not create the all of the required files initially. Doing dotnet restore adds the required files.
In my case the error was the GIT repository. It had spaces in the name, making my project unable to restore
If this is your issue, just rename the GIT repository when you clone
git clone http://Your%20Project%20With%20Spaces newprojectname
In case when 'dotnet restore' not works, following steps may help:
Visual Studio >> Tools >> Options >> Nuget Manager >> Package Sources
Unchecked any third party package sources.
Rebuild solution.
To those with the same issue as me in Azure DevOps / VSTS environment encountering a similar message:
C:\Program Files\dotnet\sdk\2.2.104\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(208,5): Error NETSDK1004: Assets file '...\obj\project.assets.json' not found. Run a NuGet package restore to generate this file
Add /t:Restore to your MSBuild Arguments in Build Solution.
Closing and re-opening Visual Studio solved this issue for me, once I had made sure the NuGet packages had been restored as per other answers posted here.
Edit: Sometimes just trying to build again fixes the problem.
For me when i did - dotnet restore still error was occurring.
I went to
1 Tool -> NuGet Package Maneger -> Package Manager settings -> click on "Clear all NuGet Cache(s)"
2 dotnet restore
resolved issues.
In visual studio 2017 please do following steps:
1) select Tool=>Options=>NuGet Package Manager=> Package Sources then uncheck Microsoft Visual Studio Offline Packages Option.
2) now open Tool=>NuGet Package Maneger=>Package Manager Console.
3) execute command in PM>dotnet restore.
Hope its working...
It was mentioned earlier but I just wanted to re-emphasize the importance of not have space anywhere in your pathing! This is what was getting me. You've been warned.
If this error occurs as part of a build in Azure DevOps (TFS) and your build already has a NuGet restore task, this error may indicate the NuGet restore task was not able to restore all packages, especially if you use a custom package source (such as an internal NuGet server). Adding /t:Restore;Build to the MSBuild Arguments seems to be one way to resolve the error, but this asks MSBuild to perform an additional NuGet restore operation. I believe this succeeds because MSBuild uses the custom package source configured in Visual Studio. A preferable solution is to fix the NuGet restore task.
To configure a custom package source for the NuGet restore task:
Create a NuGet.config file that lists all of the package sources (Microsoft Visual Studio Offline Packages, nuget.org, and your custom package source) and add it to source control.
In the Nuget restore task under Feeds to use: select the option Feeds in my NuGet.config.
Provide the path to NuGet.config.
Remove the /t:Restore;Build option from the MSBuild task.
Additional information is available here.
For me I upgraded NuGet.exe from 3.4 to 4.9 because 3.4 doesn't understand how to restore packages for .NET Core.
For details please see dotnet restore vs. nuget restore with teamcity
You will get required packages from "https://api.nuget.org/v3/index.json". Add this in Package Resources. Also make sure other packages are unchecked for time being. And Click Restore Nuget Package on Solution Explorer
Select Tools > NuGet Package Manager > Package Manager Console
And then Run:
dotnet restore <project or solution name>
Solved by adding /t:Restore;Build to MSBuild Arguments
Nothing above worked for me. But simply deleting all 'bin' and 'obj' folders did the trick.
You can go for : Tools > NuGet Package Manager > Package Manager Console
And then Run:
dotnet restore
little late to the answer but seems this will add value. Looking at the error - it seems to occur in CI/CD pipeline.
Just running "dotnet build" will be sufficient enough.
dotnet build
dotnet build runs the "restore" by default.
I lost several hours on this error in Azure DevOps when I set the 'Visual Studio Build' task in a build pipeline to build an individual project in my solution, rather than the whole solution.
Doing that means that DevOps either doesn't build any (or possibly some, I'm not sure which) of the projects referenced by the project you've targeted for the build, and therefore those projects won't have their project.json.asset files generated, which then causes this issue.
The solution for me was to swap from using the VS Build task to the MSBuild task. Using the MSBuild task for an individual project correctly builds any projects referenced by the project you're building and eliminates this error.
This problem happening when your build tool is not set to do restore on projects set to use PackageReference vs packages.config and mostly affect Net Core and Netstandard new style projects.
When you open Visual Studio and build, it resolves this for you. But if you use automation, CLI tools, you see this issue.
Many solutions are offered here. But all you need to remember, you need to force restore. In some instances you use dotnet restore before build. If you build using MsBuild just add /t:Restore switch to your command.
Bottom line, you need to see why restoring can't be activated. Either bad nuget source or missing restore action, or outdated nuget.exe, or all of the above.
If simply restoring NuGet packages does not work make sure in Tools -> Options -> NuGet Package Manager -> General under Package Restore that the "Allow NuGet to download missing packages" is checked.
Then Restore NuGet Packages again OR just REBUILD after deleting obj and bin folders.
run your VS as administrator after that in package manager console run dotnet restore.
When using VSTS, check your global.json file. I had entered the sdk version as just "2.2" which caused a parse error (but not when building locally). Adding the full version, "2.2.104" solved the problem.
I have same problem and dotnet resotre not work for me. I Install this component:
and the run dotnet resotre and the problem has solved.
In my case, I had the following added to my *.csproj files to fully remove obj and bin folders on 'Clean'. Apparently, it was the culprit. Got rid of that and viola, all started to work again. Now I'm using the "Clean Bin" extension instead. Hope this might help anyone who is running into this issue, and none of the mentioned fixes works.
<Target Name="SuperClean" AfterTargets="Clean">
<!-- Remove obj folder -->
<RemoveDir Directories="$(BaseIntermediateOutputPath)" />
<!-- Remove bin folder -->
<RemoveDir Directories="$(BaseOutputPath)" />
</Target>
Another one, if by any chance you're using Dropbox, check for Conflicted in file names, do a search in your repo and delete all those conflicted files.
This may have happened if you have moved the files around.
Cause of this defect: you have to remove the injected Nuget in file explorer.
Solution: Once you remove that Nuget in your system, then remove from following location.
select Tool=>Options=>NuGet Package Manager=> Package Sources then uncheck Microsoft Visual Studio Offline Packages Option
This worked for me:
added this package source:
Microsoft and .net
https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/
then run "dotnet restore" in the console
In my case I had a problem with the Available Package Sources. I had move the local nuget repository folder to a new path but I did not update it in the Nuget Available Package Sources. When I've correct the path issue, update it in the Available Package Sources and after that everything (nuget restor, etc) was working fine.
Very weird experience I have encountered!
I had cloned with GIT bash and GIT cmd-Line earlier, I encountered the above issues.
Later, I cloned with Tortoise-GIT and everything worked as expected.
May be this is a crazy answer, but trying with this once may save your time!
Seen this after adding a WinForms Core 3.1 project (from project templates) on VS-2019 vs 16.4.0 and trying to run it out of the box. Clean or Rebuild the entire solution did not work.
I just reloaded my solution.. that is File/Close Solution and then reopening it and rebuilding it solved the problem.
For me it turned out to be a nuget source credentials problem. I had recently changed my password for accessing a nexus server and visual studio was still using the old password when trying to access a nuget on that server through the windows credential manager. To fix it, I had to delete the entry for those outdated credentials in the credential manager and after, when I did a nuget restore, it prompted me for a password letting me enter the new password, which got saved in the credential manager again. You can access the credential manager from the cmd line using CmdKey.exe.

Could not install package '--'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5'

I created this package, I need it in a project but couldn't install it, this error appears:
Could not install package 'Mshwf.NiceLinq 1.0.9'. 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 or content files that are compatible with that
framework. For more information, contact the package author
I don't know why this happen, in another project (Console) I changed the framework to 4.6 and other versions and it wasn't a problem, but this only happen in this project (MVC and Web API):
this is the nuspec file:
<?xml version="1.0"?>
<package >
<metadata>
<id>Mshwf.NiceLinq</id>
<version>1.0.9</version>
<title>Nice LINQ</title>
<authors>MShawaf</authors>
<owners>Mshawaf</owners>
<projectUrl>https://github.com/mshwf/NiceLinq</projectUrl>
<iconUrl>https://raw.githubusercontent.com/mshwf/NiceLinq/master/logo.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>See it as: WHERE ID IN (1, 2, 3, 7, 9, 22, 30, 101)</description>
<releaseNotes>Minor changes.</releaseNotes>
<copyright>Copyright 2016</copyright>
<tags>LINQ IEnumerable Where Contains Search Filter</tags>
</metadata>
</package>
Your package targets NETFramework,Version=v4.5.2. That means the assembly folder is lib\net452. You are trying to install the package to a higher framework (greater than 4.5) project. Create a project with framework 4.5.2 or rename the package's lib folder from net452 to the version which you want to target like net45 or net46.
You can target multiple framework too from a single package.
Edit your csproj file like this:
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
Refer here: https://learn.microsoft.com/en-us/nuget/create-packages/supporting-multiple-target-frameworks
For a complete, up-to-date list of target framework names, refer to https://learn.microsoft.com/en-us/nuget/reference/target-frameworks#supported-frameworks
Go to the folder:
C:\Users\[username]\.nuget\packages\[package name]\1.0.0.4\lib
Rename the folder with the .net version of your project.
Suppose I am using .net framework 4.6.1 my folder name should be net461
You can install earlier version like : Install-Package AutoMapper -Version 7.0.1
The .NET Target Framework version is most likely too old. I have VS 2017 and my default Target Framework for a new .NET Framework project was 4.0. I initially tried to install the RestSharp package but it failed with an almost identical message as in this post 'Could not install package ...' However, when I went to Project | Properties | and Application I was able to change the Target Framework to .NET Framework 4.6.1 and then it installed fine.
In my case, I was trying to install the package into a WPF App (.Net Framework) while my co-workers prepared the package for .Net Core Project.
Try creating a .Net Core Project(or the type of the targeted project type) and install the packages same way:
Solution Explorer>Right click to Solution>Manage Nuget Packages for solution>Search for the needed package>Install
Checking this before other solutions may save time.
In my case, I was trying to insert a package of our own making that we put into our own Nuget feed, so I had access to the project.
This is what I did to clear the issue up. In the project solution window, click on the packages.config. In the properties window, change build action to "Content." After pushing it out to our feed again I was able to install it into the main project.
I had similar issue which i fixed by removing the packages.config(you can edit the file if you don't want to remove) file and then made sure both the package i was using was built using the same .net version as the Project i was using it in(for me the package was built using 4.6 while my console project was targeting earlier version of .net).
Update the Application .NET target framework could solve the problem. In my case, I'm installing EmguCv 4.2 package. I get this same error when trying to build with 4.5.1 .NET target framework. After updated the .NET target framework to 4.6.2, I can install the EmguCv 4.2 Nuget package successfully.
Try installing .net SDK here and then right-click on your solution/project and "restore nuget packages"
I had this problem with a package I had created and hosted on our own private nuget server, but even after trying others suggestions here such as making sure that the package supported the correct .net framework version, it still wouldn't work.
I got someone else to try and they managed to add it with no problem.
Today, messing around in VS's options, I found a fix for this:
Options -> NuGet Package Manager -> General -> Clear All NuGet Cache(s)
How to clear nuget cache in visual studio
Hopefully this helps someone who was as confused as I was :D
In my case I tried to install Itext7 package my project .NET framework was 4.5
I changed my project .NET framework to .NET 4.6.1 by using the following steps then I installed the package successfully :
1- right click the project and click properties
2- Under application tab change the Target framework to the required framework for your package
I could not install OpenTK package in .NETFramwork app but i had success with .NET Core project
Check the supported version from "C:\Users \ [username] \.nuget\packages
[package name]\1.0.0.4\lib".
Go to Project > Right click and select Properties > Application > Target Framework
Change the Target Framework to the supported version
In my case supported version is net462 for the library

Unable to locate Dependency Microsoft.AspNet.Server.WebListener >= 1.0.0-rc1-final

I'm using the very latest ServiceFabric SDK (v1.4.87.9494) with VS2015 Update1 and the latest ASP.NET 5 RC1 update (v1.0.11125.0).
When I add an ASP.NET 5 WebApp to my ServiceFabric solution I am seeing an error in project.json that looks like this:
Unable to locate Dependency Microsoft.AspNet.Server.WebListener >=
1.0.0-rc1-final
I'm a super noob to ServiceFabric and ASP.NET 5, how do I go about debugging this?
This is a known (intermittent) issue that will be fixed in an upcoming SDK refresh. In the meantime, you should be able to work around it in one of two ways:
Option 1: In the web project, open project.json, make some kind of cosmetic change (add a space or a newline) and save it. This will force a package restore, which should bring down the WebListener.
Option 2: Explicitly add the WebListener package to the web project. Right-click on the web project, choose Manage NuGet Packages, then search for Microsoft.AspNet.Server.WebListener and install it.
If neither of those work, we've occasionally seen cases where having numerous NuGet package sources exacerbates this problem. You can try de-selecting all sources except nuget.org and that generally fixes it.
Add AspNetVNext to your NuGet package sources pointing to https://www.myget.org/F/aspnetmaster/api/v2/

NuGet not updating project references

I recently migrated all my Visual Studio 2013 projects to Visual Studio 2015 and followed the steps documented in this article by Nuget to make sure that automatic package restore is still working, in short
I deleted the Nuget.exe and Nuget.target files from source control and disk
I updated all project files and deleted the sections related to Nuget
I'm experiencing a problem when I'm updating Nuget packages, it is not updating the project references to point to the newest dll versions. I can see that the newest packages was installed though. This problem is also not related to specific packages.
Has anyone else experienced a problem like this?
NuGet package restore does not modify the project files. It just downloads and extracts the NuGet packages to the packages directory.
If you are trying to edit the packages.config file and then have the project's updated you would have to use the Package Manager Console and run:
Update-Package -reinstall
Which will uninstall and install the packages again and update the project's references.
We realized that some of our junior developers only installed the required Nuget packages for ONE project in the solution, they then added references to the required dll's for all other projects by browsing to the physical location of the dll's on disk. This obviously caused the problem because only ONE of the projects in the solution contained entries for Nuget packages in it's packages.config file while the remaining projects in the solution contained none.
When all packages were updated using the Update-Package command only the ONE project containing entries in it's packages.config file were updated with the correct project references.
Even though this is not a Nuget bug and rather a problem caused by inexperience, I logged an issue with Nuget to see if they can improve the software to prevent these types of problems.
So I recently had a very similar issue as well, unfortunately uninstalling and reinstalling did not work. Hopefully this helps anyone else as it was very frustrating.
Steps:
go to or launch the quick launch feature.
type package manager
select "tools->Nuget PackageManager-> Package Manager Settings"
In the options window that pops up. click "Clear All Nuget Cache(s)"
Right click solution and select Restore Nuget Packages.
Hope this helps.
I was facing an issue with NuGet package of Newtonsoft.Json as shown below:
I tried all possible solutions but none of the below mentioned ones worked:
Cleaning solution
Rebuilding solution
Clearing NuGet package cache
Finally I realized it had something to do with .NET Framework version targeted by my C# project. There was some mismatch it seems. The moment I upgraded the .NET Framework version of my project to latest, the Newtonsoft.Json package dependency and its reference came alive instantly.
Something I just noticed, and I'm not sure if this will help you or anyone else reading this, but this issue literally wracked my brain. The problem was that I was installing packages that I had created myself using NuGet Package Explorer on Windows.
It turned out that, I believe after updating NuGet Package Explorer, it was no longer putting DLLs that I included into the lib folder. Once I started manually adding the lib folder back into the package within Package Explorer, and then uploading to NuGet and reinstalling in the consuming project, that the reference would once again start to appear.
I'm not sure what caused this behavior - it could have been my own fault, but I literally just now figured this out - and consequently have to go back and re-do a whole bunch of NuGet package goodness that I've done over the past month. OUCH.
Hope this saves someone at least an ounce of pain.
None of the above worked for me.
What did work, was to edit the project file directly and delete the existing reference. When I reloaded the project, the package then showed up in references as a Nuget package.
I happened to come across the same problem. i tried all the possible solution but found the solution - just open the .proj file in an text editor and check the package Version and the HintPath in the Reference tag. Sometime there is an mismatch correct it then Visual studio will recognize. I hope everyone can save lot of time. Here is an sample to refer
<Reference Include="nunit.framework, Version=3.4.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb">
<HintPath>..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll</HintPath>
</Reference>
Migrating to PackageReferences worked for me for the projects that allowed it. My Asp.Net project could not be migrated, so I resorted to manually adding the references to the .csproj file