High CPU usage in VBCSCompiler after update .NET 6 to .NET 7 - asp.net-core-webapi

I have ASP NET Core Web App and after I update .NET 6 to .NET 7 I get High CPU usage in VBCSCompiler when deploy my app in docker
dotnet --info output
`.NET SDK:
Version: 7.0.102
Commit: 4bbdd14480
Runtime Environment:
OS Name: ol
OS Version: 8
OS Platform: Linux
RID: ol.8-x64
Base Path: /usr/lib64/dotnet/sdk/7.0.102/
Host:
Version: 7.0.2
Architecture: x64
Commit: d037e070eb
.NET SDKs installed:
7.0.102 [/usr/lib64/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.2 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.2 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
DOTNET_ROOT [/usr/lib64/dotnet]
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:`
Here is what i get
run dotnet app and get this problem.

Related

Install dotnet ef success but when call it hit error

Error: A fatal error occurred. The required library libhostfxr.so could not be found. If this is a self-contained application, that library should exist in [/home/alanee/.dotnet/tools/.store/dotnet-ef/3.1.3/dotnet-ef/3.1.3/tools/netcoreapp3.1/any/]. If this is a framework-dependent application, install the runtime in the global location [/usr/share/dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet/install_location].
The .NET Core runtime can be found at: - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=ubuntu.20.04-x64
My current dotnet info is: .NET Core SDK (reflecting any global.json): Version: 3.1.201 Commit: b1768b4ae7
Runtime Environment: OS Name: ubuntu OS Version: 20.04 OS Platform: Linux RID: linux-x64 Base Path: /snap/dotnet-sdk/69/sdk/3.1.201/
Host (useful for support): Version: 3.1.3 Commit: 4a9f85e9f8
.NET Core SDKs installed: 3.1.201 [/snap/dotnet-sdk/69/sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.App 3.1.3 [/snap/dotnet-sdk/69/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.3 [/snap/dotnet-sdk/69/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
make the configuration below and use the latest version of dotnet-ef:
export PATH="$PATH:$HOME/.dotnet/tools"
export DOTNET_ROOT=/snap/dotnet-sdk/current
export MSBuildSDKsPath=$DOTNET_ROOT/sdk/$(${DOTNET_ROOT}/dotnet --version)/Sdks
export PATH="${PATH}:${DOTNET_ROOT}"
export PATH="$PATH:$HOME/.dotnet/tools"

Unable to resolve 'Microsoft.EntityFrameworkCore.SqlServer (>= 3.0.0)' for '.NETCoreApp,Version=v3.0'

Good day,
I am trying to add a package named 'Microsoft.EntityFrameworkCore.SqlServer --version 3.0.0' in my ASP.NET Core Blazor application in VS Code. But I am getting the following error.
P.s. This is my first time working with VS Code.
Terminal
g:\Workspace\Test>dotnet add package Microsoft.EntityFrameworkCore.SqlServer --version 3.0.0
Writing C:\Users\dell\AppData\Local\Temp\tmpDB70.tmp
info : Adding PackageReference for package 'Microsoft.EntityFrameworkCore.SqlServer' into project 'g:\Workspace\Test\Test.csproj'.
info : Restoring packages for g:\Workspace\Test\Test.csproj...
error: Unable to resolve 'Microsoft.EntityFrameworkCore.SqlServer (>= 3.0.0)' for '.NETCoreApp,Version=v3.0'.
error: Package 'Microsoft.EntityFrameworkCore.SqlServer' is incompatible with 'all' frameworks in project 'g:\Workspace\Test\Test.csproj'.
.NET Info
g:\Workspace\Test>dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.0.100
Commit: 04339c3a26
Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100\
Host (useful for support):
Version: 3.0.0
Commit: 95a0a61858
.NET Core SDKs installed:
3.0.100 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.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
.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
</Project>
A couple of posts suggested that I clear Nuget cache which I did. But still in vain.
g:\Workspace\Test>dotnet nuget locals all --clear
info : Clearing NuGet HTTP cache: C:\Users\dell\AppData\Local\NuGet\v3-cache
info : Clearing NuGet global packages folder: C:\Users\dell\.nuget\packages\
info : Clearing NuGet Temp cache: C:\Users\dell\AppData\Local\Temp\NuGetScratch
info : Clearing NuGet plugins cache: C:\Users\dell\AppData\Local\NuGet\plugins-cache
info : Local resources cleared.
g:\Workspace\Test>dotnet restore --force
Restore completed in 50.68 ms for g:\Workspace\Test\Test.csproj.
Thanks in advance.
If you are using any Visual studio IDE, try to delete/cut the nuget config file somewhere else.

VS 2019 C# console netcore 3 app not debugging

OS: Windows 10 Enterprise 10.0.18362
IDE: Visual Studio 2019 Community Edition Version 16.3.6
NET Core version: 3.0.100 Commit: 04339c3a26
What to do: Create simple .NET Core 3 console app in VS2019, switch target platform to x86 and press "F5".
Then 2 options:
.NET Core 3 any versions installed in system (all combinations of x86, x64, both). Environment variable "path" for x86 moved up and "dotnet --info" shows that it targets x86 version:
Error: The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
The program '[18492] dotnet.exe' has exited with code -2147450751 (0x80008081).
P.S. In this case this error also shown when switched to x64 target platform. But everything works good when run as AnyCPU.
Any version of .NET Core installed and environment variable for x86 version removed of moved below x64 version
Error: IDE can't find x86 version of dotnet.exe in Program Files (x86)
Infos for both x86 and x64 versions of dotnet:
.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-x86
Base Path: C:\Program Files (x86)\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 (x86)\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.0.0 [C:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.0.0 [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files (x86)\dotnet\shared\Microsoft.WindowsDesktop.App]
.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:
2.1.509 [C:\Program Files\dotnet\sdk]
2.2.103 [C:\Program Files\dotnet\sdk]
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.All 2.2.1 [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 2.2.1 [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 2.2.1 [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]
Have to say that x86 version of compiled console app works good if you launch exe file. Just can't launch it in debug from VS 2019. If switch to AnyCPU/x64
I am also using Visual Studio 2019 (16.3.8) and got a similar error when trying to debug with target x86 (but a netcoreapp2.0 project):
C:\Program Files\dotnet\dotnet.exe (process 40168) exited with code -532462766.
To automatically close the console when debugging stops, enable Tools->Options-
>Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .
If I remember right, this was working out of the box with Visual Studio 2017 and after installing VS 2019, VS 2017 also started to behave the same. It's ridiculous that VS cannot detect the target platform and launch the correct dotnet.exe accordingly.
Fortunately the fix is quite easy, add this setting to your project:
<PropertyGroup>
<RunCommand Condition=" '$(Platform)' == 'x86' ">$(MSBuildProgramFiles32)\dotnet\dotnet</RunCommand>
</PropertyGroup>
So when debugging, if your current target is x86, it will use C:\Program Files (x86)\dotnet\dotnet.exe and for others (default setting) it will use C:\Program Files\dotnet\dotnet.exe
Of course you should first ensure you have a .NET Core X86 SDK.
For a more detailed setting (more conditions), see here:
https://github.com/dotnet/cli/issues/7532#issuecomment-330706524
Though, the simple setting above works well for debugging both x86 and AnyCPU.
for me happend the same error, was because the parent folder name was "c#" and another folder inside of it that contains the c# project, the name was "month 9", so i renamed it the "c#" folder to "csharp" and the "month 9" to "month9" and then a ran the project again and worked it.
example with error:
c# >
month 9 >
"project here"
example fixed:
csharp >
month9 >
"project here"

Upgrading to .NET Core 3 in project that also uses netstandard2.1 is not building in Rider

I'm running on a macOS and the project I'm working on just upgraded from .NET Core 2 to .NET Core 3. The problem is that I can no longer build my project in Rider. If I try to build it in the terminal using dotnet build, the build succeeds. In my project, there are some subprojects that use netstandard2, but this should not be a problem (as its working in the terminal). I'm getting the following error message:
Project1 is not compatible with netcoreapp3.0 (.NETCoreApp,Version=v3.0). Project2 supports: netstandard2.1 (.NETStandard,Version=v2.1)
I have tried to add a global.json file which specifies I'm using version 3 of .NET Core, but it didn't help.
If I'm running dotnet build once in the terminal, then the new build of Rider will succeed. So things are working, but it is just annoying to always build in the terminal first.
The output of dotnet --info:
dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.0.100
Commit: 04339c3a26
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.14
OS Platform: Darwin
RID: osx.10.14-x64
Base Path: /usr/local/share/dotnet/sdk/3.0.100/
Host (useful for support):
Version: 3.0.0
Commit: 7d57652f33
.NET Core SDKs installed:
2.2.300 [/usr/local/share/dotnet/sdk]
2.2.401 [/usr/local/share/dotnet/sdk]
2.2.402 [/usr/local/share/dotnet/sdk]
3.0.100 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
I found that the issue was in Rider. The workaround is to change PackageReference Restore Engine (in File > Settings > Build, Execution, Deployment > NuGet) to MSBuild.
The issue will be fixed in a later version of Rider, so it is recommended to switch back to Embedded after the version is relased. The difference between MSBuild and Embedded:
MSBuild just calls external MSBuild task; Embedded directly calls
NuGet API inside Rider process. Embedded should work much faster and
it provides additional logs which can be useful when restore fails
The reason for the issue:
[...] because Rider 2019.2 EAP2 still used NuGet 4.9 internally; this
version doesn't have proper support of .NET Core 3.0 / .NET Standard
2.1. In Rider 2019.2 RTM, we are going to upgrade the internal version of NuGet up to 5.1.
Source for quotes and screenshot:
https://youtrack.jetbrains.com/issue/RIDER-29888

Difference between .NET Core SDK and TargetFramework versions

I don't really understand what is the difference between the dotnet sdk version and the TargetFramework version specified in my csproj file.
For example, my current project is using <TargetFramework>netcoreapp2.1</TargetFramework> version, but dotnet --version command returns 2.2.100. So the major version is the same, but the minor differs by 1.
Is it backwards compatible and netcoreapp2.1 apps can run on newer versions of dotnet sdk or something completely different?
dotnet --info:
.NET Core SDK (reflecting any global.json):
Version: 2.2.100
Commit: b9f2fa0ca8
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.100\
Host (useful for support):
Version: 2.2.0
Commit: 1249f08fed
.NET Core SDKs installed:
2.2.100 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

Resources