'System.Xaml' which was not found in the GAC - c#

Trying to update Microsoft.Build.Framework using Nuget in my SLN and getting the below error. This is VS 2017 Enterprise Version 15.9.1
Projects all target NET461 in this sln.
I duplicated this problem on 2 different windows 10 machines with the same project.
What can I do to get these packages updated?
Output
Attempting to gather dependency information for package 'Microsoft.Build.Framework.15.8.166' with respect to project 'Synovia.Service', targeting '.NETFramework,Version=v4.7.2'
Gathering dependency information took 3.08 sec
Attempting to resolve dependencies for package 'Microsoft.Build.Framework.15.8.166' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'Microsoft.Build.Framework.15.8.166'
Resolved actions to install package 'Microsoft.Build.Framework.15.8.166'
Found package 'Microsoft.Build.Framework 15.8.166' in 'D:\git\sbss\Source\packages'.
GET https://api.nuget.org/v3-flatcontainer/microsoft.build.tasks.core/15.7.179/microsoft.build.tasks.core.15.7.179.nupkg
GET https://api.nuget.org/v3-flatcontainer/microsoft.build.utilities.core/15.7.179/microsoft.build.utilities.core.15.7.179.nupkg
Retrieving package 'Microsoft.Build.Tasks.Core 15.7.179' from 'nuget.org'.
Retrieving package 'Microsoft.Build.Utilities.Core 15.7.179' from 'nuget.org'.
Found package 'Microsoft.VisualStudio.Setup.Configuration.Interop 1.16.30' in 'D:\git\sbss\Source\packages'.
Removed package 'Microsoft.Build.Framework.15.6.82' from 'packages.config'
OK https://api.nuget.org/v3-flatcontainer/microsoft.build.utilities.core/15.7.179/microsoft.build.utilities.core.15.7.179.nupkg 53ms
Installing Microsoft.Build.Utilities.Core 15.7.179.
OK https://api.nuget.org/v3-flatcontainer/microsoft.build.tasks.core/15.7.179/microsoft.build.tasks.core.15.7.179.nupkg 78ms
Successfully uninstalled 'Microsoft.Build.Framework.15.6.82' from Synovia.Service
Installing Microsoft.Build.Tasks.Core 15.7.179.
Removed package 'Microsoft.Build.Tasks.Core.15.6.82' from 'packages.config'
Successfully uninstalled 'Microsoft.Build.Tasks.Core.15.6.82' from Synovia.Service
Removed package 'Microsoft.Build.Utilities.Core.15.6.82' from 'packages.config'
Successfully uninstalled 'Microsoft.Build.Utilities.Core.15.6.82' from Synovia.Service
Package 'Microsoft.Build.Framework.15.8.166' already exists in folder 'D:\git\sbss\Source\packages'
Install failed. Rolling back...
Package 'Microsoft.Build.Framework.15.8.166' does not exist in project 'Synovia.Service'
Package 'Microsoft.Build.Utilities.Core.15.6.82' already exists in folder 'D:\git\sbss\Source\packages'
Added package 'Microsoft.Build.Utilities.Core.15.6.82' to 'packages.config'
Package 'Microsoft.Build.Tasks.Core.15.6.82' already exists in folder 'D:\git\sbss\Source\packages'
Added package 'Microsoft.Build.Tasks.Core.15.6.82' to 'packages.config'
Package 'Microsoft.Build.Framework.15.6.82' already exists in folder 'D:\git\sbss\Source\packages'
Added package 'Microsoft.Build.Framework.15.6.82' to 'packages.config'
Executing nuget actions took 6.84 sec
Failed to add reference. The package 'Microsoft.Build.Framework' tried to add a framework reference to 'System.Xaml' which was not found in the GAC. This is possibly a bug in the package. Please contact the package owners for assistance.
Reference unavailable.
Time Elapsed: 00:00:10.1224742
========== Finished ==========

'System.Xaml' which was not found in the GAC
Your project is probably target .Net 3.5, which does not have this DLL. You can update the framework version in Project Properties.
If above not resolve your issue or you do not want to change your framework version, you can manually add the reference System.Xaml to your project:
Go to References -> Add Reference... and then click on Browse..
Add the file, which is located on (Windows 10): C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll
Then update your nuget package.
Hope this helps.

Related

Nuget.exe and NuGet Package Manager resolve different dependencies

I want to install OPCFoundation.NetStandard.Opc.Ua version 1.4.355.26 (and all of its dependencies) to an offline machine. My online and offline machines are running Visual Studio 2019 16.1.3.
When I install OPCFoundation.NetStandard.Opc.Ua version 1.4.355.26 using the NuGet Package Manager, it installs many dependencies, including Libuv.1.10.0. See screenshot:
When I download the same package for offline installation, nuget.exe fetches Libuv.1.9.2. See screenshot:
C:\Users\cstankevitz\Downloads>nuget.exe install OPCFoundation.NetStandard.Opc.Ua
Feeds used:
https://api.nuget.org/v3/index.json
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Installing package 'OPCFoundation.NetStandard.Opc.Ua' to 'C:\Users\cstankevitz\Downloads'.
GET https://api.nuget.org/v3/registration3-gz-semver2/opcfoundation.netstandard.opc.ua/index.json
OK https://api.nuget.org/v3/registration3-gz-semver2/opcfoundation.netstandard.opc.ua/index.json 558ms
Attempting to gather dependency information for package 'OPCFoundation.NetStandard.Opc.Ua.1.4.355.26' with respect to project 'C:\Users\cstankevitz\Downloads', targeting 'Any,Version=v0.0'
Gathering dependency information took 16.89 sec
Attempting to resolve dependencies for package 'OPCFoundation.NetStandard.Opc.Ua.1.4.355.26' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'OPCFoundation.NetStandard.Opc.Ua.1.4.355.26'
Resolved actions to install package 'OPCFoundation.NetStandard.Opc.Ua.1.4.355.26'
Retrieving package 'Libuv 1.9.2' from 'nuget.org'.
...
Of course, when I bring the downloaded packages to my offline machine and install them using Visual Studio 2019 NuGet Package Manager, the install fails because the Libuv.1.10.0 is not available.
How can I get nuget.exe (or any other tool) to download the correct packages needed by NuGet Package Manager for offline installation?
Here is how I installed the correct dependencies to my offline system:
On the online system
Fetch the source of https://github.com/StuffOfInterest/NuGetDependencyDownloader
Edit PackageTools.cs and modify the function GetRangedPackageVersion so that it contains the code below. This is needed to fix a "bug" in which older packages are not downloaded when newer packages are available -- but the older packages will be needed in Step 9 below.
Compile and run NuGetDependencyDownloader to download the package and its dependencies
Copy the packages to an external drive
On the offline system
Copy the packages to your offline system (c:\Work\2019-07018 Nuget Offline\ in my example)
Edit options for Nuget Package Manager | Package Sources. Add a source that points to the directory used in step 5. Specify Local Package Source Screenshot
Run Nuget Package Manager.
Specify the Package source that you created in step 6. Specify package source screenshot
Install your package
Notice that it appears to install but nothing is actually happening. It is trying to contact something online (which will fail after a long timeout). This is repeated for every dependency. Speed up the failure by disconnecting all of your interfaces (unplug cables, etc).
private IPackage GetRangedPackageVersion(IQueryable<IPackage> packages, IVersionSpec versionSpec)
{
packages = packages.Where(o => o.Version == versionSpec.MinVersion);
IPackage package = packages
.OrderByDescending(o => o.Version)
.FirstOrDefault();
return package;
}
If you look at the output of the Preview Changes dialog in VS, all the Microsoft.AspNetCore packages are version 2.0.1, whereas running nuget.exe, it got versions 1.1.x. If you look at OPCFoundation.NetStandard.Opc.Ua on nuget.org and expand the dependencies, you see it has dependencies on the 1.1 packages for net46 and netstandard2.0, but 2.0 dependencies for netstandard2.0.
From this I can deduce that your project is using netcoreapp2.0, netstandard2.0, or above, whereas nuget.exe is probably using some .NET Framework for dependencies.
As for ways to get the same packages that your project actually uses, I've answered this question several times in the past and I usually link to the first time I answered it

Cannot update nuget package (PCL)

I'm getting this error when using maps in Android:
System.MissingMethodEsception: Method
'Xamarin.Forms.maps.Android.MapRenderer.OnCameraChange' not found.
And I've read that you can update the nugetpackage to fix the issue. However, I cannot install it due to this:
Could not install package 'TK.CustomMap 2.0.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile78', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
The updates of packages installs just find in iOS and Android but not for PCL. I've tried to remove all the packages and then tried to add TK.Customs nuget package but this same issue.
Also tried to install it on a fresh project and that installed just fine. Just cant get it to install on my old project.
Here is the whole error message when trying to update package:
Attempting to gather dependency information for package 'TK.CustomMap.2.0.1' with respect to project 'Vernamo', targeting '.NETPortable,Version=v4.5,Profile=Profile78'
GET https://api.nuget.org/v3/registration3-gz-semver2/tk.custommap/index.json
OK https://api.nuget.org/v3/registration3-gz-semver2/tk.custommap/index.json 175ms
Total number of results gathered : 29
Gathering dependency information took 232 ms
Summary of time taken to gather dependencies per source :
https://api.nuget.org/v3/index.json - 204.03 ms
Attempting to resolve dependencies for package 'TK.CustomMap.2.0.1' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'TK.CustomMap.2.0.1'
Resolved actions to install package 'TK.CustomMap.2.0.1'
Found package 'TK.CustomMap 2.0.1' in '/Users/holger/Downloads/Vernamo/packages'.
For adding package 'TK.CustomMap.2.0.1' to project 'Vernamo' that targets 'portable45-net45+win8+wp8'.
Install failed. Rolling back...
Package 'TK.CustomMap.2.0.1' does not exist in project 'Vernamo'
Executing nuget actions took 52 ms
Could not install package 'TK.CustomMap 2.0.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile78', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
The pre-release version (at least pre2) of TK.CustomMap supported all platforms (see here), anyway, as of pre3 (see here), obviously the support for all platforms was dropped in favor of .NET Standard (1.1 in this case).
The profile you are using in your PCL does not seem to be compatible with .NET Standard 1.1, hence NuGet fails to add the reference. You may try to switch to another profile (.NET 4.5.1 for example), but I don't know if that would help. Another option would be to migrate your projects to .NET Standard. It's kind of a stupid, repetetive task, but it's possible.

Sending solution to new developer with tfs - package issues

I have shared a solution with another developer via TFS and we are having some trouble with the packages.
In the source control explorer I see what is shared is a packages folder with each package folder and a .nupkg file in each.
I read that we needed to run Update-Package to install all of these based on the packages.config folder. When we did that there was an error on EntityFramework. Here are the logs.
No package updates are available from the current package source for project 'ConfigManager'.
Attempting to gather dependency information for multiple packages with respect to project 'BusinessServices.Tests', targeting '.NETFramework,Version=v4.5'
Attempting to resolve dependencies for multiple packages.
Resolving actions install multiple packages
Removed package 'NUnit 3.2.1' from 'packages.config'
Successfully uninstalled 'NUnit 3.2.1' from BusinessServices.Tests
GET https://api.nuget.org/v3-flatcontainer/nunit/3.5.0/nunit.3.5.0.nupkg
OK https://api.nuget.org/v3-flatcontainer/nunit/3.5.0/nunit.3.5.0.nupkg 56ms
Installing NUnit 3.5.0.
Adding package 'NUnit.3.5.0' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'NUnit.3.5.0' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'NUnit.3.5.0' to 'packages.config'
Successfully installed 'NUnit 3.5.0' to BusinessServices.Tests
Removing package 'NUnit 3.2.1' from folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Removed package 'NUnit 3.2.1' from folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Attempting to gather dependency information for multiple packages with respect to project 'PrintServices.Tests', targeting '.NETFramework,Version=v4.5'
Attempting to resolve dependencies for multiple packages.
Resolving actions install multiple packages
Removed package 'NUnit 2.6.4' from 'packages.config'
Successfully uninstalled 'NUnit 2.6.4' from PrintServices.Tests
Removed package 'Moq 4.5.9' from 'packages.config'
Successfully uninstalled 'Moq 4.5.9' from PrintServices.Tests
Executing script file 'C:\WORK\TFS\TransitProjects\HmkApi\packages\AutoMapper.3.3.1\tools\net40\uninstall.ps1'
Removed package 'AutoMapper 3.3.1' from 'packages.config'
Successfully uninstalled 'AutoMapper 3.3.1' from PrintServices.Tests
GET https://api.nuget.org/v3-flatcontainer/automapper/5.1.1/automapper.5.1.1.nupkg
OK https://api.nuget.org/v3-flatcontainer/automapper/5.1.1/automapper.5.1.1.nupkg 120ms
Installing AutoMapper 5.1.1.
Adding package 'AutoMapper.5.1.1' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'AutoMapper.5.1.1' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'AutoMapper.5.1.1' to 'packages.config'
Successfully installed 'AutoMapper 5.1.1' to PrintServices.Tests
GET https://api.nuget.org/v3-flatcontainer/moq/4.5.28/moq.4.5.28.nupkg
OK https://api.nuget.org/v3-flatcontainer/moq/4.5.28/moq.4.5.28.nupkg 113ms
Installing Moq 4.5.28.
Adding package 'Moq.4.5.28' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'Moq.4.5.28' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'Moq.4.5.28' to 'packages.config'
Successfully installed 'Moq 4.5.28' to PrintServices.Tests
Package 'NUnit.3.5.0' already exists in folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'NUnit.3.5.0' to 'packages.config'
Successfully installed 'NUnit 3.5.0' to PrintServices.Tests
Removing package 'AutoMapper 3.3.1' from folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Removed package 'AutoMapper 3.3.1' from folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Attempting to gather dependency information for multiple packages with respect to project 'PrintServices', targeting '.NETFramework,Version=v4.5'
Attempting to resolve dependencies for multiple packages.
Resolving actions install multiple packages
Removed package 'NLog 4.3.3' from 'packages.config'
Successfully uninstalled 'NLog 4.3.3' from PrintServices
GET https://api.nuget.org/v3-flatcontainer/nlog/4.3.11/nlog.4.3.11.nupkg
OK https://api.nuget.org/v3-flatcontainer/nlog/4.3.11/nlog.4.3.11.nupkg 283ms
Installing NLog 4.3.11.
Adding package 'NLog.4.3.11' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'NLog.4.3.11' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'NLog.4.3.11' to 'packages.config'
Successfully installed 'NLog 4.3.11' to PrintServices
Attempting to gather dependency information for multiple packages with respect to project 'Resolver', targeting '.NETFramework,Version=v4.5'
Attempting to resolve dependencies for multiple packages.
Resolving actions install multiple packages
Removed package 'Unity 2.1.505.0' from 'packages.config'
Successfully uninstalled 'Unity 2.1.505.0' from Resolver
Removed package 'CommonServiceLocator 1.0' from 'packages.config'
Successfully uninstalled 'CommonServiceLocator 1.0' from Resolver
GET https://api.nuget.org/v3-flatcontainer/commonservicelocator/1.3.0/commonservicelocator.1.3.0.nupkg
OK https://api.nuget.org/v3-flatcontainer/commonservicelocator/1.3.0/commonservicelocator.1.3.0.nupkg 8ms
Installing CommonServiceLocator 1.3.0.
Adding package 'CommonServiceLocator.1.3.0' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'CommonServiceLocator.1.3.0' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'CommonServiceLocator.1.3.0' to 'packages.config'
Successfully installed 'CommonServiceLocator 1.3.0' to Resolver
GET https://api.nuget.org/v3-flatcontainer/unity/4.0.1/unity.4.0.1.nupkg
OK https://api.nuget.org/v3-flatcontainer/unity/4.0.1/unity.4.0.1.nupkg 4ms
Installing Unity 4.0.1.
Adding package 'Unity.4.0.1' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'Unity.4.0.1' to folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'Unity.4.0.1' to 'packages.config'
Successfully installed 'Unity 4.0.1' to Resolver
Attempting to gather dependency information for multiple packages with respect to project 'BusinessServices', targeting '.NETFramework,Version=v4.5'
Attempting to resolve dependencies for multiple packages.
Resolving actions install multiple packages
Removed package 'NLog 4.3.3' from 'packages.config'
Successfully uninstalled 'NLog 4.3.3' from BusinessServices
Removed package 'EntityFramework 5.0.0' from 'packages.config'
Successfully uninstalled 'EntityFramework 5.0.0' from BusinessServices
Removed package 'AutoMapper 4.2.1' from 'packages.config'
Successfully uninstalled 'AutoMapper 4.2.1' from BusinessServices
Package 'AutoMapper.5.1.1' already exists in folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Added package 'AutoMapper.5.1.1' to 'packages.config'
Successfully installed 'AutoMapper 5.1.1' to BusinessServices
Package 'EntityFramework.6.1.3' already exists in folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Install failed. Rolling back...
Package 'EntityFramework 6.1.3' does not exist in project 'BusinessServices'
Removed package 'AutoMapper 5.1.1' from 'packages.config'
Package 'AutoMapper 4.2.1' already exists in folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Package 'EntityFramework 5.0.0' already exists in folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Package 'NLog 4.3.3' already exists in folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Removing package 'EntityFramework 6.1.3' from folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Removed package 'EntityFramework 6.1.3' from folder 'C:\WORK\TFS\TransitProjects\HmkApi\packages'
Update-Package : Failed to add reference to 'EntityFramework'.
At line:1 char:1
+ Update-Package
+ ~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Update-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
At this point I am pretty stuck, not sure what my options are?

Missing reference on successful NuGet package installation

I am following this guide to setup my own NuGet private server, but using Visual Studio 2010.
I have successfully added the NuGet.Server package through Package Manager Console, but when I want to build the WebApplication I got errors:
The type or namespace name 'Server' does not exist in the namespace 'NuGet' (are you missing an assembly reference?)
There is no error in the package installation, but I see that NuGet.Server is not added in the reference folder of the project, Why is that happen?
Edit : Further investigating on the package contents, I see that NuGet.Server does not have the lib for net40. I might need to fork NuGet.Server source and compile it in net40 to fix this.
Here is my logs from Package Manager Console:
PM> Install-package nuget.server
Attempting to resolve dependency 'NuGet.Core (≥ 2.10.1)'.
Attempting to resolve dependency 'Microsoft.Web.Xdt (≥ 2.1.0)'.
Attempting to resolve dependency 'Newtonsoft.Json (≥ 8.0.1)'.
Attempting to resolve dependency 'RouteMagic (≥ 1.3.0)'.
Attempting to resolve dependency 'WebActivatorEx (≥ 2.1.0)'.
Attempting to resolve dependency 'Microsoft.Web.Infrastructure (≥ 1.0.0.0)'.
Installing 'Microsoft.Web.Xdt 2.1.1'.
You are downloading Microsoft.Web.Xdt from Microsoft Corporation, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkId=273778. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Microsoft.Web.Xdt 2.1.1'.
Installing 'NuGet.Core 2.10.1'.
Successfully installed 'NuGet.Core 2.10.1'.
Installing 'Newtonsoft.Json 8.0.1'.
Successfully installed 'Newtonsoft.Json 8.0.1'.
Installing 'RouteMagic 1.3'.
Successfully installed 'RouteMagic 1.3'.
Installing 'Microsoft.Web.Infrastructure 1.0.0.0'.
Successfully installed 'Microsoft.Web.Infrastructure 1.0.0.0'.
Installing 'WebActivatorEx 2.1.0'.
Successfully installed 'WebActivatorEx 2.1.0'.
Installing 'NuGet.Server 2.10.3'.
Successfully installed 'NuGet.Server 2.10.3'.
Adding 'Microsoft.Web.Xdt 2.1.1' to WebApplication2.
Successfully added 'Microsoft.Web.Xdt 2.1.1' to WebApplication2.
Adding 'NuGet.Core 2.10.1' to WebApplication2.
Successfully added 'NuGet.Core 2.10.1' to WebApplication2.
Adding 'Newtonsoft.Json 8.0.1' to WebApplication2.
Successfully added 'Newtonsoft.Json 8.0.1' to WebApplication2.
Adding 'RouteMagic 1.3' to WebApplication2.
Successfully added 'RouteMagic 1.3' to WebApplication2.
Adding 'Microsoft.Web.Infrastructure 1.0.0.0' to WebApplication2.
Successfully added 'Microsoft.Web.Infrastructure 1.0.0.0' to WebApplication2.
Adding 'WebActivatorEx 2.1.0' to WebApplication2.
Successfully added 'WebActivatorEx 2.1.0' to WebApplication2.
Adding 'NuGet.Server 2.10.3' to WebApplication2.
File Conflict
File 'Web.config' already exists in project 'WebApplication2'. Do you want to overwrite it?
[Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "N"):A
Overwrite existing file 'Web.config'.
Successfully added 'NuGet.Server 2.10.3' to WebApplication2.
I got the same error when trying to build it with Visual Studio 2015 in a project that had the target framework set to .NET Framework 4.0. Setting the target framework to .NET Framework 4.6.1 fixed it for me.
I would suggest using a newer version of Visual Studio if possible, or compiling it with the newer framework itself via the command line. This other stack overflow answer may be of assistance if you wish to do the later. How to build .NET 4.6 Framework app without Visual Studio installed?
An option for anyone who do not want to, or cannot target a different .NET Framework version, is to install a previous version of NuGet.Server. For example, version 2.10.3 targets .NET 4.5.

Installing Entity Framework fails in Visual Studio 2015

I'm reading/coding along with the Apress book Pro ASP.NET MVC 5 by Adam Freeman. In chapter 7 (p. 174), we're supposed to install Entity Framework using the following commands:
Install-Package EntityFramework -projectname SportsStore.Domain
Install-Package EntityFramework -projectname SportsStore.WebUI
But this fails. Here is the output:
Attempting to gather dependencies information for package 'EntityFramework.6.1.3' with respect to project 'SportsStore.Domain', targeting '.NETFramework,Version=v4.5.1'
Attempting to resolve dependencies for package 'EntityFramework.6.1.3' with DependencyBehavior 'Lowest'
Resolving actions to install package 'EntityFramework.6.1.3'
Resolved actions to install package 'EntityFramework.6.1.3'
Adding package 'EntityFramework.6.1.3' to folder 'C:\git\SportsStore\packages'
Added package 'EntityFramework.6.1.3' to folder 'C:\git\SportsStore\packages'
Added package 'EntityFramework.6.1.3' to 'packages.config'
Executing script file 'C:\git\SportsStore\packages\EntityFramework.6.1.3\tools\init.ps1'
Executing script file 'C:\git\SportsStore\packages\EntityFramework.6.1.3\tools\install.ps1'
Type 'get-help EntityFramework' to see all available Entity Framework commands.
Successfully installed 'EntityFramework 6.1.3' to SportsStore.Domain
Install failed. Rolling back...
Removed package 'EntityFramework 6.1.3' from 'packages.config'
Removing package 'EntityFramework 6.1.3' from folder 'C:\git\SportsStore\packages'
Access to the path 'C:\git\SportsStore\packages\EntityFramework.6.1.3\tools\EntityFramework.PowerShell.Utility.dll' is denied.
Access to the path 'EntityFramework.PowerShell.Utility.dll' is denied.
Removed package 'EntityFramework 6.1.3' from folder 'C:\git\SportsStore\packages'
Install-Package : An item with the same key has already been added.
At line:1 char:1
+ Install-Package EntityFramework -projectname SportsStore.Domain
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
One or more packages could not be completely uninstalled: 'C:\git\SportsStore\packages\EntityFramework.6.1.3'. Restart Visual Studio to finish uninstall.
The book is instructing us to install specific versions of all other libraries (e.g. Microsoft.Aspnet.Mvc 5.0.0), but does not mention which version of EF to install, so I've tried installing different versions of EF, but keep getting the same error. (Install failed. Rolling back...)
I'm running VS2015 as administrator.
Seems NuGet itself was causing these issues (probably related to https://github.com/NuGet/Home/issues/1239, as I was seeing the same 'always rolling back' issue as discussed in that thread)
Updating NuGet solved it for me. (Updated from version 3.0.60624.657 to 3.1.60724.766)
These references were set up earlier in the project:
SportsStore.WebUI -> SportsStore.Domain
SportsStore.UnitTests -> SportsStore.Domain and SportsStore.WebUI
I removed the references for each project and then ran the install-package command for the Entity Framework as directed. That worked fine.
I then re-added the references.
Try to remove all the EF nuget packages installed on your solution and then reinstall the only one that you need.
Try to disconnect references between projects and than try to install EF. Hope it'll help
Relaunching Visual Studio as Admin and retry to install the package did the trick for me.

Categories