ASP.Net Core WebApi Project creates an empty solution - asp.net

I am trying to create a ASP.Net Core WebAPI application, i installed every sdk and runtime i was told to.
I then go into Visual Studio and create the Project from the ProjectCreator.
What I end up with is an empty solution and a project in the specified directory that i cannot open, with the error message the Project cannot be opened because it couldnt find a fitting sdk
(btw, creating it with .netCore3.1)
Heres a list of my installed sdks/runtimes:
.NET Core Runtime 2.1
.NET Core Runtime 3.1
.NET Core SDK 3.1.1
.NET Core SDK 3.1.4
.NET Runtime 5.0
.NET SDK 5.0.2
.NET SDK 5.0.3
ASP.NET Core 3.1.17
ASP.NET Core 5.0.8
This is what my solution explorer looks like tho the csproj is correctly placed
Whats seems to be the problem? Too many runtimes/sdk?
Are they overriding each other? Visual Studio cannot choose? I am baffled, this should work :/
[Edit1]
This is the guide I am following: https://learn.microsoft.com/de-de/aspnet/core/tutorials/first-web-api?view=aspnetcore-5.0&tabs=visual-studio
[Edit2]
I found a command that lets you see every sdk and runtime the dotnet/cli can access/see
(dotnet --info)
Looks like dotnet doesnt seem to find an sdk i installed
[Edit3]
I tried to manually install the .net core SDK 3.1 binaries into the C:\ProgramFiles\dotnet folder, but to no avail, dotnet --info still doesnt recognize the SDK
[Edit4]
I got it working, I will post the solution as an answer.

Heres what I did:
I uninstalled my Visual Studio IDE with the Visual Studio Installer
I uninstalled every .NET (Core) SDK and .NET (Core) Runtime
I did a fresh Visual Studio install with only the components i really need
After that I checked the dotnet --info command and there was it, 2 SDKs were installed. When I create the WebAPI Project now, the Solution Explorer has a project and I can finally see all files. This was weird. Thanks everyone tho!

Related

How to run .NET framework project with VS Code, which has dependency of ReactJS?

I am beginner to .NET framework and ReactJS. I have a code repository which is .NET framework, with ReactJS dependency.
When I opened the repository, VS Code suggested me to install C# extension, I installed.
Now when I opened the main file abc.csproj; it automatically started installing packages.
It ended with message:
Finished
Failed to spawn 'dotnet --info'
and notified:
The .NET core SDK cannot be located. .NET Core debugging will not be enabled. Make sure the .NET Core SDK is installed and is on path.
What is process and list of extensions if I need it to be ran in VS Code?
P. S. It is a .NET framework 4.5 project and not core .NET project
The C# extension no longer ships with an included Mono & MSBuild Tools...
If you still need Unity or .NET Framework support, you can set
omnisharp.useModernNet to false
in your VS Code settings and restart OmniSharp.
See issue #5120 for more details.
https://github.com/OmniSharp/omnisharp-vscode/issues/5120
it seems you don't have the .net framework SDK installed on your machine.
you can download and install .net sdk from here : https://dotnet.microsoft.com/download/visual-studio-sdks to be able to build .net framework projects
I will suggest to use Microsoft Visual Studio. I am using it and it's good and dragless rather than getting SDKs and having installation troubles.

Build error: COMReference .NET CORE 3.0: AxImp not found

I am trying to compile a .NET CORE 3.0 application that has a COM reference. Unfortunately when trying to build that application that has the reference, I am getting a build error:
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2726,5):
error MSB3091:
Task failed because "AxImp.exe" was not found, or the correct Microsoft Windows SDK is not installed.
The task is looking for "AxImp.exe" in the "bin" subdirectory beneath the location specified in the
InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\4.7.2\WinSDK-NetFx40Tools-x86.
You may be able to solve the problem by doing one of the following:
1) Install the Microsoft Windows SDK.
2) Install Visual Studio 2010.
3) Manually set the above registry key to the correct location.
4) Pass the correct location into the "ToolPath" parameter of the task.
I understand that something is probably wrong with the setup or configuration (?), but cannot figure out what exactly. I have Visual Studio 2019 installed (the latest one at the moment of writing, 16.3.9). The application is set to target .NET CORE 3.0, that should support <ComReference ...> element.
How do I build an application that has a COM REFERENCE with .NET CORE 3.0 using Visual Studio 2019? I am building from VS2019 IDE. As of my understanding, it should not even look for the "AxImp", it should probably look for the "TlbImp". Also, why is it looking for Visual Studio 2010?? Windows SDK is installed. Does it need some specific version? Which one?
I tried to remove and then add the reference again using project references, nothing changed. Am I missing something?
After installing .NET SDK 4.7.2 the problem is gone. I had 4.8 version before (installed by default with VS 2019)

Asp.Net Core 2.1 with .Net Framework 4.6.1 error after deployment using dotnet publish or visual studio publish

I am trying to deploy Asp.Net Core 2.1 application with target framework 4.6.1 on server. I am using dotnet publish command and copying the publish folder on the server where deployment is intended. Everything works fine on local machine. But when I am trying to run the application on the server , it is throwing the exception ".Net Framework 4.6.1 not installed, please install it.".
I thought .Net framework is not installed but when I checked installed software , I can see .Net 4.6.1 is installed. Not sure why the error is occurring.
Here is screenshot for the application error and installed software
That error is odd, since you do indeed seem to have that version installed. However, I believe it may be a red herring. I haven't personally tried to run ASP.NET Core 2.1 on .NET Framework, but I suspect it may not work at the moment. The full framework support depends on .NET Standard compatibility which only goes up to .NET Core 2.0. (With .NET Standard 2.0). ASP.NET Core requires .NET Core 2.1. You can try targeting a later version of .NET Framework - something recent like 4.7.2. You may need to downgrade to ASP.NET Core 2.0, if you need to target .NET Framework.
Your list only shows development packages to support targeting and developing for .NET Framework 4.6.1
See How to: Determine which .NET Framework versions are installed for ways to check the .NET Framework version on the machine.

Where is Microsoft.AspNetCore.Antiforgery library defined in .NET Core 2?

Environment: Ubuntu 16.04
I have written an ASP.NET application that is based on .NET core 1.1. This application works as expected. Today, I just upgraded my server to dotnet-sdk-2.0.0-preview2-006497. After the upgrade, I ran the following commands in my project directory to make sure everything is up to date:
$ dotnet migrate
$ dotnet restore
Now, when I run my application and try to navigate to my login page, I get an error "Cannot find compilation library location for package Microsoft.AspNetCore.Antiforgery."
Wondering how I can fix this. Regards.
As currently dotnet migrate only migrates a Preview 2 .NET Core project to a .NET Core SDK 1.0 project, you have to manually update your app to targeted to .NET Core 2.0 preview and Microsoft.AspNetCore.Antiforgery dependency in csproj to be 2.0.0-preview2-final (and the same for other dependencies).

Installating .NET Core SDK failes silently - how can I install it?

I want to install the .NET Core SDK 1.1 which I downloaded from the site .NET Core Downloads.
When I try to run the downloaded file dotnet-1.1.1-sdk-win-x64.exe nothing happens at all - no windows, no message.
The Windows task manager shows shortly the dotnet-1.1.1-sdk-win-x64.exe process which disappears in a second or two.
The same happens when I try with .NET Core Runtime dotnet-win-x64.1.1.1.exe.
What does go wrong?
you can check this page for instructions on how to install via command line and confirm if it's working
https://www.microsoft.com/net/core#windowscmd
Personally, I prefer installing Visual Studio and letting Visual Studio configure .net core for me as shown in this page
https://www.microsoft.com/net/core#windowsvs2017
First verify 'IIS'and all other windows features(like ASP.NET) are enabled in your machine.
Then try to install dotnet SDK and Visual Studio 2017.
It will work for sure.

Resources