I have a multi-project solution with Prism Nuget packages installed in several projects. I then attempted to add a Prism Mef extensions package to one of the projects using the Nuget Package Manager UI (I have already added it to one of the other projects).
The first time I attempted to add the package, it failed to install one of the dependencies, no specific error reason, just "failed". So, I installed it a second time, all seemed to be fine, no errors reported, but a few of the references did not resolve.
So, I uninstalled the package and all dependencies and installed it again. Again all appeared fine, but more references do not resolve.
I have tried uninstalling and installing the package more times but get the same result every time now.
I have had this problem many times and I know its not specific to the Prism package as I've had it with loads of different packages.
I think its just a major bug with Nuget, but I'm hoping somebody will know an easy way to fix it. I think I usually have better success with the Nuget console, but I find it more effort to use.
I've done some searching online and not really found a good explanation of the cause of the problem or a way to resolve it.
Somebody at work completely refuses to have anything to do with Nuget as he has so many of these issues, but I am determined to make it work!
Within the Package Manager Console run the following command:
Update-Package -reinstall
This will reinstall each nuget package within that project which should resolve any missing references.
If you know you're missing a specific reference:
Update-Package -reinstall <Package-Name>
I just closed Visual Studio and reopened it and references are resolved...!
You need to follow this procedure.
1. Update-Package -reinstall
2. Restart visual studio.
You may want to check the .NET version of the package vs. your project.
I had an instance where my project was .NET 4.6.1, and the package I was attempting to install was using version 4.6.2. After updating my project to the same .NET version, the reference showed up.
I recently encountered this error on visual studio 2012, solution for me was to delete .nupkg file from nuget cache. Nuget cache location can be found from nuget settings > general > browse.
Note: I did not clear cache, I just deleted a specific file from cache directory and reinstalled the nuget package.
Delete all the <assemblyBinding> references from your .config file, then run this command from the Nuget Package Manager:
Get-Project -All | Add-BindingRedirect
This is how I fixed it.
I was working on a legacy .NET framework project (using <Reference Include... rather than PackageReference). The .dlls were referenced with a relative path that wasn't being resolved.
Fixed by changing to absolute paths, building, then changing back to the original relative paths.
For example:
<Reference Include="My.Package">
<HintPath>..\..\packages\My.Package.dll</HintPath>
</Reference>
Changed to:
<Reference Include="My.Package">
<HintPath>C:\Users\will\Documents\MySolution\packages\My.Package.dll</HintPath>
</Reference>
Then built and changed back to the relative path and the build still worked.
In our case, on one machine VS was holding onto an old version of a dependency, so references to newly added methods in the dependency were not resolving (even when package manager was reporting the latest version installed). The solution was to restart visual after uninstalling the dependency, then install again.
Related
On the same code branch we are successfully building on one machine, but on another we get this:
Error Multiple assemblies with equivalent identity have been imported: '...\src\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.2\Facades\System.Xml.ReaderWriter.dll'. Remove one of the duplicate references.
How can we resolve?
I ultimately solved this by updating Visual Studio to the latest
Using MSBuild 15 solves the problem.
MSBuild 15 is part of the .NET Core SDK or can be downloaded using the Build Tools for Visual Studio 2017.
I suspect that you have both a directly referenced (via the GAC or file system via Browse...) dll and a Nuget package in your project.
Best to try uninstalling the Nuget package, and then check your references and uncheck any remaining references to System.Xml.ReaderWriter.dll, and then install your Nuget reference again.
UPDATE
For reference, a similar error was encountered with System.Threading when an EntityFramework package was renamed. Perhaps one of your packages has a newer version or has a renamed namespace? Or maybe you have incompatible versions of .NET Standard?
Solved the "Error Multiple assemblies" problem by uninstalling Xamarin from computer and Visual Studio 15.
Followed this instruction:
https://developer.xamarin.com/guides/cross-platform/getting_started/visual_studio_with_xamarin/troubleshooting/uninstall-xamarinvs/
My problem occured when updating asp.net nuget packages from version 1.0.0 to 1.1.0.
See https://github.com/dotnet/corefx/issues/14050
This explains that in v4.3.0 of the nuget package it requires using VS 2015 Build tools Update 3 or later.
If you can't upgrade, downgrade the package to v4.0.11.
Made the following change to .csproj, which did the trick:
<PackageReference Include="System.Reflection.Emit">
<Version>4.3.0</Version>
<ExcludeAssets>All</ExcludeAssets>
<IncludeAssets>none</IncludeAssets>
</PackageReference>
In case someone comes looking for another answer. Can happen (6/6/2018) due to a package reinstall ambiguity between matching namespaces of NetStandard and .NET Framework.
Issue took root updating a NetStandard 3rd party package and it required/installed a dependency of System.Net.NetworkInformation (v4.3.0 I believe.) Honestly worked fine before that package so I manually removed the dependency from CSPROJ and package.config that main solution added.
It's not clean but demonstrates a NuGet or MSBuild issue not recognizing they are in fact different assemblies and thus count as a duplicate reference.
Delete the dll in 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.2\Facades\System.Xml.ReaderWriter.dll'.
and build your code.
Add it back after build successfully.
I was able to resolve the issue by updating the NuGet package Microsoft.Net.Compilers to a newer version. It had been at 1.0.0, which I believe wasn't using the newer version of MSBuild (as pointed out in some of the other answers).
When I try to compile my program I get the following error:
This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567.
Now when I right click on the solution and press
All packages are already installed and there is nothing to restore.
I tried manually reinstalling every package which didn't solve the problem, I tried reinstalling NuGet but that didn't help either and I even tried reinstalling visual studio.
I also tried moving the package folder from the tfs folder to overwrite my package folder but that didn't solve anything. I also tried redownloading them with this package missing, that didn' t solve the problem either.
Anybody know how to restore the nuget packages?
Use Package Manager Console in Visual Studio to run this command.
1.This will restore all packages from solution
nuget restore YourSolution.sln
2.If you want to reinstall the packages to the same versions as were previously installed
Update-Package -reinstall
Honestly, whoever developed the NuGet command for VS needs to go back to the drawing board. They totaly missed the fact that sometimes these DLL(s) and/or files get corrupt or deleted. a "NuGet Get-Packages -Force" option would really save their bacon. The only GAP I see is that VS and the Package console does not allow you to invoke a forced download from NuGet. Even clearing the cache via VS is useless.
I ran into this issue when I tried to build my project on a computer where the packages-folder did not already exist in the solution root.
When the project file was initially created, it seems VS2019 added the following into the project file:
<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.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
From what I understand those settings are deprecated nowadays, no idea why VS inserted it in the first place.
Anyway, after removing those lines VS restored the packages and built the solution correctly again.
It's probably a good idea to clear the Nuget Cache by deleting the contents within this directory: C:\Users\{your_username}\AppData\Local\NuGet
All you need is that:
Open the Package Manager Console and run this command: Update-Package -reinstall
P.S: VS2017 and above NuGet Package Manager is included with Visual Studio, no need to install anything else.
The problem with the functionality of the NuGet package can also be caused by the fact that NuGet package is requiring certain dependency that the project does not meet.
NuGet package can have a declared dependency in Dependecies section, e.g. .NETFramework,Version=v.4.6.2 while the project is targeted to an older version (Target framework: .NET Framework 4.6.1.).
Instead of the NuGet system notifying the user of this fact, the project simply does not compile.
In my case, I have different Nuget configurations, and somehow the HintPath in the project file didn't fit.
Maybe you should check if the HintPath leads to the right NuGetPackages folder.
You should also check the following entries at the top of the file:
And at the bottom of the file:
All these paths should point to the right NuGetPackage folder in your file structure.
In my case the problem was solved by deleting the "obj" folder(s) and then rebuilding the solution.
The "obj" folder had several NuGet related files that still referred to version 0.0.2 of a package while all projects in the solution were already using version 1.0.0 of that package. Building the solution failed with the error message "package with version 0.0.2 could not be found". The solution with build folders included was recently copied from another machine.
Well it's probably a bad way but I found that it works if I just delete the line
http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
from the project.csproj , not sure if this is going to cause problems later on but it works for now.
I have a project that I have on TFS online. When Im trying to build the project, I get the following error:
Severity Code Description Project File Line
Error The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly C:\Users\Bryan\Source\Workspaces\TestProject\ContosoUniversity\packages\Microsoft.Net.Compilers.1.0.0\build..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll. Could not load file or assembly 'file:///C:\Users\Bryan\Source\Workspaces\TestProject\ContosoUniversity\packages\Microsoft.Net.Compilers.1.0.0\tools\Microsoft.Build.Tasks.CodeAnalysis.dll' or one of its dependencies. Could not find the file. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. ContosoUniversity
Has this something to do with that Azure don't support ASP.NET 4.6?
Here was the fix for me. Using Nuget Package Manager, remove these two packages if referenced:
Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Microsoft.Net.Compilers
After that, run a rebuild. This ensured that the build was not trying to use a specific build exe. Click here for the Diff against previous revision
No, it is not related to Azure Web Apps doesn't support ASP.NET 4.6. Actually, you get this error message because NuGet packages are checked into version control.
So, you need to remove folder TestProject\ContosoUniversity\packages from TFS and build again. See: BuildTasks.Csc task could not be loaded from the assembly?
I had the same problem sometime ago, to fix it:
make sure your packages are not under source control
Force restore all package, by deleting the package folder
restart your visual studio
In my case it got resolved by updating the below two Nuget packages to the latest version:
Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Microsoft.Net.Compilers
Delete the packages folder or its contents, clean, rebuild solves the problem for me.
If you take a look at the file in reference it points you to a packages location. It turns out that NuGet packages is broken
To Resolve: you simply need to delete that packages folder (usually under project name \ project name \ packages.), then on build, Nuget will restore all the required packages.
I needed to update all my Nuget packages on my development box, then check the project in to TFS again.
For added peace of mind, I deleted the packages folder in the Team City build folder.
In case someone looks at this later on.
I was getting this issue only when building in DevOps.
But after manually deleting packages in my local build I started getting the same issue locally.
After removing the apparently missing NuGets using the NuGet manager the issue resolved it's self both locally and on azure.
Not sure what caused it but might save someone a headache in the future.
I was using .net 4.7.2
I have an asp.net application using EF, MVC4 and some additional packages. Whenever I try to open the project on a different PC I have issues with the installed packages. My references are marked as missing, and the code is far from compilable. Last time I solved it by deleting references and packages and installing the needed packages one by one. I find the solution tedious. Is there any better, global solution for this? How is this supposed to be done? Shouldn't this be automated?
Thanks for the help and pointers!
UPDATE
I DO use NuGet Packages, (otherwise it would be very hard to get all these dlls) but somehow I always end up with uninstalling and reinstalling the packages to make my project work. I always end up with wrong versions and not compiling code.
I end up doing the following:
Delete package.config
Delete dependencies from the web.config file
NuGet Package Manager Console:
PM> Uninstall-Package A.B.C
PM> Install-Package A.B.C
Clean - rebuild project and hope for the best
I think Uninstall - Install can be replaced with Update-Package –reinstall A.B.C
I was hoping that there is a simpler solution for this.
If using visual studio; you can enable automatic package restore; this article outlines nuget in detail.
If you go to Tools -> Options -> NuGetPackage Manager you can make sure that the auto download is enabled. See the screenshot below.
Without knowing which references are broken, I would assume that you can at least use NuGet Packages to manage Entity Framework and additional framework references.
As lucian.jp said nuget it probably the way to go. At my company, we usually will go out of our way to find and use only packages that have maintained nuget packages, and even most of the core Microsoft ones have them, for example https://www.nuget.org/packages/Microsoft.AspNet.Mvc/
For the other ones, keeping a little thirdparty folder with external assemblies/dlls in the root of your repository and then reference from your project to that instead of from some random place on your hard-drive. I.e. check the third party assemblies into your project somewhere that is not your bin directories.
So if you have an existing project, here is what I suggest you do to avoid future issues:
For each of the assemblies, including your MVC ones, find the nuget equivalent, remove the dll from your project and add it back using the nuget package manager.
Get a copy of all the remaining assemblies and create a folder in the root of your repository and place them in there, then delete all of them and add them back in referencing the dlls from that folder.
If you are using git I'd also use .gitignore to not check in your bin directories. Which will force a new deployment of your code to get the assemblies from their respective sources.
Use Nuget for DLL packages like EF and MVC. But do not use Nuget for JS / CSS packages instead go for bower. Nuget packages for CSS and JS libraries are good but just their installation and uninstallation is tricky and may not match your project structure.
I cloned a project with vs 2013. When I run it I get this error.
Error 1 The "EnsureBindingRedirects" task could not be loaded from the assembly D:\BMaster\packages\Microsoft.Bcl.Build.1.0.13\tools\Microsoft.Bcl.Build.Tasks.dll. Could not load file or assembly 'file:///D:\BMaster\packages\Microsoft.Bcl.Build.1.0.13\tools\Microsoft.Bcl.Build.Tasks.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. BargainMaster.Web
I'm not sure about root cause of this issue but it appeared when I added missing libraries by hand.
I resolved it by doing this:
Delete <solution>\packages\Microsoft.Bcl.Build.1.0.13\
Close solution
Open solution
Navigate to View / Other Windows / Package Manager Console
Press Restore Packages in right top corner of the window
Re-build
(For some reason none of the other answers worked for me.)
I resolved the issue by doing this:
Delete the "packages" folder.
Right click on the solution > Manage NuGet Packages or Solution.
Downgrade Microsoft.Bcl.Build to a previous version 1.0.14. (Latest stable version at the moment of writing this is 1.0.21)
Restore packages and rebuild.
I just went to the Manage NuGet packages options for the particular VS project and updated the version of the Microsoft BCL nuget and it solved the problem for me.
Verify that you have Nuget Package Manager installed.
By default, Visual Studio 2010 doesn't have it (later versions do)
- Open Tools / Extension Manager
- Search for Nuget Package Manager and click Download
- After this I had to remove the Nuget package (Microsoft.Bxl.Async, Microsoft.BCL, and Microsoft.Bcl.Build) causing the error, restart VS and re-add the package.
The above answer didn't work for me. I just had to remove references (in packages and proj file) to Microsoft.Bcl.Build.. Rebuilt and succeeded.