Installing Newtonsoft.Json NuGet Package in .NET 4.0 project fails - json.net

Why can't I install Newtonsoft.Json in a .NET 4.0 project considering its dependencies?
I have a .NET class library project targetting .NET 4.0 that references the Newtonsoft.Json 4.5.6 NuGet package. I want to upgrade Newtonsoft.Json to the latest version (v10.0.3). This fails with the following message printed out on the Package Manager Console:
Could not install package 'System.Net.Http 4.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', 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 dependency behavior on install was: "Lowest".
Looking at the dependencies of Newtonsoft.Json NuGet package shows:
.NETFramework,Version=v4.0
No dependencies
Am I misinterpreting something? I expected that it can be installed in a .NET 4.0 project.
The full install log is:
Attempting to gather dependency information for package 'Newtonsoft.Json.10.0.3' with respect to project 'XYZ', targeting '.NETFramework,Version=v4.0'
Attempting to resolve dependencies for package 'Newtonsoft.Json.10.0.3' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Newtonsoft.Json.10.0.3'
Resolved actions to install package 'Newtonsoft.Json.10.0.3'
Removed package 'Newtonsoft.Json.4.5.6' from 'packages.config'
Successfully uninstalled 'Newtonsoft.Json.4.5.6' from XYZ Removed package 'System.Net.Http.2.0.20710' from 'packages.config'
Successfully uninstalled 'System.Net.Http.2.0.20710' from XYZ
Adding package 'Newtonsoft.Json.10.0.3' to folder 'c:\MAIN\packages'
Added package 'Newtonsoft.Json.10.0.3' to folder 'c:\MAIN\packages'
Added package 'Newtonsoft.Json.10.0.3' to 'packages.config'
Executing script file 'c:\MAIN\packages\Newtonsoft.Json.10.0.3\tools\install.ps1'...
Successfully installed 'Newtonsoft.Json 10.0.3' to XYZ Install failed.
Rolling back...
Package 'System.Net.Http.4.0.0' does not exist in project 'XYZ'
Removed package 'Newtonsoft.Json.10.0.3' from 'packages.config'
Adding package 'System.Net.Http.2.0.20710', which only has dependencies, to project 'XYZ'.
Package 'System.Net.Http.2.0.20710' already exists in folder 'c:\MAIN\packages'
Added package 'System.Net.Http.2.0.20710' to 'packages.config'
Package 'Newtonsoft.Json.4.5.6' already exists in folder 'c:\MAIN\packages'
Added package 'Newtonsoft.Json.4.5.6' to 'packages.config'
Removing package 'Newtonsoft.Json.10.0.3' from folder 'c:\MAIN\packages'
Removed package 'Newtonsoft.Json.10.0.3' from folder 'c:\MAIN\packages'
Could not install package 'System.Net.Http 4.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', 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.
========== Finished ==========
The only way to install Newtonsoft.Json into the .NET 4.0 project was to use dependency behavior "Ignore Dependencies".

Try to run in Packager manager console
Install-Package Newtonsoft.Json -Version 4.0.8

Related

Devops MSBuild Error Cant Find NuGet Package

I have a DevOps Pipeline created to build asp.net website. I can build the site on my computer but when I use Pipelines it gives error:
Error CS0246: The type or namespace name 'Azure' could not be found (are you missing a using directive or an assembly reference?
I have three Azure packages being installed from NuGet and according to the NuGet restore task it is installing them (and others) with no error
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
[command]C:\Windows\system32\chcp.com 65001
Active code page: 65001
Detected NuGet version 4.4.1.4656 / 4.4.1
SYSTEMVSSCONNECTION exists true
[command]C:\hostedtoolcache\windows\NuGet\4.4.1\x64\nuget.exe sources Add -NonInteractive -Name NuGetOrg -Source https://api.nuget.org/v3/index.json -ConfigFile D:\a\1\Nuget\tempNuGet_108.config
Package Source with Name: NuGetOrg added successfully.
[command]C:\hostedtoolcache\windows\NuGet\4.4.1\x64\nuget.exe restore D:\a\1\s\EncryptionDecryptionLib\EncryptionDecryptionLib.sln -Verbosity Detailed -NonInteractive -ConfigFile D:\a\1\Nuget\tempNuGet_108.config
NuGet Version: 4.4.1.4656
MSBuild auto-detection: using msbuild version '15.9.21.664' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
MSBuild P2P timeout [ms]: 120000
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\msbuild.exe "C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\5rlwkrkr.ltc.nugetinputs.targets" /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:NuGetRestoreTargets="C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\lluddamt.xwo.nugetrestore.targets" /p:RestoreTaskAssemblyFile="C:\hostedtoolcache\windows\NuGet\4.4.1\x64\nuget.exe" /p:RestoreSolutionDirectory="D:\a\1\s\EncryptionDecryptionLib" /p:RestoreConfigFile="D:\a\1\Nuget\tempNuGet_108.config" /p:SolutionDir="D:\a\1\s\EncryptionDecryptionLib"
Nothing to do. None of the projects in this solution specify any packages for NuGet to restore.
[command]C:\hostedtoolcache\windows\NuGet\4.4.1\x64\nuget.exe restore D:\a\1\s\LabCode.sln -Verbosity Detailed -NonInteractive -ConfigFile D:\a\1\Nuget\tempNuGet_108.config
NuGet Version: 4.4.1.4656
MSBuild auto-detection: using msbuild version '15.9.21.664' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
WARNING: Project file D:\a\1\s\LabCode\ cannot be found.
Nothing to do. None of the projects in this solution specify any packages for NuGet to restore.
[command]C:\hostedtoolcache\windows\NuGet\4.4.1\x64\nuget.exe restore D:\a\1\s\LabCode\LabCode.sln -Verbosity Detailed -NonInteractive -ConfigFile D:\a\1\Nuget\tempNuGet_108.config
NuGet Version: 4.4.1.4656
MSBuild auto-detection: using msbuild version '15.9.21.664' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
MSBuild P2P timeout [ms]: 120000
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\msbuild.exe "C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\pljrnr0g.jqu.nugetinputs.targets" /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:NuGetRestoreTargets="C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\hlbc31tk.hzh.nugetrestore.targets" /p:RestoreTaskAssemblyFile="C:\hostedtoolcache\windows\NuGet\4.4.1\x64\nuget.exe" /p:RestoreSolutionDirectory="D:\a\1\s\LabCode" /p:RestoreConfigFile="D:\a\1\Nuget\tempNuGet_108.config" /p:SolutionDir="D:\a\1\s\LabCode"
Restoring NuGet package Azure.Core.1.15.0.
Restoring NuGet package Azure.Identity.1.5.0-beta.1.
Restoring NuGet package Azure.Security.KeyVault.Keys.4.2.0-beta.6.
Restoring NuGet package Azure.Security.KeyVault.Secrets.4.2.0-beta.5.
Restoring NuGet package EPPlus.5.6.3.
Restoring NuGet package Microsoft.Bcl.AsyncInterfaces.1.0.0.
Restoring NuGet package Microsoft.Identity.Client.4.30.1.
Restoring NuGet package Microsoft.Identity.Client.Extensions.Msal.2.18.4.
Restoring NuGet package Microsoft.IO.RecyclableMemoryStream.1.4.1.
Restoring NuGet package Microsoft.NETCore.Platforms.1.1.0.
Restoring NuGet package Microsoft.ReportViewer.Common.10.0.40219.1.
Restoring NuGet package Microsoft.ReportViewer.WebForms.10.0.40219.1.
Restoring NuGet package NETStandard.Library.2.0.0.
Restoring NuGet package System.Buffers.4.5.1.
Restoring NuGet package System.Diagnostics.DiagnosticSource.4.6.0.
Restoring NuGet package System.Memory.4.5.4.
GET https://api.nuget.org/v3-flatcontainer/azure.identity/1.5.0-beta.1/azure.identity.1.5.0-beta.1.nupkg
GET https://api.nuget.org/v3-flatcontainer/azure.security.keyvault.secrets/4.2.0-beta.5/azure.security.keyvault.secrets.4.2.0-beta.5.nupkg
GET https://api.nuget.org/v3-flatcontainer/epplus/5.6.3/epplus.5.6.3.nupkg
GET https://api.nuget.org/v3-flatcontainer/azure.core/1.15.0/azure.core.1.15.0.nupkg
GET https://api.nuget.org/v3-flatcontainer/microsoft.bcl.asyncinterfaces/1.0.0/microsoft.bcl.asyncinterfaces.1.0.0.nupkg
GET https://api.nuget.org/v3-flatcontainer/microsoft.identity.client/4.30.1/microsoft.identity.client.4.30.1.nupkg
GET https://api.nuget.org/v3-flatcontainer/microsoft.identity.client.extensions.msal/2.18.4/microsoft.identity.client.extensions.msal.2.18.4.nupkg
GET https://api.nuget.org/v3-flatcontainer/microsoft.io.recyclablememorystream/1.4.1/microsoft.io.recyclablememorystream.1.4.1.nupkg
GET https://api.nuget.org/v3-flatcontainer/microsoft.netcore.platforms/1.1.0/microsoft.netcore.platforms.1.1.0.nupkg
GET https://api.nuget.org/v3-flatcontainer/microsoft.reportviewer.common/10.0.40219.1/microsoft.reportviewer.common.10.0.40219.1.nupkg
GET https://api.nuget.org/v3-flatcontainer/microsoft.reportviewer.webforms/10.0.40219.1/microsoft.reportviewer.webforms.10.0.40219.1.nupkg
GET https://api.nuget.org/v3-flatcontainer/netstandard.library/2.0.0/netstandard.library.2.0.0.nupkg
GET https://api.nuget.org/v3-flatcontainer/system.buffers/4.5.1/system.buffers.4.5.1.nupkg
GET https://api.nuget.org/v3-flatcontainer/system.diagnostics.diagnosticsource/4.6.0/system.diagnostics.diagnosticsource.4.6.0.nupkg
GET https://api.nuget.org/v3-flatcontainer/system.memory/4.5.4/system.memory.4.5.4.nupkg
GET https://api.nuget.org/v3-flatcontainer/azure.security.keyvault.keys/4.2.0-beta.6/azure.security.keyvault.keys.4.2.0-beta.6.nupkg
OK https://api.nuget.org/v3-flatcontainer/azure.security.keyvault.secrets/4.2.0-beta.5/azure.security.keyvault.secrets.4.2.0-beta.5.nupkg 13ms
Acquiring lock for the installation of Azure.Security.KeyVault.Secrets 4.2.0-beta.5
Acquired lock for the installation of Azure.Security.KeyVault.Secrets 4.2.0-beta.5
Installing Azure.Security.KeyVault.Secrets 4.2.0-beta.5.
OK https://api.nuget.org/v3-flatcontainer/epplus/5.6.3/epplus.5.6.3.nupkg 55ms
OK https://api.nuget.org/v3-flatcontainer/microsoft.netcore.platforms/1.1.0/microsoft.netcore.platforms.1.1.0.nupkg 52ms
Acquiring lock for the installation of Microsoft.NETCore.Platforms 1.1.0
Acquiring lock for the installation of EPPlus 5.6.3
Acquired lock for the installation of EPPlus 5.6.3
Installing EPPlus 5.6.3.
OK https://api.nuget.org/v3-flatcontainer/microsoft.bcl.asyncinterfaces/1.0.0/microsoft.bcl.asyncinterfaces.1.0.0.nupkg 54ms
Acquiring lock for the installation of Microsoft.Bcl.AsyncInterfaces 1.0.0
OK https://api.nuget.org/v3-flatcontainer/system.memory/4.5.4/system.memory.4.5.4.nupkg 53ms
Acquiring lock for the installation of System.Memory 4.5.4
Acquired lock for the installation of Microsoft.NETCore.Platforms 1.1.0
Installing Microsoft.NETCore.Platforms 1.1.0.
Acquired lock for the installation of System.Memory 4.5.4
Installing System.Memory 4.5.4.
OK https://api.nuget.org/v3-flatcontainer/microsoft.io.recyclablememorystream/1.4.1/microsoft.io.recyclablememorystream.1.4.1.nupkg 55ms
Acquiring lock for the installation of Microsoft.IO.RecyclableMemoryStream 1.4.1
OK https://api.nuget.org/v3-flatcontainer/azure.identity/1.5.0-beta.1/azure.identity.1.5.0-beta.1.nupkg 59ms
Acquiring lock for the installation of Azure.Identity 1.5.0-beta.1
Acquired lock for the installation of Microsoft.IO.RecyclableMemoryStream 1.4.1
Installing Microsoft.IO.RecyclableMemoryStream 1.4.1.
OK https://api.nuget.org/v3-flatcontainer/microsoft.identity.client.extensions.msal/2.18.4/microsoft.identity.client.extensions.msal.2.18.4.nupkg 56ms
Acquiring lock for the installation of Microsoft.Identity.Client.Extensions.Msal 2.18.4
Acquired lock for the installation of Microsoft.Bcl.AsyncInterfaces 1.0.0
Installing Microsoft.Bcl.AsyncInterfaces 1.0.0.
Acquired lock for the installation of Azure.Identity 1.5.0-beta.1
Installing Azure.Identity 1.5.0-beta.1.
Acquired lock for the installation of Microsoft.Identity.Client.Extensions.Msal 2.18.4
Installing Microsoft.Identity.Client.Extensions.Msal 2.18.4.
OK https://api.nuget.org/v3-flatcontainer/azure.core/1.15.0/azure.core.1.15.0.nupkg 59ms
Acquiring lock for the installation of Azure.Core 1.15.0
Acquired lock for the installation of Azure.Core 1.15.0
Installing Azure.Core 1.15.0.
OK https://api.nuget.org/v3-flatcontainer/azure.security.keyvault.keys/4.2.0-beta.6/azure.security.keyvault.keys.4.2.0-beta.6.nupkg 67ms
Acquiring lock for the installation of Azure.Security.KeyVault.Keys 4.2.0-beta.6
Acquired lock for the installation of Azure.Security.KeyVault.Keys 4.2.0-beta.6
Installing Azure.Security.KeyVault.Keys 4.2.0-beta.6.
OK https://api.nuget.org/v3-flatcontainer/microsoft.reportviewer.webforms/10.0.40219.1/microsoft.reportviewer.webforms.10.0.40219.1.nupkg 76ms
Acquiring lock for the installation of Microsoft.ReportViewer.WebForms 10.0.40219.1
Acquired lock for the installation of Microsoft.ReportViewer.WebForms 10.0.40219.1
Installing Microsoft.ReportViewer.WebForms 10.0.40219.1.
OK https://api.nuget.org/v3-flatcontainer/netstandard.library/2.0.0/netstandard.library.2.0.0.nupkg 89ms
Acquiring lock for the installation of NETStandard.Library 2.0.0
Acquired lock for the installation of NETStandard.Library 2.0.0
Installing NETStandard.Library 2.0.0.
OK https://api.nuget.org/v3-flatcontainer/microsoft.reportviewer.common/10.0.40219.1/microsoft.reportviewer.common.10.0.40219.1.nupkg 99ms
Acquiring lock for the installation of Microsoft.ReportViewer.Common 10.0.40219.1
Acquired lock for the installation of Microsoft.ReportViewer.Common 10.0.40219.1
Installing Microsoft.ReportViewer.Common 10.0.40219.1.
OK https://api.nuget.org/v3-flatcontainer/system.buffers/4.5.1/system.buffers.4.5.1.nupkg 113ms
Acquiring lock for the installation of System.Buffers 4.5.1
OK https://api.nuget.org/v3-flatcontainer/system.diagnostics.diagnosticsource/4.6.0/system.diagnostics.diagnosticsource.4.6.0.nupkg 120ms
Acquiring lock for the installation of System.Diagnostics.DiagnosticSource 4.6.0
Acquired lock for the installation of System.Buffers 4.5.1
Installing System.Buffers 4.5.1.
Acquired lock for the installation of System.Diagnostics.DiagnosticSource 4.6.0
Installing System.Diagnostics.DiagnosticSource 4.6.0.
OK https://api.nuget.org/v3-flatcontainer/microsoft.identity.client/4.30.1/microsoft.identity.client.4.30.1.nupkg 2052ms
Acquiring lock for the installation of Microsoft.Identity.Client 4.30.1
Acquired lock for the installation of Microsoft.Identity.Client 4.30.1
Installing Microsoft.Identity.Client 4.30.1.
Completed installation of Microsoft.NETCore.Platforms 1.1.0
Adding package 'Microsoft.NETCore.Platforms.1.1.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Microsoft.NETCore.Platforms.1.1.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Microsoft.NETCore.Platforms.1.1.0' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Restoring NuGet package System.Memory.Data.1.0.2.
GET https://api.nuget.org/v3-flatcontainer/system.memory.data/1.0.2/system.memory.data.1.0.2.nupkg
Completed installation of Azure.Security.KeyVault.Secrets 4.2.0-beta.5
Completed installation of Azure.Security.KeyVault.Keys 4.2.0-beta.6
OK https://api.nuget.org/v3-flatcontainer/system.memory.data/1.0.2/system.memory.data.1.0.2.nupkg 8ms
Acquiring lock for the installation of System.Memory.Data 1.0.2
Adding package 'Azure.Security.KeyVault.Secrets.4.2.0-beta.5' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Azure.Security.KeyVault.Secrets.4.2.0-beta.5' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Azure.Security.KeyVault.Secrets.4.2.0-beta.5' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Restoring NuGet package System.Numerics.Vectors.4.5.0.
Acquired lock for the installation of System.Memory.Data 1.0.2
Installing System.Memory.Data 1.0.2.
GET https://api.nuget.org/v3-flatcontainer/system.numerics.vectors/4.5.0/system.numerics.vectors.4.5.0.nupkg
Adding package 'Azure.Security.KeyVault.Keys.4.2.0-beta.6' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Azure.Security.KeyVault.Keys.4.2.0-beta.6' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Azure.Security.KeyVault.Keys.4.2.0-beta.6' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Restoring NuGet package System.Runtime.CompilerServices.Unsafe.4.6.0.
GET https://api.nuget.org/v3-flatcontainer/system.runtime.compilerservices.unsafe/4.6.0/system.runtime.compilerservices.unsafe.4.6.0.nupkg
Completed installation of Microsoft.Identity.Client.Extensions.Msal 2.18.4
Adding package 'Microsoft.Identity.Client.Extensions.Msal.2.18.4' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Microsoft.Identity.Client.Extensions.Msal.2.18.4' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Microsoft.Identity.Client.Extensions.Msal.2.18.4' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Restoring NuGet package System.Security.Cryptography.ProtectedData.4.5.0.
GET https://api.nuget.org/v3-flatcontainer/system.security.cryptography.protecteddata/4.5.0/system.security.cryptography.protecteddata.4.5.0.nupkg
OK https://api.nuget.org/v3-flatcontainer/system.security.cryptography.protecteddata/4.5.0/system.security.cryptography.protecteddata.4.5.0.nupkg 7ms
Acquiring lock for the installation of System.Security.Cryptography.ProtectedData 4.5.0
Acquired lock for the installation of System.Security.Cryptography.ProtectedData 4.5.0
Installing System.Security.Cryptography.ProtectedData 4.5.0.
Completed installation of Azure.Identity 1.5.0-beta.1
Adding package 'Azure.Identity.1.5.0-beta.1' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Azure.Identity.1.5.0-beta.1' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Azure.Identity.1.5.0-beta.1' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Restoring NuGet package System.Text.Encodings.Web.4.7.2.
GET https://api.nuget.org/v3-flatcontainer/system.text.encodings.web/4.7.2/system.text.encodings.web.4.7.2.nupkg
Completed installation of Microsoft.Bcl.AsyncInterfaces 1.0.0
Adding package 'Microsoft.Bcl.AsyncInterfaces.1.0.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Microsoft.Bcl.AsyncInterfaces.1.0.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Microsoft.Bcl.AsyncInterfaces.1.0.0' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Restoring NuGet package System.Text.Json.4.6.0.
GET https://api.nuget.org/v3-flatcontainer/system.text.json/4.6.0/system.text.json.4.6.0.nupkg
OK https://api.nuget.org/v3-flatcontainer/system.numerics.vectors/4.5.0/system.numerics.vectors.4.5.0.nupkg 811ms
OK https://api.nuget.org/v3-flatcontainer/system.text.encodings.web/4.7.2/system.text.encodings.web.4.7.2.nupkg 677ms
Acquiring lock for the installation of System.Text.Encodings.Web 4.7.2
Acquiring lock for the installation of System.Numerics.Vectors 4.5.0
OK https://api.nuget.org/v3-flatcontainer/system.runtime.compilerservices.unsafe/4.6.0/system.runtime.compilerservices.unsafe.4.6.0.nupkg 807ms
Acquiring lock for the installation of System.Runtime.CompilerServices.Unsafe 4.6.0
OK https://api.nuget.org/v3-flatcontainer/system.text.json/4.6.0/system.text.json.4.6.0.nupkg 670ms
Acquiring lock for the installation of System.Text.Json 4.6.0
Acquired lock for the installation of System.Text.Encodings.Web 4.7.2
Installing System.Text.Encodings.Web 4.7.2.
Acquired lock for the installation of System.Numerics.Vectors 4.5.0
Installing System.Numerics.Vectors 4.5.0.
Acquired lock for the installation of System.Text.Json 4.6.0
Installing System.Text.Json 4.6.0.
Acquired lock for the installation of System.Runtime.CompilerServices.Unsafe 4.6.0
Installing System.Runtime.CompilerServices.Unsafe 4.6.0.
OK https://api.nuget.org/v3-flatcontainer/system.threading.tasks.extensions/4.5.2/system.threading.tasks.extensions.4.5.2.nupkg 9ms
Acquiring lock for the installation of System.Threading.Tasks.Extensions 4.5.2
Completed installation of Microsoft.IO.RecyclableMemoryStream 1.4.1
Completed installation of System.Memory 4.5.4
Completed installation of Azure.Core 1.15.0
Adding package 'Azure.Core.1.15.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Azure.Core.1.15.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Azure.Core.1.15.0' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Completed installation of System.Diagnostics.DiagnosticSource 4.6.0
Adding package 'System.Diagnostics.DiagnosticSource.4.6.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'System.Diagnostics.DiagnosticSource.4.6.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'System.Diagnostics.DiagnosticSource.4.6.0' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Completed installation of System.Runtime.CompilerServices.Unsafe 4.6.0
Adding package 'System.Runtime.CompilerServices.Unsafe.4.6.0' to folder 'D:\a\1\s\LabCode\packages'
Completed installation of System.Text.Encodings.Web 4.7.2
Adding package 'System.Text.Encodings.Web.4.7.2' to folder 'D:\a\1\s\LabCode\packages'
Added package 'System.Runtime.CompilerServices.Unsafe.4.6.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'System.Runtime.CompilerServices.Unsafe.4.6.0' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Added package 'System.Text.Encodings.Web.4.7.2' to folder 'D:\a\1\s\LabCode\packages'
Added package 'System.Text.Encodings.Web.4.7.2' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Completed installation of System.Threading.Tasks.Extensions 4.5.2
Adding package 'System.Threading.Tasks.Extensions.4.5.2' to folder 'D:\a\1\s\LabCode\packages'
Added package 'System.Threading.Tasks.Extensions.4.5.2' to folder 'D:\a\1\s\LabCode\packages'
Added package 'System.Threading.Tasks.Extensions.4.5.2' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Completed installation of System.Text.Json 4.6.0
Adding package 'System.Text.Json.4.6.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'System.Text.Json.4.6.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'System.Text.Json.4.6.0' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Completed installation of System.Security.Cryptography.ProtectedData 4.5.0
Completed installation of Microsoft.ReportViewer.WebForms 10.0.40219.1
Adding package 'System.Security.Cryptography.ProtectedData.4.5.0' to folder 'D:\a\1\s\LabCode\packages'
Adding package 'Microsoft.ReportViewer.WebForms.10.0.40219.1' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Microsoft.ReportViewer.WebForms.10.0.40219.1' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Microsoft.ReportViewer.WebForms.10.0.40219.1' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Added package 'System.Security.Cryptography.ProtectedData.4.5.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'System.Security.Cryptography.ProtectedData.4.5.0' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Completed installation of System.ValueTuple 4.5.0
Adding package 'System.ValueTuple.4.5.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'System.ValueTuple.4.5.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'System.ValueTuple.4.5.0' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Completed installation of System.Numerics.Vectors 4.5.0
Adding package 'System.Numerics.Vectors.4.5.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'System.Numerics.Vectors.4.5.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'System.Numerics.Vectors.4.5.0' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Completed installation of Microsoft.ReportViewer.Common 10.0.40219.1
Adding package 'Microsoft.ReportViewer.Common.10.0.40219.1' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Microsoft.ReportViewer.Common.10.0.40219.1' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Microsoft.ReportViewer.Common.10.0.40219.1' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Completed installation of NETStandard.Library 2.0.0
Adding package 'NETStandard.Library.2.0.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'NETStandard.Library.2.0.0' to folder 'D:\a\1\s\LabCode\packages'
Added package 'NETStandard.Library.2.0.0' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Completed installation of Microsoft.Identity.Client 4.30.1
Adding package 'Microsoft.Identity.Client.4.30.1' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Microsoft.Identity.Client.4.30.1' to folder 'D:\a\1\s\LabCode\packages'
Added package 'Microsoft.Identity.Client.4.30.1' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
Completed installation of EPPlus 5.6.3
Adding package 'EPPlus.5.6.3' to folder 'D:\a\1\s\LabCode\packages'
Added package 'EPPlus.5.6.3' to folder 'D:\a\1\s\LabCode\packages'
Added package 'EPPlus.5.6.3' to folder 'D:\a\1\s\LabCode\packages' from source 'https://api.nuget.org/v3/index.json'
NuGet Config files used:
D:\a\1\Nuget\tempNuGet_108.config
Feeds used:
https://api.nuget.org/v3/index.json
Installed:
24 package(s) to packages.config projects
Finishing: NuGet restore
All the nuGet packages are being restored to d:\a\1\s\LabCode\packages folder
Then when the msbuild runs it gives the following output with the errors:
##[section]Starting: Build solution
==============================================================================
Task : Visual Studio build
Description : Build with MSBuild and set the Visual Studio version property
Version : 1.187.0
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build
==============================================================================
##[command]"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" "D:\a\1\s\LabCode.sln" /nologo /nr:false /dl:CentralLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.187.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=bd1b54f4-cf00-4079-a811-339152db6b3e|SolutionDir=D:\a\1\s"*ForwardingLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.187.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="D:\a\1\a\\" /p:platform="any cpu" /p:configuration="debug" /p:VisualStudioVersion="15.0" /p:_MSDeployUserAgent="VSTS_811f008f-007e-4c35-a27e-d88722b3949b_build_8_0"
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 6/14/2021 3:03:22 PM.
Project "D:\a\1\s\LabCode.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "debug|any cpu".
##[warning]D:\a\1\s\LabCode.metaproj(0,0): Warning MSB3030: Could not copy the file "D:\a\1\s\packages\EPPlus.5.6.3\lib\net40\EPPlus.dll" because it was not found.
Project "D:\a\1\s\LabCode.sln" (1) is building "D:\a\1\s\LabCode.metaproj" (2) on node 1 (default targets).
D:\a\1\s\LabCode.metaproj : warning MSB3030: Could not copy the file "D:\a\1\s\packages\EPPlus.5.6.3\lib\net40\EPPlus.dll" because it was not found.
The previous error was converted to a warning because the task was called with ContinueOnError=true.
Build continuing because "ContinueOnError" on the task "Copy" is set to "true".
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /localhost_59094 -p LabCode\ -u -f -d PrecompiledWeb\localhost_59094\
##[error]LabCode\App_Code\Util.cs(6,0): Error CS0246: The type or namespace name 'Azure' could not be found (are you missing a using directive or an assembly reference?)
d:\a\1\s\LabCode\App_Code\Util.cs(6): error CS0246: The type or namespace name 'Azure' could not be found (are you missing a using directive or an assembly reference?) [D:\a\1\s\LabCode.metaproj]
##[error]LabCode\App_Code\Util.cs(7,0): Error CS0246: The type or namespace name 'Azure' could not be found (are you missing a using directive or an assembly reference?)
d:\a\1\s\LabCode\App_Code\Util.cs(7): error CS0246: The type or namespace name 'Azure' could not be found (are you missing a using directive or an assembly reference?) [D:\a\1\s\LabCode.metaproj]
Done Building Project "D:\a\1\s\LabCode.metaproj" (default targets) -- FAILED.
Done Building Project "D:\a\1\s\LabCode.sln" (default targets) -- FAILED.
Build FAILED.
"D:\a\1\s\LabCode.sln" (default target) (1) ->
"D:\a\1\s\LabCode.metaproj" (default target) (2) ->
(Build target) ->
D:\a\1\s\LabCode.metaproj : warning MSB3030: Could not copy the file "D:\a\1\s\packages\EPPlus.5.6.3\lib\net40\EPPlus.dll" because it was not found.
"D:\a\1\s\LabCode.sln" (default target) (1) ->
"D:\a\1\s\LabCode.metaproj" (default target) (2) ->
(Build target) ->
d:\a\1\s\LabCode\App_Code\Util.cs(6): error CS0246: The type or namespace name 'Azure' could not be found (are you missing a using directive or an assembly reference?) [D:\a\1\s\LabCode.metaproj]
d:\a\1\s\LabCode\App_Code\Util.cs(7): error CS0246: The type or namespace name 'Azure' could not be found (are you missing a using directive or an assembly reference?) [D:\a\1\s\LabCode.metaproj]
1 Warning(s)
2 Error(s)
Time Elapsed 00:00:19.77
##[error]Process 'msbuild.exe' exited with code '1'.
##[section]Finishing: Build solution
So even though the NuGet task completed successfully and restored the Azure packages, it cant find them (EPPlus is not able be be found and then it gives error about the Azure missing reference)
nuget.exe version 4.4.1 is too old and it inevitably causes some unclear problems during the recovery process.
I suggest you could try to use the latest nuget version 5.9.1 to restore nuget packages. Also, do not forget not to use the local nuget caches.
Like this:
5.x means the latest nuget.exe version.
And check this option.

Why nuget package installation failed due to not responding of irrelevant package source

I was playing with dotnet cli to create f# project. I ran the following command to install NewtonSoft.Json NuGet Package.
$>dotnet add src/Library/Library.fsproj package Newtonsoft.Json
the output is
Writing C:\Users\MyUserName\AppData\Local\Temp\tmp440E.tmp
info : Adding PackageReference for package 'Newtonsoft.Json' into project 'src/Library/Library.fsproj'.
info : Restoring packages for c:\Learning\Projects\FSNetCore\FSNetCore\src\Library\Library.fsproj...
info : GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json
info : OK https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json 288ms
error: Unable to load the service index for source https://MyEmployer.pkgs.visualstudio.com/_packaging/NuGetServerName/nuget/v3/index.json.
error: Response status code does not indicate success: 401 (Unauthorized).
I am wondering why this operation has failed due to 401 response from a irrelevant package source which is a private azure artifacts pointed by user-level scoped Nuget.Config file.
$>dotnet nuget --version
NuGet Command Line
5.2.0.3
Package can be installed successfully to projecy by specifying Source and version explicitly
$> dotnet add src/Library/Library.fsproj package Newtonsoft.Json --source https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json --version 12.0.2
Writing C:\Users\MyUserName\AppData\Local\Temp\tmp8A3B.tmp
info : Adding PackageReference for package 'Newtonsoft.Json' into project 'src/Library/Library.fsproj'.
info : Restoring packages for c:\Learning\Projects\FSNetCore\FSNetCore\src\Library\Library.fsproj...
info : Package 'Newtonsoft.Json' is compatible with all the specified frameworks in project 'src/Library/Library.fsproj'.
info : PackageReference for package 'Newtonsoft.Json' version '12.0.2' added to file 'c:\Learning\Projects\FSNetCore\FSNetCore\src\Library\Library.fsproj'.
info : Committing restore...
info : Writing assets file to disk. Path: c:\Learning\Projects\FSNetCore\FSNetCore\src\Library\obj\project.assets.json
log : Restore completed in 193.98 ms for c:\Learning\Projects\FSNetCore\FSNetCore\src\Library\Library.fsproj.
Why dotnet cli tried to load the service index from irrelevant package source ?

Stripe.net nuget package doesn't recognize json.net 9.0.1

I'm trying to install the Stripe.net 6.12.0 nuget package in my project. It has a dependency on the Json.NET 9.0.1 nuget package which I have installed, but when I go to install stripe.net, visual studio gives me the error message: "Stripe.NET already has a dependency defined for"Newtonsoft.Json'. What do I have to do to install Stripe.NET?
Was not obvious from the error message, but the solution was simply to upgrade Nuget. Was using 2.8.xxx and upgraded to the latest which is 2.12.xxx. Restarted. Fixed the problem.

Cannot install Hangfire to my existing project

I have an existing ASP.NET project and it's not in MVC. When I try to install Hangire I get this error.
PM> Install-Package Hangfire
Attempting to gather dependency information for package 'Hangfire.1.5.8' with respect to project 'FYMAS', targeting '.NETFramework,Version=v4.0'
Attempting to resolve dependencies for package 'Hangfire.1.5.8' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Hangfire.1.5.8'
Resolved actions to install package 'Hangfire.1.5.8'
Adding package 'Newtonsoft.Json.5.0.1' to folder 'C:\Users\User\Desktop\hang\packages'
Added package 'Newtonsoft.Json.5.0.1' to folder 'C:\Users\User\Desktop\hang\packages'
Added package 'Newtonsoft.Json.5.0.1' to 'packages.config'
Successfully installed 'Newtonsoft.Json 5.0.1' to FYMAS
Install failed. Rolling back...
Package 'Hangfire.Core.1.5.8 : Newtonsoft.Json [5.0.0, ), Owin [1.0.0, )' does not exist in project 'FYMAS'
Removed package 'Newtonsoft.Json.5.0.1' from 'packages.config'
Package 'Hangfire.Core.1.5.8 : Newtonsoft.Json [5.0.0, ), Owin [1.0.0, )' does not exist in folder 'C:\Users\User\Desktop\hang\packages'
Removing package 'Newtonsoft.Json.5.0.1' from folder 'C:\Users\User\Desktop\hang\packages'
Removed package 'Newtonsoft.Json.5.0.1' from folder 'C:\Users\User\Desktop\hang\packages'
Install-Package : Could not install package 'Hangfire.Core 1.5.8'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', 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.
At line:1 char:1
+ Install-Package Hangfire
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
I tried to install owin to my project using Install-Package Owin command, this installation is success but when I try to install hanfire again, I got the same error. I tried installing an older version of hangfire using Install-Package HangFire -Version 1.4.6, but got the same error.
It seems your problem is your .NET framework, you are using 4.0, then you should install hangfire for your framework, try this
Install-Package Hangfire_net40
When you use Install-Package Hangfire, this will install the latest stable version (in your case Hangfire.1.5.8, this requires newer .net framework ~ 4.5). For more details, Hangfire (.Net 4.0) 1.1.1

Could not install Microsoft.AspNet.Razor 3.0.0

I am working on an ASP.NET project in which I need to do simple HTML templating.
The prettiest solution seems to be RazorEngine, which depends on Microsoft.AspNet.Razor. However, when trying to install Microsoft.AspNet.Razor via Nuget, the following error message is shown:
Installing 'Microsoft.AspNet.Razor 3.0.0'. Successfully
installed 'Microsoft.AspNet.Razor 3.0.0'. Adding
'Microsoft.AspNet.Razor 3.0.0' to EBulkDBSManagementApp.
Uninstalling 'Microsoft.AspNet.Razor 3.0.0'. Successfully
uninstalled 'Microsoft.AspNet.Razor 3.0.0'. Install failed.
Rolling back... Could not install package
'Microsoft.AspNet.Razor 3.0.0'. You are trying to install this package
into a project that targets '.NETFramework,Version=v4.0', 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.
Any solution?
The latest RazorEngine 3.4.0 NuGet package depends on the Microsoft.AspNet.Razor 3.0.0 NuGet package which requires .Net 4.5
If you wish to use RazorEngine with a version of .NET prior to 4.5, then you will need to use the RazorEngine 3.3.0 NuGet pacakage.
You can install this using the package manager console with the following command.
Install-Package RazorEngine -Version 3.3.0

Resources