I reinstall my whole system, visual studio, and packages (control suite, crystal reports and so on), and download my solution from team foundation. When I try to rebuild it, I get missing references warning and it does not work :
When I check, all nugets package are (physically) here. The thing which annoys me the more is that even System, System.Data,... are in warning state. Anybody already had this problem (and a fix !) ?
I have a lot of project in my solution, and there's only a part of them which screw up (sorry for my english, it is not my native language).
Try this, nuget package restore.
https://learn.microsoft.com/en-us/nuget/consume-packages/package-restore
Have you tried adding them manually under Solution Explorer->right-click your project node then-> click Properties. Click on the References tab and re-add them to the project.
Have a look at https://msdn.microsoft.com/en-us/library/ayds71se.aspx for more suggested solutions. Hope this helps
I had a fix which was to copy all files from my previous disk which were not in TFS and it fixed it all. I am a bit ashamed because I skipped to list them to add util files in TFS. Thanks all for your time.
Related
I am working on a C# program that utilizes EntityFramework, I've cloned the program from git repo, but now it is having that dreadful Metadata file 'EntityFramework.dll' could not be found error. I have searched and tried countless suggestions for this kind of problem, but none worked. I've already checked that the reference to EntityFramework.dll in the .csproj files are correct and it is definitely there under the packages\EntityFramework.6.2.0\lib\net45\ folder. So I am not sure what else to try.
Ok, I've resolved this problem. Here is what happened. Apparently, when cloning into local directory, one of the folder on the path has a space in its name (like My DSS), and this nuget issue seems to indicate the inability of nuget to find package with space in path. So, once I changed that folder's name to MyDSS, it compiled successfully.
please have a look on the bin folder ,sometimes the dlls do not exist there .
This typically happens when teams check in files that should not be checked in (such as the .suo file) or have "optimized" their builds to exclude rarely changed projects. (unticking projects in the configuration manager.)
Another common cause for missing references is when devs reference a dependency from a /bin folder instead of the packages folder, but it sounds like you've confirmed that isn't the case.
Other questions such as Metadata file '.dll' could not be found list a number of things to check, so your problem will surely be one of these. Try building each project individually, working from projects that have no project dependencies upwards to the main application project(s). Ensure they're running the same .Net versions, check the solution NuGet packages for dependencies with "multiple versions" and consolidate these so that the solution is using a single version of each dependency. (generally good for cleaning up) Also look at .config files for version re-directs that sometimes get zombified in source control.
In Visual Studio, on top, click on Build -> Configuration Manager. Make sure that the build checkbox next to your project is checked. In case it already is, uncheck it and then make it checked again. Clean your Solution and Build it again after this.
I get this as a warning when I build the solution. The weird part is that I removed those references long ago when I realized I didn't need them.
"Found conflicts between different versions of "System.Somenamespace.AnotherNamespace" that could not be resolved
I tried a Clean Solution then rebuild but no difference. I checked the solution and project files as well to see if there was a leftover reference but nothing. How do I clean this up?
Note: this is VS2017
Make sure nuget packages you use do not have discrepancies in their version. if so, you will either need to do assembly rebinding or use the exact same version across the solution. You can use the later by means of the “Consolidate” of the nuget package manager at the solution level.
I have a Visual Studio Solution (multiple projects) which was able to build on another computer in the past, that can't build after being pulled with Git on a new computer. The IDE (VS2017), platform target (Any CPU), .Net Framework (.Net 4.6.1), ... and everything else should be the same, yet it gives a few "The type or namespace name 'nameOfTypeOrNamespace' does not exist in the namespace" errors. There're also a few "Metadata file 'pathToFile.dll" could not be found" errors. Example screenshot:
Most of the missing assembly's are self-written but there are a few which are thrid party, as seen in the solution explorer. I also don't seem to have a reference folder in the solution anymore:
I know there's already a few questions involving missing namespaces, but none seem to match my particular case. I've already checked references and namespaces but can't seem to find the problem (no typo's eithersince it worked before). It's probably really hard for someone to find the problem without the project, which I can't share, so my question:
How should one best search for the solution?
I've also checked my .gitignore file and verified that it shouldn't have caused this issue.
Update as said in the comment section: I'm using Nuget but the Restore Nuget Packages option does not work out.
I currently solved this issue by doing the following:
Remove packages from the .gitignore-file
Open a cmd and type the following Git commando's (be sure to commit all your changes first since you might lose them by executing following commands):
a. git rm -r --cached . (clears the cache so that Git can detect changes)
b. git add . (adds all changed files)
c. git commit -m "Fixing the packages issue" (commit the changes)
Keep in mind that this is only a quick fix or a hack and that this doesn't actually solve the issue.
#Wouter's solution is working but as he said it's not optimal way and cause huge amount of source control storage occupied as well as increase download and upload size in push and pull(Checkin and Checkout in TFS).
To restore packages if 'Restore Nuget Packages' not works, use this solution:
From Tools menu in Visual studio, chose NuGet Package Manager--> Package Manager Console
and run this command:
Update-Package –reinstall
I hope It works.
Windows 8.1 Enterprise x64, Visual Studio 2015, MVC 5, EF 6, VS Online using git
I'm a relatively new developer with Visual Studio (about nine months), and ever since I started I've had an incredibly difficult time with references and NuGet packages. All of my references were working correctly on Friday when I shut my computer down for the weekend. I didn't touch the computer at all the entire weekend, now I've booted up today and I have a ton of reference errors:
(There are 6,262 errors total but I obviously can't screenshot the entire thing.)
Like I said, this sort of problem occurs very often, and it's incredibly frustrating. Things I've tried:
Ensure all references throwing the errors actually are referenced
Un/reinstall the packages throwing the errors in NuGet
Completely delete the contents of the packages folder and let NuGet restore them (all reinstalled, views have the same errors as before)
Ensure every single reference is set to Copy Local
Close the solution, delete all bin and obj folders, reboot computer, clean, rebuild
Ensured all necessary references are in the relevant web.config (either inside Views or at the root)
Check for NuGet option to restore missing packages (did not appear, all packages are in my local packages folder)
Other things on SO that I'm sure I've forgotten to list here
I'm at my wits' end with these packages and references. It's a different fix every time, and this time I can't figure it out. Am I missing some obvious fix, something I overlooked? Is there a way to somehow take a backup when this is working and restore it whenever things break? Any ideas whatsoever, whether helping with the current problem or for fixing the underlying problem, would be very much appreciated.
Additional note
The problem is NOT only with views--controllers are also throwing errors. Specifically:
The type or namespace name 'Controller' could not be found (are you missing a using directive or an assembly reference?)
(It literally says Controller, that's not something I changed for privacy or whatnot.)
These are thrown despite the fact that I have using statements for all of the necessary namespaces. The using statements themselves work properly, but the error is thrown in the code. The automatic fix suggested is to manually reference everything: for example, var sb = new StringBuilder(); wants me to change the line to var sb = new System.Text.StringBuilder();. Testing that fix does not correct the problem, the same error is thrown but on System instead of StringBuilder.
Additional requested information
I use git with VS Team Services (but packages are ignored with .gitignore).
I and one other person work on this, but the other person hasn't touched it at all (not even pulling from the remote repo) in several weeks.
References in the .csproj file are in the format ..\..\..\packages\ (correct for the location relative to the .csproj file).
Targeting .NET 4.6 (always have been, that's not new)
All references resolve, no exclamation marks in the references list.
New Projects
There is one single thing you need to do in order for packages to work correctly with git:
When you create a repository, make sure you add a .gitignore tailored for Visual Studio development. You can search google for such a file or take it from here.
This will make sure you don't commit anything that will cause problems later.
This should solve a lot of the problems that usually happen when you check in packages to a code repository. You can add/remove packages and upgrade packages and also be able to clone the repository to a new machine and packages will be restored automatically.
Existing Projects
This is good for new projects. If you already have a project with a great big mess, then it is very hard to fix it since Visual Studio keeps package versions in several places - packages.config and app.config (and web.config where relevant).
Option 1 - Fix the current project
You can remove all packages (remove all the references from all projects and delete the package contents).
Make sure that the packages no longer appear in any file (e.g. packages.config or app.config). Now add the .gitignore and then start adding the packages back.
Option 2 - Create a new project
If it doesn't work, start a new project, add the .gitignore, transfer all the code (only your code) and install the packages.
I'm not quite familiar with how Git works in VS, but I recall one time recently when using TFS that unbinding the solution from source control, fixing all packages, cleaning and re-building before binding it again solved a bunch of issues regarding NuGet references.
I apologize if Git works way different within VS.
I am trying to get the async nuget package for .net 4.0 to work but it doesn't seem to work. Ive uninstalled the package, restarted VS 2013, and reinstalled the package about 10 times now. Ive tried manually copying the file and right clicking add > add existing.
Here is the thing I get the following error each time...
Could not load file or assembly 'Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
So for some reason it is looking for version 1.0.12 but i have only ever installed version 1.0.168 (the latest) so I have no idea on earth why it would be looking for version 12 and I cant find where this setting would be. I tried the packages.config file but it lists it correctly at version 1.0.168
what the heck!? how can I tell this to look for version 1.0.168 instead!! Please help me!
Usually this happens when there is an issue with packages.config. It happened to me a couple of times in the past. Just review your packages.config and make sure that its definition matches with the version you need.
If packages.config is not the issue you can try:
Removing the nugget from the solution (right click on the solution and click manage nugget packages for solution) and re-installing it.
Update nugget packages in all your projects to require the same version of the assembly. Maybe another project is dependent on the old version.
If the reference that you have in the project is for the wrong version, then FIRST uninstall the nugget, then remove the reference from the project and then try to either re-install the nugget, or manually reference the correct assembly.
I also forgot to mention that you can also remove the entry in packages.config, but this is not a good solution (unless you are 100% sure you will only use this library from one assembly), as it will cause problems when difference projects in your solution will need to reference that assembly.
I had a similar issue, where VS insisted on using a specific version, which was not available anymore.
Restoring and rebuilding did not seem to help.
Lastly, I went for msbuild dirs.proj and that resolved the issue for me.