Unable to Install Microsoft.Net.Http through Nuget - c#

When trying to installing Microsoft.Net.Http in a Windows Phone 8 project. I'm getting this error:
Attempting to resolve dependency 'Microsoft.Bcl (≥ 1.1.3)'.
Attempting to resolve dependency 'Microsoft.Bcl.Build (≥ 1.0.4)'.
Successfully installed 'Microsoft.Bcl.Build 1.0.10'.
Successfully installed 'Microsoft.Bcl 1.1.3'.
Successfully installed 'Microsoft.Net.Http 2.2.13'.
Successfully added 'Microsoft.Bcl.Build 1.0.10' to WinPhone.Data.
Executing script file 'D:\WinPhone\packages\Microsoft.Bcl.Build.1.0.10\tools\Install.ps1'.
This reference cannot be removed from the project because it is always referenced by the compiler.
This reference cannot be removed from the project because it is always referenced by the compiler.
This reference cannot be removed from the project because it is always referenced by the compiler.
This reference cannot be removed from the project because it is always referenced by the compiler.
Executing script file 'D:\WinPhone\packages\Microsoft.Bcl.Build.1.0.10\tools\Uninstall.ps1'.
Successfully uninstalled 'Microsoft.Bcl 1.1.3'.
Successfully uninstalled 'Microsoft.Bcl.Build 1.0.10'.
Install failed. Rolling back...
Failed to add reference to 'System.IO'
It says it's supported for Windows Phone 8 : https://www.nuget.org/packages/Microsoft.Net.Http/2.2.13
Anyone with any suggestions ?

The problem was Nuget; after someone answered this on msdn to update and try again. It worked after that.

Related

Xamarin Android Error "Can not resolve reference: `System.Dynamic`, referenced by `Microsoft.CSharp`"

After years of happily using VS2019 for my Xamarin MVVMCross application, I am trying upgrade the Visual Studio 2019 Enterprise from 16.7.7 to 16.10.2, but upon building my Android Application i receive the following error:
Can not resolve reference: System.Dynamic, referenced by Microsoft.CSharp. Please add a NuGet package or assembly reference for System.Dynamic, or remove the reference to Microsoft.CSharp. ClarityWork.Droid
I have tried removing the reference to Microsot.CSharp in my Droid project and also removed the two places in my code where System.Dynamic was being used, but i am still getting the same error. I have also tried adding System.Dynamic.Runtime from NuGet to no avail
The error from the output window is as follows:
3>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(311,5): error XA2002: Can not resolve reference: System.Dynamic, referenced by Microsoft.CSharp. Please add a NuGet package or assembly reference for System.Dynamic, or remove the reference to Microsoft.CSharp.
Has anyone else had a similar issue when upgrading VS2019 version? I have searched online and can't find any other references to it
The answer to this was to add the NuGet package for Microsoft.CSharp to my .net standard core project

Incorrect Nuget Reference to System.ComponentModel.Composition when I am adding System.Runtine 4.3.1

I am using Visual Studio Professional 2019 and when adding nuget package for System.Runtime 4.3.1 it automatically adds reference to System.ComponentModel.Composition . Though build is successful on my local machine, it fails on Azure VM when pipeline runs. Azure VM does not have Visual Studio installed it uses MSBuild. I did search it and read similar question answer but didn't help. Any help would be highly appreciated.
While I am not sure exactly why System.Runtime needs to add reference of System.ComponentModel.Composition, but I can confirm from my testing that while installing System.Runtime nuget it adds a reference of System.ComponentModel.Composition from GAC, but does not add that nuget. Hence it is failing in machine where it's not present in GAC. So, to fix your error just add the nuget System.ComponentModel.Composition explicitly in your required project.

Azure Function App failing to load IOptionsFormatter

I have a C# Azure Function App that I'm trying to run locally. It previously had worked fine some months ago but is now failing with the following:
A host error has occurred
Microsoft.Azure.WebJobs.Extensions.Storage: Could not load type 'Microsoft.Azure.WebJobs.Hosting.IOptionsFormatter' from assembly 'Microsoft.Azure.WebJobs.Host, Version=3.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
At some point I had updated the Azure Functions and Web Jobs Tools to the latest version (15.10.20460.0).
On startup, it was having problems indexing the functions so I updated the Microsoft.NET.Sdk.Functions nuget package reference to the latest version (1.0.24) which is now giving me the above error.
I also added a nuget package reference to Microsoft.Azure.WebJobs.Extensions.Storage 3.0.3 to resolve the missing TableAttribute errors that appeared as well.
I've checked the assemblies in the bin folder which have the following versions:
Microsoft.Azure.WebJobs.Extensions.Storage.dll - v3.0.3.0
Microsoft.Azure.WebJobs.Host.dll - v3.0.4.0
For Visual Studio for Mac 2019 users I found the following to help me. If you add an azure functions project to your solution there should be a message that there are updated templates available. Click that, let them update and then cancel adding a new project.
This appears to update the tooling as well. My error went away. Not sure why a brand new VS for Mac 2019 install didn't have updated tools.
Changing the Nuget Package Reference for Microsoft.Azure.WebJobs.Extensions.Storage from the latest version - 3.0.3 to 3.0.2 resolves the issue.
Running the function project now launches successfully with no errors displayed.
I'm using Visual Studio 2019 (16.2.0) with most of my Microsoft.Azure.WebJobs.Extensions being version 3.0.6.
After trying out all suggestions above without success, I recognized that I was missing the "Connection" attribute in my ServiceBusTrigger.
Adding the connection attribute resolved the issue immediately.

'System.Xaml' which was not found in the GAC

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.

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.

Categories