Dotnet restore not working - nuget

dotnet Version: 1.1.0 (global.json)
NuGet Version : 4.4.1.4656
VS2017 v15.5.2 (as Administrator)
.NET Core 1.1
The solution I am trying to build
Update I:
I just changed the project to run under target framework .NET Core v2.0 & sdk version 2.1.3 and I only get these kind of errors:
Severity Code Description Project File Line Suppression State
Error NU1202 Package Microsoft.Extensions.FileProviders.Physical 1.1.0
is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0).
Package Microsoft.Extensions.FileProviders.Physical 1.1.0 does not
support any target
frameworks. AspNetCoreExample C:\Users\Admin\Source\Repos\Examples\src\AspNetCoreExample\AspNetCoreExample.csproj 1
Update II:
While the following solves the current issue, i am not sure if it solves the root cause for this issue.
Delete the global nuget.config file %AppData%/Nuget/Nuget.config.
I fixed this issue by doing the following:
I migrated the project to .net core 2.0 and changed the global.json to point to sdk 2.1.3.
Removed all references in AspNetCoreExample manually and added the latest version for all of them.
Issues with target framework 1.1
When doing a restore from the solution in VS 2017:
When doing the restore from cmd (dotnet restore)
Running dotnet restore in Package Manager Console
NuGet.targets(103,5): error : Access to the path 'System.Runtime.dll'
is denied
.NET Core SDKs installed:
.NET Host
Now when opening the solution I get:

Comparing the log entries you pasted to their AppVeyor build,
https://ci.appveyor.com/project/Autofac/examples
Your machine's NuGet configuration seems to be broken. Analyze that and fix the issues.

You should add this code to your .csproj file
<RuntimeFramework>2.0.3</RuntimeFramework>
This worked for me.

Related

Why can't I install Microsoft.EntityFrameworkCore.Sqlite?

I am following this tutorial:
https://learn.microsoft.com/en-us/ef/core/get-started/overview/first-app?tabs=visual-studio
I am immediately stopped because I can not complete the following command:
Install-Package Microsoft.EntityFrameworkCore.Sqlite
This is the error:
Could not install package 'Microsoft.EntityFrameworkCore.Sqlite.Core 7.0.0'. You are trying to install a package into a project that targets '.NETFramework,Version=v4.7.2', 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.
I am attempting to learn how to use the Entity Framework and so I don't know much regarding this. Any advice would be helpful even if it's a link to something I need to read.
About the tutorial
The tutorial is about .netCore but in the error message you can see that you created a .netFramework project '.NETFramework,Version=v4.7.2'.
Create a new console application, but don't select projects that have (.NET Framework) in the description.
About the Sqlite package (only if continue the practicing with .netFramework)
The command Install-Package Microsoft.EntityFrameworkCore.Sqlite will try to install the last version. Currently, the last version is 7.0.0. This version only work with .NET 6.0.
You can check existing .net versions right here
So, you need to specify the version. The version for .NET 4.7.2 is the 3.1.31.
Install-Package Microsoft.EntityFrameworkCore.Sqlite -Version 3.1.31
Nuget Sqlite package info here

Omnisharp error about dotnet version - Unity

at VSCode launch today I'm receiving this error:
Starting OmniSharp server at 27/5/2022, 12:37:25
Target: f:\UnityProjects\MyGame.sln
[ERROR] Error: Found dotnet version 5.0.407. Minimum required version is 6.0.100.
I read that there have been updates in omnisharp but I really don't know how to fix the issue.
I've installed dotnet 6.0 TLS through a new visual studio installation... is there anything else I can do to bring dotnet working with my Unity project?
If you're using C# extension 1.25.0 they announced a change in the extension's details page:
.NET Framework builds of OmniSharp no longer ship with Mono or the
MSBuild tooling (See announcement omnisharp-roslyn#2339). To ensure
that the C# extension remains usable out of the box for .NET SDK
projects, we have changed the default value of omnisharp.useModernNet
to true.
If you still need Unity or .NET Framework support, you can set
omnisharp.useModernNet to false in your VS Code settings and restart
OmniSharp.
Changing that omnisharp.useModernNet setting to false worked for me.
If you use vscode for web development and your installed dotnet SDK version is < 6, this answer might be useful.
After quite some time I spotted an Ominisharp Log warning this.
[ERROR] Error: Found dotnet version 3.1.419. Minimum required version is 6.0.100.
Solution
Install dotnet SDK 6 alongside or by replacing your current version.
I recommend you install it by using the dotnet-install.{sh | ps1} script.
By running the command below it will install the latest version alongside your current one.
sudo ./dotnet-install.sh -c 6.0 --install-dir /usr/share/dotnet
~ ยป dotnet --list-sdks
3.1.419 [/usr/share/dotnet/sdk]
6.0.300 [/usr/share/dotnet/sdk]

Mac - VS 8.10 - New 3.1 Project - Install Postsharp

I created a new, console application. Nuget => Add PostSharp =>
Reading project file
/Users/jason/Projects/Postsharp/Postsharp/Postsharp.csproj.
Restoring packages for
/Users/jason/Projects/Postsharp/Postsharp/Postsharp.csproj...
Restoring packages for .NETCoreApp,Version=v3.1... Resolving conflicts
for .NETCoreApp,Version=v3.1... Cycle detected. Postsharp ->
PostSharp (>= 6.10.6). Checking compatibility of packages on
.NETCoreApp,Version=v3.1. Checking compatibility for Postsharp 1.0.0
with .NETCoreApp,Version=v3.1. Checking compatibility for Serilog
2.10.0 with .NETCoreApp,Version=v3.1. All packages and projects are compatible with .NETCoreApp,Version=v3.1. Package restore failed.
Rolling back package changes for 'Postsharp'.
Cycle Detected?
Geez, what am I doing wrong?
Thanks,
Jason
This is caused by naming your project PostSharp and having a dependency on the package of the same name.
Daniel, you were right, the project name was part of the problem.
The biggest issue was I needed to manually set PostSharpDependencyRestoreDisabled=True and then I had to manually add all the referenced Nuget packages. It was annoying, but at least it works now.
Thanks!

Azure Devops - Compatibility problems moving from .NET Core 3.1 to .NET 5 at Nuget Package

I have a .NET Core solution which was running well using .NET Core 3.1 using a Pipeline on Azure Devops. Everything was working fine on the Pipeline.
After moving from .NET Core 3.1 to .NET 5.0, I started to have some strange troubles running the pipeline, specifically with Nuget packages.
I can build with no problems, but when it starts to pack using Nuget Package, I've got this error:
[error] The nuget command failed with exit code(1)
NU1202: Package Microsoft.EntityFrameworkCore 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
Some weird fact is that this solution is running fine at the local machine.
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.8.8.9</Version>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
I already tried to change the OS on the Build, but I've got this error:
The current available version of MSBuild is 16.7.0.37604. Change the .NET Core SDK specified in global.json to an older version that requires the MSBuild version currently available.
Does someone have an idea?
Package Microsoft.EntityFrameworkCore.Relational 5.0.0 supports:
netstandard2.1 (.NETStandard,Version=v2.1)
This is because it was using an old version of Nuget. You can try to change it to 5.x and restore.
Here is a case with similar issue you can refer to.

Nuget "Older to New" Update Failed

I want to update project for Asp.NET Web Api 2.2 (My project is Web Api 1.0). But Nuget doesn't update all package and i didn't find this problem's solve.
Can you help me for this problem ?
Failed Text:
Updating 'Microsoft.AspNet.WebApi.Core 4.0.30506.0' to 'Microsoft.AspNet.WebApi.Core 5.2.0' failed. Unable to find a version of 'Strathweb.CacheOutput' that is compatible with 'Microsoft.AspNet.WebApi.Core 5.2.0'.
It looks like the current build of Strathweb.CacheOutput (0.5.0) package is fixed to WebApi 4.0.30506.
You have 2 options:
Contact the package owner and ask them to allow the package to work with newer versions of WebApi
Use the command line for NuGet in Visual Studio to force the package update by specifying the -IgnoreDependencies argument
Either way, you will need a binding redirect for Microsoft.AspNet.WebApi.Core 4.0.30506.0 -> 5.2.0, depending on which option you use, NuGet may add this to your web.config for you.