Cannot install dotnet-ef tool on Windows 10 - c#

I'm trying to install the dotnet-ef tool via the dotnet-cli.
The command that I enter: dotnet tool install --global dotnet-ef
I gives me the following error:
The tool package could not be restored.
Tool 'dotnet-ef' failed to install. This failure may have been caused by:
* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET Core tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.
I'm using dotnet 3.0, I believe I didn't have this problem on MacOS, I'm now trying to execute the same command on my Windows 10 machine and it gives me that error.
Some info using dotnet --info command:
.NET Core SDK (reflecting any global.json):
Version: 3.0.100
Commit: 04339c3a26
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100\
Host (useful for support):
Version: 3.0.0
Commit: 7d57652f33
.NET Core SDKs installed:
3.0.100 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

I got it working by adding the --version flag and specifying the version to 3.0.0.
The command that I used:
dotnet tool install --global dotnet-ef --version 3.0.0

dotnet tool install -g dotnet-ef --ignore-failed-sources worked for me. Thanks to Anas-Alhariri
Source

I had the same issue on Mac OS recently.
It was related to the fact that we use our own NuGet feed (packageSources section).
So, I fixed that by removing the custom NuGet feed from NuGet.config file for a while.

If everything else failed then you should check in your Visual Studio the next route: Tools > NuGet Package Manager > Package Manager Settings > Nuget Package Manager > Package Sources.
There you should have nuget.org, if not and you only have Microsoft Visual Studio Offline Packages, well that is the problem. Next you need to add the package resource nuget.org like this:
Once you click Ok you can go back to your terminal and install dotnet-ef with no problem.

I got this error message, but when I closely inspected all the errors I also had:
Response status code does not indicate success: 407 (Proxy Authorization Required).
Turning off the proxy while running the command fixed the issue.

I got this error when I tried to run the command from the Package Manager Console instead of a Powershell command window.

For some of reasons you can try to delete directory C:\Program Files\dotnet\sdk-manifests it will make you can download it.
.net 6
ref : https://github.com/dotnet/sdk/issues/23435

Related

It was not possible to find any installed .NET SDKs

I have installed multiple versions of .NET Sdk.Now the Omnisharp suggestions is not working fine.
output shows these
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /BO-V2/Techne-Travel/travel-techne-bo-for-ota/src/Application/Application.csproj
A compatible installed .NET SDK for global.json version [6.0.101] from [/BO-V2/Techne-Travel/travel-techne-bo-for-ota/global.json] was not found.
Install the [6.0.101] .NET SDK or update [/BO-V2/Techne-Travel/travel-techne-bo-for-ota/global.json] with an installed .NET SDK:
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
https://aka.ms/dotnet-download
A compatible installed .NET SDK for global.json version [6.0.101] from [/BO-V2/Techne-Travel/travel-techne-bo-for-ota/global.json] was not found.
Install the [6.0.101] .NET SDK or update [/BO-V2/Techne-Travel/travel-techne-bo-for-ota/global.json] with an installed .NET SDK:
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
https://aka.ms/dotnet-download
[fail]: OmniSharp.MSBuild.ProjectLoader
Unable to locate the .NET SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.
[fail]: OmniSharp.MSBuild.ProjectLoader
The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found.
[fail]: OmniSharp.MSBuild.ProjectManager
But dotnet --info shows this output
.NET SDK (reflecting any global.json):
Version: 6.0.101
Commit: ef49f6213a
Runtime Environment:
OS Name: ubuntu
OS Version: 20.04
OS Platform: Linux
RID: ubuntu.20.04-x64
Base Path: /usr/share/dotnet/sdk/6.0.101/
Host (useful for support):
Version: 6.0.1
Commit: 3a25a7f1cc
.NET SDKs installed:
3.1.415 [/usr/share/dotnet/sdk]
5.0.100 [/usr/share/dotnet/sdk]
5.0.209 [/usr/share/dotnet/sdk]
5.0.403 [/usr/share/dotnet/sdk]
6.0.100 [/usr/share/dotnet/sdk]
6.0.101 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.21 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.12 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.21 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.13 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
which dotnet command
/usr/bin/dotnet
I have searched in google and find this
https://www.py4u.net/discuss/1941159.
I did below as they said.
But Still I face the same issue.
Why this issue? How can I solve this
setting.json
{
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll": false
},
"omnisharp.path": "latest",
}
omnisharp.json
{
"MsBuild": {
"UseLegacySdkResolver": true
}
}
global.json
{
"sdk": {
"version": "6.0.101",
"rollForward": "latestMinor"
}
}
What should I do to make omnisharp works fine?
I could not continue the work without Omnisharp Suggestion. It is hard to code. Please help me.
See the documentation here https://github.com/OmniSharp/omnisharp-vscode
Using .NET 6 builds of OmniSharp Starting with C# extension version
1.24.0, there is now an option to use build of OmniSharp that runs on the .NET 6 SDK. This build requires that the .NET 6 SDK be installed
and does not use Visual Studio MSBuild tools or Mono. It only supports
newer SDK-style projects that are buildable with dotnet build. Unity
projects and other Full Framework projects are not supported.
To use the .NET 6 build, set omnisharp.useModernNet to true in your VS
Code settings and restart OmniSharp.

/usr/share/dotnet/sdk/2.2.402/NuGet.targets(123,5): error : Root element is missing. [~/projects/test-proj/test-proj.csproj]

So now dotnet restore started throwing this error:
/usr/share/dotnet/sdk/2.2.402/NuGet.targets(123,5): error : Root element is missing. [/home/francardoso/projects/test-proj/test-proj.csproj]
It happens for existing projects, but also if I try to create a fresh new webapi.
Already tried to reinstall dotnet.
Why is this happening?
$ dotnet new webapi -n test-proj
The template "ASP.NET Core Web API" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on test-proj/test-proj.csproj...
/usr/share/dotnet/sdk/2.2.402/NuGet.targets(123,5): error : Root element is missing. [/home/francardoso/projects/test-proj/test-proj.csproj]
Restore failed.
Post action failed.
Description: Restore NuGet packages required by this project.
Manual instructions: Run 'dotnet restore'
dotnet restore /usr/share/dotnet/sdk/2.2.402/NuGet.targets(123,5): error : Root element is missing. [/home/francardoso/projects/test-proj/test-proj.csproj]
$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.2.402
Commit: c7f2f96116
Runtime Environment:
OS Name: ubuntu
OS Version: 18.04
OS Platform: Linux
RID: ubuntu.18.04-x64
Base Path: /usr/share/dotnet/sdk/2.2.402/
Host (useful for support):
Version: 2.2.8
Commit: b9aa1abc51
.NET Core SDKs installed:
2.2.402 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Same on dotnet sdk 6.0.405. Clearing nuget cache worked for me:
dotnet nuget locals all --clear

dotnet ef migrations issue in Ubuntu 19.10. Dotnet sdk 3.1.1

I installed dotnet ef tool in order to generate migrations for a dotnet core project am working on using the command. dotnet tool install -g dotnet-ef. The installation was successfull. In order to us dotnet ef i have installed the nuget packages below
Microsoft.EntityFrameworkCore.SqlServer
Microsoft.EntityFrameworkCore
Microsoft.AspNetCore.Identity.EntityFrameworkCore
Microsoft.EntityFrameworkCore.Tools
When trying to generate migrations using the command dotnet ef migrations add IdentityandCategory i get the output below.
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '3.1.1' was not found.
- The following frameworks were found:
2.1.14 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
2.2.8 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
3.1.0 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.1&arch=x64&rid=ubuntu.19.10-x64
I reinstall dotnet 3.1.1 but this trouble continues. dotnet info seem to detect the version
when i run donet --info
.NET Core SDK (reflecting any global.json):
Version: 3.1.100
Commit: cd82f021f4
Runtime Environment:
OS Name: ubuntu
OS Version: 19.10
OS Platform: Linux
RID: ubuntu.19.10-x64
Base Path: /usr/share/dotnet/sdk/3.1.100/
Host (useful for support):
Version: 3.1.0
Commit: 157910edee
.NET Core SDKs installed:
2.1.802 [/usr/share/dotnet/sdk]
2.2.402 [/usr/share/dotnet/sdk]
3.1.100 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.14 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.14 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.14 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
How can i solve this issues? Thank in advance for your help
I ran into this issue today on Azure Pipelines. The easiest way to fix it is to explicitly install dotnet-ef by specifying the exact version you need.
dotnet tool install --global dotnet-ef --version 3.1.0
I believe that the .NET Core Runtime version and the dotnet-ef version have to be in sync. Since there was a security patch released recently that bumped .NET Core Runtime up to 3.1.1, there is a mismatch and that is why it is complaining.
That said, it is probably wise to just update everything to 3.1.1 when time permits.

The current .NET SDK does not support targeting .NET Core 2.2. (SDK 2.2.202)

Another one of those many many similar issues, yet none of the solutions searched for, helped (see below which one are looked at).
At the moment of writing this, .NET Core v2.2 is out of preview, the latest version being v2.2.202 (release date, 02-04-2019).
I installed that one via "Install other frameworks", I installed the x64 one, all other versions I have installed earlier are also that version.
After installing, when I create a new project, it shows up:
But when I then open the properties, it does not:
dotnet --info within the directory of the project, gives the following result:
.NET Core SDK (reflecting any global.json):
Version: 2.2.202
Commit: 8a7ff6789d
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.2.202\
Host (useful for support):
Version: 2.2.3
Commit: 6b8ad509b6
.NET Core SDKs installed:
2.1.2 [C:\Program Files\dotnet\sdk]
2.1.4 [C:\Program Files\dotnet\sdk]
2.1.201 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.401 [C:\Program Files\dotnet\sdk]
2.1.505 [C:\Program Files\dotnet\sdk]
2.2.202 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.3-servicing-26724-03 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
I have tried:
Create a global.json (SO answer), this only produced more errors as it could not load the project that is targeting v2.2
Enable preview SDKs within Settings (SO answer)
I have tried installing the x86 version, but that gave also more errors as it was confused about which one to use now. So that started complaining about .NET Standard not being installed.
I have updated Visual Studio and Visual Studio Build Tools to the latest versions, which is 15.9.11 (release date, 02-04-2019)
When I build via the command line dotnet build in the solution directory, it builds successfully, so it must be a visual studio thing.
verified that only C:\Program Files\dotnet\ is in the Environment Variables, so C:\Program Files (x86)\dotnet\ is not present.
Looked at these options, did all of them but I did not set the MSBuildSDKsPath environment variable since I have other projects also in need with 2.1. I checked that there is currently no MSBuildSDKsPath set so it should not be forced to that version.
All of the above attempts of course involving restarting the computer or restarting VS.
This most likely looks like an installer optimisation for VS that removes old SDKs being too greedy and remove versions that older VS versions rely on, but at the moment this is more of an hypothesis while MS teams are investigating. See this GitHub issue for more similar reports.
The 2.2.1xx SDK(!) versions use MSBuild 15 and the 2.2.2xx use MSBuild 16.
VS 2017 needs to resolve a local version that is compatible with MSBuild 15 so if 2.2.1xx was removed during an upgrade, this may fail.
You can fix this by re-installing a compatible version - e.g. 2.2.105 - from https://dotnet.microsoft.com/download/dotnet-core/2.2
In order to find out which SDK uses which components, you can check the DependencyVersions.props file in the <3.0 sources and the Versions.props file for >= 3.0 (preview) sources - MSBuild version is set in via the MicrosoftBuildPackageVersion property.
If you are using Visual Studio 2017 (v15.9) you need to install .NET Core SDK version 2.2.108 as greater versions is supported only in Visual Studio 2019.
See the table below to select the correct download.
Check also release information and download links here
Adding #martin-ullrich's answer from https://github.com/aspnet/AspNetCore.Docs/issues/11844, because it made more sense to me. (Maybe 'cuz it's Friday, and I just needed: "Go here and do this.")
Go to https://dotnet.microsoft.com/download/dotnet-core/2.2 and
download the installer for the 2.2.105 version. Anything >= 2.2.200
will not work in VS 2017. Both 2.2.105 and 2.2.202 contain the latest
and greatest .NET Core 2.2 version but they differ in the version of
the tools they include and are based on - the 1xx train is MSBuild
15., NuGet 4. etc. and the 2xx train is MSBuild 16., NuGet 5. and so on and Visual Studio only looks for the latest version compatible with
its version of MSBuild - for VS 2017 this is 2.1.502 version which
cannot target .NET Core 2.2. (And to add more confusion, there are now
2.1.6xx versions with VS 2019 tool versions together with the .NET Core 2.1 runtime)
[#]leecow and [#]rowanmiller are working on updating that page
regarding VS, also see dotnet/core#2542 and dotnet/sdk#3076 which are
about the same problem.
My contribution: After installing 2.2.105, I deleted the folder(s) titled '2.2.202' in directory C:\Program Files (x86)\dotnet\sdk and/or C:\Program Files\dotnet\sdk so that dotnet --info now reads the following:
Installing dotnet-sdk-2.2.103-win-x64 fixed the issue
Use Visual Studio 2019 instead of 2017 if you want work with asp.net core version more then v2.2.100
https://github.com/aspnet/AspNetCore.Docs/issues/11844

Using Jenkins SonarQube MSBuild plugin with dotnet core on linux

i am struggling to both understand and get the Jenkins SonarQube MSBuild to analyse a dotnet core c# project and hoped someone could help out with it. I am able to run the scan using the following commands in an "Execute Shell" build step:
dotnet sonarscanner begin /k:"xxx" /n:"xxx" /v:"xxx"
dotnet build xx.sln --configuration Release
dotnet sonarscanner end
my current setup is:
Jenkins Server running on Amazon linux, on which i have installed jenkins (version 2.150.2) dotnet core and the sonarqube msbuild plugin
[jenkins#jenkins_qa sonar]# dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.2.104
Commit: 73f036d4ac
Runtime Environment:
OS Name: amzn
OS Version: 2
OS Platform: Linux
RID: linux-x64
Base Path: /usr/share/dotnet/sdk/2.2.104/
Host (useful for support):
Version: 2.2.2
Commit: a4fd7b2c84
.NET Core SDKs installed:
2.1.4 [/usr/share/dotnet/sdk]
2.2.104 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
sonarqube server is installed on an Amazon Windows Instance.
I would like to use the plugin to run the analysis as this will include the report on the jenkins ui.
Thanks in advance

Categories