So im downloading a project at home from work over team foundation server. I download the project and it won't compile because of the error. Warning 2 The referenced component 'EntityFramework' could not be found. Could anyone offer guidance in how I can get entity framework to work. I installed nuget package.
Thankyou
I suggest you to check:
1) "Allow NuGet to download missing packages during build" ticked
Tool --> Options... --> Package Manager --> General
2) "Project selected" ticked
Solution Explorer --> right-click on the solution/project --> Manage NuPackages
3) Rebuild Solution
EDIT
For completeness I would like to add that if you are working with a CI system (e.g. Jenkins) or you are using MSBuild on the command line, you need to select Enable NuGet Package Restore to make it work:
Enable NuGet Package Restore http://docs.nuget.org/docs/Workflows/images/enable-package-restore.png
I had the same problem. I solved it like this:
Choose References > Right-click > Add Reference ...
Choose Browse tab
Find your Project Folder > packages > EntityFramework.4.1.10331.0 > lib
Choose EntityFramework.dll
Click OK
This happened to me, after I moved projects to a subfolder.
Then, the relative paths to the packages folder were not correct anymore.
Got errors like that:
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\NETStandard.Library.2.0.1\build\netstandard2.0\NETStandard.Library.targets. PROJECTNAME D:\VSTS\TEAMPROJECT\src\PROJECTFOLDER\PROJECTNAME.csproj
Fixed it by editing the *.csproj file and corrected the relative paths, in my case from ..\packages to ..\..\packages
Also make sure to check the paths under
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
There are good ways suggested by the developers, you may also try this solution to solve your problem.
In your case your project has a reference to the EntityFramework library, but library it self is not available to you project. You may try either the following:
If you have NuGet package manager:
Click on Project-> Manage NuGet Packages. It will open following window.
Find the EntityFramework and click Install.
- Alternatively, Download the EntityFramework library to your computer, then
Right-Click the Prject-> Add References...-> Browse-> Locate your
EntityFramework library-> Click OK
- Optionally you may use package manager to install library reference, check this link package-manager-console (Note: This might require NuGet Package manager)
I solved this issue by adding Entity Framework reference (Add ref) under C:\ Prog Files\Entity...\Binaries\Entity Framework.dll into my project. Hope this helps!
An old thread, but for anyone that this may help..
What worked for me was to go to the 'Packages' folder in the root of my solution and delete the EntityFramework.6.4.4 folder.
Then, go to Manage Nuget Packages menu option, and this banner pops up:
After pressing Restore the missing reference was restored.
Related
I am trying to write a C# interactive script (.csx) that needs to use a NuGet package, but I must be overlooking something fundamental because I can't get it to work.
I tried adding a project.json that refers to the package, and it gets installed into the global packages dir when I nuget restore, but it seems the #r directive does not look there. I failed to find a relevant documentation on how the #r directive work (most docs seem to deal with the similar but different project called ScriptCS).
How do you write a csx script that references NuGet packages?
Dotnet Script has support for referencing Nuget packages in CSX files:
#r "nuget: AutoMapper, 6.1.0"
https://discoverdot.net/projects/dotnet-script#nuget-packages-1
C# Interactive can't reference NuGet packages, but scriptcs can.
This wiki entry has a note for the Interactive Window saying that you need to reference directly the NuGet DLL. So you could use the absolute path to the DLL in the global packages directory. It's not ideal, but should work.
Very simple from Visual studio UI:
Right click the project, Click Manage NuGet Packages
Selected the NuGet Package from the list in Browse or Installed tab and click the nuget.org URL
URL will lead to this webpage, Go to Script and Interactive tab, then simply click the copy button and paste it in your CSI in Visual studio or *.csx file
The solution is quite simple if you have ever worked with FSharp before, but the main
solution is:
#r "nuget:Newtonsoft.Json"
Above gets the latest package version. But if you want to specidy a version this works.
#r "nuget:Newtonsoft.Json,1.20"
If you happen to be working with external nuget sources, you should initialize that source with.
#i "nuget:http://example.com"
for sources on the web and
#i "nuget:C:\Nuget"
```for sources on your local file system
I am getting the following issue while compiling my project. It is a MVC 5 application. Here is the error:
Severity Code Description Project File Line Suppression State
Error This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props. WikidoctorAdmin E:\My Projects\Wiki-Doctor\Wiki-Doctor.com\Wiki-Doctor.com\WikidoctorAdmin\WikidoctorAdmin.csproj 2107
Please help me how to solve this error.
I had the same issue and solve it by opening the project in a text editor and deleting the following section:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
I didn't need Nuget for this project.
Hope this helps.
You can fix this one of two ways:
Under Tools/Nuget Package Manager:
Menu screen capture
1) Choose the first option (Package manager Console).
Package manager console window will appear (Usually toward the bottom of the screen)
You should see a button that says "Restore Missing packages"...Click it.
This method will work for this project only...and you will have you redo this for each project with missing packages
2) Choose Package Manager settings
Make sure the check box that says "Allow Nuget to download missing
packages" is checked
Re-build your solution
Nuget will automatically download missing packages from now on. This is easier, but might not always be what you want.
The name of the project is longer than 248 characters. You need to rename the path under 248 characters, then open solution and rebuild and the nuget will be updated.
that worked for me having similar error -
go to your complaining project references - find references with yellow marks
open solution nuget package manager and 'reinstall' nuget packages which have those yellow marked dlls.
easy way to reinstall one by one - select nuget in the right, in the left upper portion there would be checked projects.
in the left lower portion - select one version down, install, select one version up (your needed version), install - repeat for all questioned nugets
I've got the same problem, and I solved this way:
- erase every obj and bin folders under the solution projects,
- using the NuGet Package manager to restore and update all packages.
Hope it helps.
When I creating webtests I want to add "Web Test Plug-in" I get message box with information that one of my nuget library is missing.
Whole my solution is compilable and this "missing" library exists as entry in csproj and config files. After compilation of test project this library is inside "bIn" folder. I check under dotPeek version, publicToken etc is correct.
My question is where webtest project look for this library?
If the webtests is missing a dependency:
Right click solution > manage nuget packages for solution > click manage on the package in question, then select your webtests project > ok.
If the webtests has a broken link to a dll :
Look at the references, and see if there are any yellow triangles, and where they point to. If that is the case, delete that reference and re-attach.
I am trying to restore the missing nuget packages and it keeps giving me this Error:
An error occurred while trying to restore packages. Please try again.
Any experience solving this?
How can I find out what exactly is causing the error?
This is how I fix my issue:
First, I clear my Package Cache:
Second, I make sure I have the right path source and click the available package source:
Make sure you upgrade to the latest NuGet (http://docs.nuget.org/docs/start-here/installing-nuget).
Make sure you're doing package restore "The Right Way" http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html
That should resolve the issue.
If you don't want the package, just double-click your packages.config, find the line which refers to the package you want to get rid of, and delete that line.
Then, if you do want the package you could probably just redownload it using nuget and it'd probably resolve itself.
I had a similar issue with the Microsoft.Bcl.Build.1.0.14 NuGet package. My solution to this was to
Close Visual Studio
Remove the package folder with Explorer (or better only move it to another location)
Start Visual Studio
Go to the NuGet package manager and click Restore
I resolved the same issue by downloading the latest version of NuGet (really easy install, quick download): http://docs.nuget.org/docs/start-here/installing-nuget
(Definitely a beginner's answer here, but I'll leave it since I didn't find this anywhere else.) Make sure that nuget.org hasn't been unchecked from your package sources.
Tools. Options. Nuget package manager. Package sources. Ensure "nuget.org" is checked.
The problem in my case
In my case, we have developed our own NuGet packages. For some indescribable reason when I opened the solution, When I open solution, that has a previous version of NuGet packages that is deleted from origin or removed or unreachable for any reason. This make it unable to build the projects containing specific NuGet packages. I tried to install/reinstall/upgrade the NuGet package with out luck getting following error (see the image below), I did also try all possible answers here, and ensured the package was there, but no luck.
An error occurred while trying to restore packages: Unable to find version xxx..etc.
The solution for my case
Close your solution and find the path of the solution
Open all your projects .csproj files with notepad editor, that contain the packages that have the issue and remove all references that is shown in the error message, looks like this and save:
<Reference Include="Xxx, Version=30.0.0.16927, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xxx.35.1.122605\lib\net461\Xxx.dll</HintPath>
</Reference>
In each folder where your .csproj is located, you find packages.config file, open it with notepad editor and remove all packages that is shown in the error message, looks like this and save:
<package id="Xxx" version="35.1.122605" targetFramework="net461" />
Start your solution, the error now should disappear, but you can not build because we have removed references and packages. So now you should be able to install your missing packages in fresh. When done build and all should work. Enjoy :)
I had similar issue, i found out it was due to my nuget cache.
Command to clear cache: dotnet nuget locals all --clear
After cache is cleared try restoring.
i fix this problem by moving the project folder to another one with less characters (local path was to long) i hope it helps some one
For me I cloned a solution (vs2015/NuGet3.4) that had a nuget dependency on a pre-release package that had been superceded. Nuget failed to restore the pre-release and wouldn't let me either uninstall or upgrade it. I frigged it by manually editting packages.config to target an older non-pre-release of the package, which I could then upgrade to the version I wanted. HTH
Just in case it helps someone else, I had this issue in a .NET Standard project where I had defined the target frameworks incorrectly:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.3;netstandard2.0;net45</TargetFramework>
</PropertyGroup>
...
When it should have been the plural TargetFrameworks (not TargetFramework):
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0;net45</TargetFrameworks>
</PropertyGroup>
...
For me non of those things mentioned above work.
I solved this issue by deleting packages.config in each project of my solution and then reinstalling all Nuget packages
In my case, I had another package source added which was like this.
I just removed this source from the NuGet package manager and rebuild the solution, it started working for me.
Go to TOOLS under OPTIONS select NuGet Package Manager
General, Select Everything
Package Source, Select all required Source
Hit OK. Done you must be good to go.
I recently started using NuGet to manage external packages. For now I have only needed it for NLog.
Everything works fine when I Build the project in VS 2012. However, I am trying out TeamCity as a CI server (I'm fairly new to CI) and it is giving me the following error:
[Csc] SomeNamespace\SomeClass.cs(10, 7): error CS0246:
The type or namespace name 'NLog' could not be found
(are you missing a using directive or an assembly reference?)
(this error is repeated throughout where ever I use NLog)
Now I did not include the 'packages/' folder in SVN, since I thought it was good practice not to include binaries and let MSBuild in TeamCity download these on its own. However it's clearly not doing that. I DO include the 'packages.xml' file in SVN.
What can I check to see what is going wrong?
Update
Thanks to #DavidBrabant I was nudged in the right direction. However, I now get the following error in TeamCity:
Package restore is disabled by default. To give consent, open the Visual Studio Options dialog,
click on Package Manager node and check 'Allow NuGet to download missing packages during build.'
However I'm not in Visual Studio but TeamCity, so I do not know how to set 'consent' to true! I tried to set RestorePackages to 'true' in the NuGet.targets file:
<RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages>
but this didn't work.
Update 2
To make it work I also set the following property NuGet.targets:
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'true' ">false</RequireRestoreConsent>
This made the build run succesfully!
The enable package restore feature built into NuGet allows you to very easily set up the pre-build part of the workflow. To do so, right-click the solution node in Visual Studio’s Solution Explorer, and click the Enable NuGet Package Restore option. Note that you need to have the NuGet Visual Studio Extension installed on your system. If you do, and you still don’t see this menu item appear, you either already enabled this option, or you have a folder named .nuget in your solution directory.
After having set that option, you can now delete all sub-folders of your package installation directory, by default $(SolutionDir)\packages, except for the repositories.config file, and your solution should still compile properly. During compilation, you should see NuGet installation traces in the Visual Studio output window, and you should see the required NuGet packages reappear in the package installation directory as well.
Also see Using Nuget without committing packages.
Just to reiterate on update 2. If you stumbled here looking for a quick fix to TeamCity not downloading NuGet packages, try changing this line
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
to this line
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'true' ">false</RequireRestoreConsent>
in your NuGet.targets file and it should work.
In TeamCity v8 I was able to solve the "restore package" error using an environment variable in TC.
See:
http://johanleino.wordpress.com/2013/03/19/using-teamcity-for-asp-net-development-part-2/
and
http://confluence.jetbrains.com/display/TCD7/Configuring+Build+Parameters#ConfiguringBuildParameters-SystemPropertiesandEnvironmentVariables
Setting env.EnableNuGetPackageRestore to "true" as an environment variable at the project level will fix the problem for all build configurations. Feels a little bit better doing this than editing the NuGet.targets file imho.
Take a look at this post: http://johanleino.wordpress.com/2013/06/17/making-use-of-teamcitys-nuget-capabilities-part-2/
As described there I added first build step "NuGet Installer", made some coinfiguration and now packages are automatically restored.