Unable to find NuGet packages despite packages being installed NU1101 - c#

I created my first C# application recently, and since buying a new computer I cannot get the application to start.
I am receiving 7 of the following errors Error NU1101 Unable to find package Microsoft.VisualStudio.Web.CodeGeneration.Design. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages clesson C:\Users\porkh\Desktop\WERK\Personal\c-lesson\clesson\clesson\clesson.csproj
Each with different packages missing.
Since this was a missing dependencies message I reinstalled visual studio 2019 with C# .net support again, yet I am running into the same error.
On StackOverFlow I read that I need to check my NuGet packages,
Here it shows every package that is "missing" in the error messages as installed.
I have also tried running dotnet run and dotnet restore but I get the same error messages.
I am extremely new to C# so sorry if I have missed the solution in other's answers. Any help you can give me I'd appreciate it.
A link to all of my project files here

In the image it says
Not available in this source
and the package source is set to Offline Packages. My best guess is, switching to an official NuGet Feed in the drop down to the upper right, will solve your problem. You also want to check, if the Nuget source is available (it should).
If not, click the Cog icon, and add it there with the name "Nuget" and the Url https://api.nuget.org/v3/index.json

Related

Dotnet CLI fails building after mv to other directory?

Currently, I'm doing my second day of my first internship at a smaller company where I have to build something in C#. Except from Unity, I've never used C# before so I'm kinda new in using it. I'm currently using it on Linux Ubuntu 20. So forgive me for this most likely beginner question.
I'm using dotnet-sdk to build calling "dotnet clean; dotnet build; dotnet ~/pathToDLL/etc/etc". I've finally got something working now, So I cloned the empty git repository from the company and used the mv command to move my directory with some working code to the git repo. Now, when I try to build it it gives the following errors:
/snap/dotnet-sdk/107/sdk/5.0.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5):
error NETSDK1004: Assets file '/home/oscar/
Tacho/card_reader/obj/project.assets.json' not found.
Run a NuGet package restore to generate this file.
[/home/oscar/Tacho/card_reader/card_reader.csproj]
It gives more or less the same error twice.
/snap/dotnet-sdk/107/sdk/5.0.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5):
error NETSDK1004: Assets file '/home/oscar/
Tacho/card_reader/obj/project.assets.json' not found.
Run a NuGet package restore to generate this file.
[/home/oscar/Tacho/card_reader/card_reader.csproj]
For most users reading this error, this is probably an easy fix. But as I said, I've zero experience using C# on Linux (or Windows) outside of the context of Unity. So any explanation and fix will be very much appreciated!
Oscar
solved
There was a space somewhere in the directory I copied my working code to. I removed this space (and everything before it) for this question because there was company sensitive information there which my boss didn't want to see end up on the internet. Because of the space (in the git repo name) Linux obviously had errors executing commands. Thanks to everyone for the help.
The error seems to indicate that a NuGet package is missing some files. NuGet is a popular library distribution system that is also built into Visual Studio. Even an empty repository may be referencing the package as a dependency or your own code may be using that it. If you are using Visual Studio you can do the following:
Enable package restore by choosing Tools > Options > NuGet Package Manager. Under Package Restore options, select Allow NuGet to download missing packages.
In Solution Explorer, right click the solution and select Restore NuGet Packages.
Your company might be using a private NuGet server though, so you will want to make sure you are connected to any VPN services. Also do not be shy about asking a co-worker about this issue. This is likely part of configuring your environment properly and not something you are expected to 'just know' as a new intern.

Unable to find package but package is installed (.NET / ASP.NET CORE)

we're using DevExtreme for ASP.NET and .NET core for a project.
I pulled the project that my partner made, which worked on his system, and I can't build. The error stating that it's unable to find the package
Error log
I've installed the DevExtreme onto my PC and restarted both the computer and the IDE.
Here's proof they're installed
here
First time posting on stack overflow so I'm not sure if my post etiquette is up to par, sorry.
Need help figuring out this error
Seems, it(DevExtreme.AspNet.Core) say "not available on this source"
The DevExtreme.AspNet.Core library is a part of DevExtreme. I guess Your account contains only the ASP.NET subscription, which does not include DevExtreme.
hope this helps:
https://www.devexpress.com/Support/Center/Question/Details/T524333/devextreme-aspnet-core-is-not-available-in-nuget-repository
The package DevExtream.AspNet.Core does not exist in nuget.org. You can always go to that website and search for packages on that website. Both your screenshots show that visual studio was unable to find this package too.
Visual Studio by default uses the source of your nugets as nuget.org. You would see this in the top right corner of your "proof" screenshot. In this screenshot, you can also see the text "Not available from this source" below DevExtream.AspNet.Core at the left. This is a visual studio telling you it is not installed.
In your first screenshot, the last error says the package is not found. The first two errors seem to be related to the last (if you don't have a package installed, it can't find the namespaces).
It seems like your partner's system used a different source for these NuGet packages. In your partner's NuGet package manager check for the nuget source used. You can click the settings icon to the right of the source dropdown to configure it. Check this link for more info.

Reference dll 's are missing from the solution after going for new work space or branching

I created the MVC application and build the solution in my local machine and it builds without error then I have uploaded that MVC application into TFVC. But, if i take a new workspace from the other developer machine or going for the Branching feature in TFVC, we have been endup with all the reference dll's which was showing deleted like below screen shot and the solution does not build successfully. We are not sure what its causing the issue. Please help us to resolve this issue. Thanks in advance.
Update
Actual problem i am facing here is, I run update-package -reinstall command in the Package Manager Console, it removed all the existing dll's and restored back all the dll and build successfully. But, After successful Build, I have checked-in the pending changes into TFS. But again if I am taking the new workspace from another developer machine, i am still endup with the same build error and missing reference like above screen shot again i have to go for the Nuget Package Restore. Is it a Correct approach? Appreciate your thoughts on this.
right click on the solution and select restore nuget package this may solve your issue then clean and build
check dot net framework version in both tfs and local version
you can also try
update-package -reinstall command to reinstall all referenced packages.
I think you should try restoring missing NuGet packages, check that the option is checked in VS Settings > NuGet.

Visual Studio restoration of Nuget packages through TFS

Today I ran in to a problem that took me a little while to figure out because of my apparent misunderstanding of how the Enable NuGet Package Restore worked within source controlled projects in TFS. So to start out with let me explain the issues that I have spent the last week or so troubleshooting.
On our TFS server, I created a build definition for continuous integration. When the source code is checked-in, the build server begins compiling the source and then fails due to not being able to fetch NuGet packages. I thought initially that it was due to Enable NuGet Package Restore being disabled, so I switched it on at the solution level and re-committed my code. The builds continued to fail. Without having admin access to the Virtualized Instance of the build server, and the admin being swamped lately I let moved on and decided I'd deal with it in a couple of weeks when my Sprint and his Sprint lightens up. Getting the build server up and running is not a must at the moment. I did however remove my local mapping to the branch in TFS, delete the local directory, re-map the source code and perform a fresh get and re-compiled the source without any problems. The NuGet packages downloaded just fine.
Today however we had a new-hire join the team. He pulled a fresh copy from TFS and encountered some SlowCheetah (for transforming our WPF App Configs) NuGet failures. We spent a good chunk of time today trying to figure out why his wasn't pulling down the files properly. After a little while, I right clicked on his solution and noticed that the Enable NuGet package Restore option was available. Even though on my solution, I had enabled it, his solution did not have it set up. I enabled it and immediately his solution compiled without error.
So now down to the primary question, if I enable the solution to restore packages why do I have to re-enable it on another box? I was under the assumption that by making sure Allow NuGet to download missing packages during build option is enabled in settings on all of the boxes, Visual Studio would automatically download the NuGet packages missing from my TFS source code. This confuses me and I would appreciate some clarity on how NuGet should work (and be restored) when packages are used in a project stored in TFS. We are not including any of the packages with our TFS check-ins because I though this feature was supposed to automatically work for the project.
Lastly, I am wondering if this is why my build server is failing to run my build definition. I am getting the NuGet errors and am not sure how to tell the build definition to download the NuGet packages. Is this something I need to do by modifying the build template, adding a sequence to download NuGet packages prior to running MSBuild or something?
Thanks in advance.
Edit 1 I would like to also mention that the NuGet .targets file is included in the TFS branch as well.
This is called Package Restore Consent and for the IDE you need to do it per user. There is a way to override per machine, but its easier per user.
For servers you can use the EnableNuGetPackageRestore environment variable with a value of 'true'
Find out more on: http://docs.nuget.org/docs/reference/package-restore

File contains corrupted data - Package Manager Console

I am trying to follow this article. There is a step which says you need to install XSockets.Sample.WebRTC via package manager console(PMC), this is where I got stuck. I have been getting an error which says File contains corrupted data, shown as below -
I went through this post
but none of the solutions worked for me. I could not find any solution to my problem. What am I doing wrong? How do I make it work?
Another question is, in the article that I am following, there is this picture which shows -
but I got nothing like LocalNuget in my package source. I got only two options - check the above image.
Why is this difference? Is there anything wrong with my visual studio installation?
The problem was with Nuget Package Manager Console.If anyone comes across this problem, then try and update the Nuget Package Manager version, worked in my case.
To update Nuget Package Manager click on
Tools -> Extensions and Updates -> Updates -> Visual Studio Gallery -> Nuget Package Manager.
I updated Nuget Package Manager version to 2.8 (latest till date) but same issues.
Finally, referring to solutions at http://nuget.codeplex.com/discussions/272453 I got the problem resolved.
By clearing package cache and disabling antivirus temporarily installation of XSockets.Sample.WebRTC via package manager console(PMC) was successful for me.
Try this:
Right click in the project -> Unload project
Then, right click in the .csproj and edit. Look for Xsockets.Sample.WebRTC (maybe is not there)
If it is there, remove it, and reinstall again after Load again the project ;)
I had a similar issue after using powershell to do a solution wide string replace. I wasn't careful to exclude .exe files from the command, and it altered the nuget.exe file in the .nuget folder. Upgrading Nuget Package Manager did not help, but replacing the nuget.exe with a version from another solution did.
An easy way to tell if this is your issue, is to run the suspect nuget.exe with a right-click, run as administrator and if it gives you an error that it's not compatible with your version of windows, than you know its busted.
i had the same error after recovering a solution the was deleted by mistake, solved the problem as following.
I closed visual studio then removed all packages from packages folder, when i opened the solution again the error message isn't there and VS asked me to restore missing packages, after restoring packages every thing is working fine :)
I recently got this out of the blue.
I needed to update to Package Manager console Version 2.8.60723.765.
Starting it displayed:
========================
NuGet Enable Package Restore Fix
========================
To fix package restore:
1. Please enable package restore in Visual Studio FIRST.
2. Run the command: Install-NuGetEnablePackageRestoreFix
3. Restart Visual Studio.
This should fix that pesky broken build you are experiencing.
Running
Install-NuGetEnablePackageRestoreFix
and Rebuilding fixed it for me.
During a package restore, my PC lost power. I also had the issue with nuget package manager:
File contains corrupted data
When I opened the Package Manager Console, I got this message:
Unable to read package from path 'Microsoft.OData.Core.6.15.0\Microsoft.OData.Core.6.15.0.nupkg'.
I solved it by simply deleting that package from the disk and when I opened package manager, the original error message was gone and I was able to restore the package I had deleted.
In my case, the Nuget Package Manager extension was already the latest version & also clearing up local cache didn't help either.
However, when I cleared the packages folder & rebuilt the solution - it fixed the problem.

Categories

Resources