Nuget package update - Microsoft.Data.SqlClient.SNI.x64 - c#

when restoring a locally created nuget package I receive the following error:
Failed to add reference to 'Microsoft.Data.SqlClient.SNI.x64'.
Please make sure that the file is accessible, and that it is a valid assembly or COM component
When I look at the nuget build I see the following
click to enlarge
The highlighted yellow "missing" dlls in the screenshot above do actually exist in the project.
I am using Visual Studio 2017 professional
Thanks for any help
Mark

Nuget package update - Microsoft.Data.SqlClient.SNI.x64
Please try the following steps:
1) close VS Instance, delete nuget.config file under C:\Users\xxx(current use account)\AppData\Roaming\NuGet.
2) delete .vs hidden folder under your solution folder, bin and obj folder then restart your project to test again.
3) Please try to create a new empty project in VS2019 and test whether you can install the package Microsoft.Data.SqlClient.
If you cannot install it, you should note that whether your VS or OS has broken. If the new project has no error, the issue is your project itself. You can try the above steps to troubleshoot the issue.
If the issue still persists in the new project,
You can try to repair VS or update VS to the latest version.
Also, try to update OS or use the System File Checker tool to repair missing or corrupted system files.
Besides, try another PC to test whether the issue persists.

Microsoft.Data.SqlClient.SNI.X64 or X32 files need to be removed from release folder before creating package.
Microsoft.Data.SqlClient.SNI.X64 will be added automatically while adding Microsoft.Data.SqlClient.
So, remove the dll before creating the package and then try installing it.

Related

Lost references in Visual Studio 2017 solution

I've been working on a project with a coworker and we're using Visual Studio 2017 as IDE and also Git to push the versions to VS repository. We had a few problems and decided to start a new project in Visual Studio with the content we already had.
The weird thing is: when cloned the repository to my computer and synched, some of the references were lost. A yellow triangle appears next to the lost references icons in Solution Explorer, and it doesn't have a path set like the ones that work. Also, inside Source > Repos, the project folder has all files, including the ones that are missing. I tried deleting the project and cloning it again, tried to download only the .zip file and starting the project offline, and also running VS 2017 as administrator (it appears this solved similar problems for others before) and nothing worked. My coworker (who pushed the project to the repo in first place) can compile normally and is not facing this reference problem.
Has anyone ever experienced this issue?
We're using VSTS with a git repository, and this happens all the time, especially when pulling updated solutions. I find a clean and rebuild fixes the problem.
You can run in the Package Manager Console the following command to clean up the nugget packages:
Update-Package -reinstall -ProjectName XYZProjectName
or run it for the whole solution:
Update-Package -reinstall
In my case after a merge with the master branch, I had conflicts in the project file (.csproj). When resolving the issue VS2019 automatically had unloaded the project file where those conflicts were and I didn't notice. A check for that might save time for someone.
I once experienced it when I was having a Visual Studio 2015 project open and then pulling new git commits. The new project I was pulling was was set up for Visual Studio 2017 though.
So my VS 2015 was open and dsiplaying the now VS 2017 project. I believe it only contained one nuget package, however this was not downloaded correctly and instead the package was displayed as a missing file.
Maybe this is happening for you too?
Same problem in VSC 2021 version 1.63.
Solution - Removed project folder from workspace:
CTRL+Shift+P, search for and execute the
"Workspace: Remove Folder from Workspace" command.
Then reopened the project folder and was OK

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.

Restoring all Nuget Packages in a Visual Studio 2015 Solution

I have read many of the answers on SO and NuGet (and the Internet in general, really), but I can't seem to overcome the problem I am having with NuGet package restore in Visual Studio 2015. I have the following scenarios.
Solution A Structure
--Project A
If I open and build Solution A I see the dialog box that shows the nuget package restore progress and the solution builds successfully.
Solution B Structure
--Project A
--Project B
However, assuming that I have never built Solution A (i.e. fresh pull from TFS), if I open and build Solution B I see the dialog box that shows the nuget package restore progress, but the build fails because Project A fails to build.
What appears to be happening is that that NuGet is restoring the packages for Project B, but not for Project A thus the build failure. To the point, if I look at the references for Project B all of the NuGet references have resolved, but the references for Project A are still broken.
A few points:
I have disabled source control integration for NuGet so I am not checking in the Packages folder.
Each project has its own packages.config file
The build order in Solution B is Project A then Project B
Thoughts would be greatly appreciated.
By default, NuGet creates the solution's packages folder in the solution root, and each project references its package DLLs to that "local" packages folder. In your example, if you open the .csproj file for Project A, you'll probably see that the reference path is something like ..\packages\[package name]\[etc].
So when you do a fresh pull from TFS and build solution B, Project A can't find its DLLs because c:\workspace\Solution A\packages doesn't exist yet (or whatever the absolute path is on your machine).
To correct this, use a shared package folder, created at c:\workspace\packages. To do this, you have to add an additional node to the NuGet.config in each solution (see https://docs.nuget.org/consume/nuget-config-file for details; I am also assuming you have a NuGet folder at c:\workspace\Solution A\.nuget):
<config>
<add key="repositorypath" value="..\..\packages" />
</config>
I used a relative path here, but you can use an absolute path as well, and the documentation says you can use %HOME% as well.
Do this, then restart Visual Studio. The next time you open the package manager, it should ask you if you want to restore missing packages, and assuming you click yes, it will put them in the new location. The last step is to edit the .csproj file and change all instances of ..\packages to ..\..\packages (or you can uninstall and reinstall the package, but I find editing the .csproj a lot faster).
To restore nuget packages do following steps:
Change target framework in project properties
Clean project
Set previous target framework
Rebuild project
I hope, it will help.
Taken from OPs question
howcheng's answer is generally correct with some caveats. After implementing the changes howcheng suggested, I was able to build all of my solutions locally using a central 'packages' folders that all projects look at, regardless of solution. The problem that I ran into though was that when I checked these changes in to TFS, my CI build kicked off and failed!
My CI Build Definition builds both Solution A and Solution B as part of the default XAML process template, not a .proj file. The errors that I was seeing seemed to indicate that Solution A was restoring its packages, but Solution B was not. If I logged onto the build server and opened Solution B in VS 2015 everything worked fine; after Googling for a couple of hours I came across this article which ended up leading me to my answer.
I am developing in Visual Studio 2015 but I am using TFS 2013 for source control and builds. Despite the fact that I have Visual Studio 2015 installed on the build server, MSBuild still references the version of NuGet that shipped with TFS 2013 and NOT with the version included with VS 2015. Once I ran nuget update -self from the TFS Tools directory my build worked correctly.

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.

The imported project "C:\Microsoft.CSharp.targets" was not found

I got this error today when trying to open a Visual Studio 2008 project in Visual Studio 2005:
The imported project "C:\Microsoft.CSharp.targets" was not found.
Open your csproj file in notepad (or notepad++)
Find the line:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
and change it to
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
This is a global solution, not dependent on particular package or bin.
In my case, I removed Packages folder from my root directory.
Maybe it happens because of your packages are there but compiler is not finding it's reference. so remove older packages first and add new packages.
Steps to Add new packages
First remove, packages folder (it will be near by or one step up to your current project folder).
Then restart the project or solution.
Now, Rebuild solution file.
Project will get new references from nuGet package manager. And your issue will be resolved.
This is not proper solution, but I posted it here because I face same issue.
In my case, I wasn't even able to open my solution in visual studio and didn't get any help with other SO answers.
For me the issue was that the path of the project contained %20 characters, because git added those instead of spaces when the repository was cloned. Another problem might be if the path to a package is too long.
In my case I could not load one out of 5 projects in my solution.
It helped to close Visual Studio and I had to delete Microsoft.Net.Compilers.1.3.2 nuget folder under packages folder.
Afterwards, open your solution again and the project loaded as expected
Just to be sure, close all instances of VS before you delete the folder.
This link on MSDN also helps a lot to understand the reason why it doesn't work. $(MSBuildToolsPath) is the path to Microsoft.Build.Engine v3.5 (inserted automatically in a project file when you create in VS2008). If you try to build your project for .Net 2.0, be sure that you changed this path to $(MSBuildBinPath) which is the path to Microsoft.Build.Engine v2.0.
I used to have this following line in the csproj file:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
After deleting this file, it works fine.
If you are to encounter the error that says Microsoft.CSharp.Core.targets not found, these are the steps I took to correct mine:
Open any previous working projects folder and navigate to the link showed in the error, that is Projects/(working project name)/packages/Microsoft.Net.Compilers.1.3.2/tools/ and search for Microsoft.CSharp.Core.targets file.
Copy this file and put it in the non-working project tools folder (that is, navigating to the tools folder in the non-working project as shown above)
Now close your project (if it was open) and reopen it.
It should be working now.
Also, to make sure everything is working properly in your now open Visual Studio Project, Go to Tools > NuGetPackage Manager > Manage NuGet Packages For Solution. Here, you might find an error that says, CodeAnalysis.dll is being used by another application.
Again, go to the tools folder, find the specified file and delete it. Come back to Manage NuGet Packages For Solution. You will find a link that will ask you to Reload, click it and everything gets re-installed.
Your project should be working properly now.
I got this after reinstalling Windows. Visual Studio was installed, and I could see the Silverlight project type in the New Project window, but opening one didn't work. The solution was simple: I had to install the Silverlight Developer runtime and/or the Microsoft Silverlight 4 Tools for Visual Studio. This may seem stupid, but I overlooked it because I thought it should work, as the Silverlight project type was available.
In my case, I opened my .csproj file in notepad and removed the following three lines. Worked like a charm:
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props')" />
ok so what if it say this: between the
gt/lt signs
Import
Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v3.0\Microsoft.Silverlight.CSharp.targets"
/
how do i fix the targets error?
I also found that import string in a demo project (specifically "Build your own MVVM Framework" by Rob Eisenburg).
If you replace that import with the one suggested by lomaxx VS2010 RTM reports that you need to install this.
For errors with Microsoft.WebApplications.targets, you can:
Install Visual Studio 2010 (or the same version as in development machine) in your TFS server.
Copy the “Microsoft.WebApplication.targets” from development machine file to TFS build machine.
Here's the post.
This error can also occur when opening a Silverlight project that was built in SL 4, while you have SL 5 installed.
Here is an example error message: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.CSharp.targets" was not found.
Note the v4.0.
To resolve, edit the project and find:
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
And change it to v5.0.
Then reload project and it will open (unless you do not have SL 5 installed).
For me, the issue was the path.. When cloning the project that had a space in the name. The project folder was named "Sample%20-%205" instead of what it should be: "Sample - 5"
Opening the project was fine, but building failed with
Could not find the file:
/packages/Microsoft.Net.Compilers.1.3.2/tools/Microsoft.CSharp.Core.targets
I deleted the obj folder and then the project loaded as expected.
Sometimes the problem might be with hardcoded VS version in .csproj file. If you have in your csproj something like this:
[...]\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets"
You should check if the number is correct (the reason it's wrong can be the project was created with another version of Visual Studio). If it's wrong, replace it with your current version of build tools OR use the VS variable:
[...]\VisualStudio\v$(VisualStudioVersion)\WebApplications\Microsoft.WebApplication.targets"
I ran into this issue while executing an Ansible playbook so I want to add my 2 cents here. I noticed a warning message about missing Visual Studio 14. Visual Studio version 14 was released in 2015 and the solution to my problem was installing Visual Studio 2015 Professional on the host machine of my Azure DevOps agent.
After trying to restore, closing VS, deleting the failed package, reopening, trying to restore, multiple times I just deleted everything in packages and when I did a restore and it worked perfectly.
it seems now that the nuget packages folder has moved to a machine wide global cache, using VS2022
For me the issue was that the solution was to deep into the documents folder and on windows 10 there is a path character limit which was reached. As soon as I moved the solution folder up couple of folders this fixed the issue.

Categories

Resources