dotnet run hangs / is stuck - c#

A razor webapp can no longer be started on my machine.
The build command dotnet build works as expected but dotnet run is stuck after the first warnings.
C:\dev\mywebapp>dotnet run
Building...
C:\dev\mywebapp\Pages\Admin\Orders\TraderOrderList.cshtml.cs(101,17):
warning CS0219: The variable 'orderId' is assigned but its value is
never used [C:\dev\mywebapp\MyWebApp.csproj]
C:\dev\mywebapp\Pages\Index.cshtml.cs(23,24):
warning CS0414: The field 'IndexModel._currentAd' is assigned but its value is
never used [C:\dev\mywebapp\MyWebApp.csproj]
--- after here it is stuck no more output and i stopped it after about 3 minutes
What have i tried?
I created a new project c:\dev\webtemp>dotnet new webapp -o HelloWebApp
And ran it with c:\dev\webtemp\HelloWebApp>dotnet run. So this works as expected.
I searched for other questions on stackoverflow but they do not have the same problem.
Question
How can the issue be narrowed down?
Where is a log file for the dotnet run command?
dotnet --info
Below certain paths were replaced for brevity
name used
path
<path-to-AspNetCore.App>
C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App
<path-shared-NETCore>
C:\Program Files\dotnet\shared\Microsoft.NETCore.App
<path-shared-WindowsDesktop>
C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App
Running dotnet --info returns
c:\dev\webtemp\HelloWebApp>dotnet --info
.NET SDK: Version: 7.0.100 Commit: e12b7af219
Runtime Environment:
OS Name: Windows OS Version: 10.0.19042
OS Platform: Windows RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.100\
Host: Version: 7.0.0 Architecture: x64 Commit: d099f075e4
.NET SDKs installed:
3.1.120 [C:\Program Files\dotnet\sdk] 3.1.426 [C:\Program Files\dotnet\sdk]
5.0.408 [C:\Program Files\dotnet\sdk]
6.0.113 [C:\Program Files\dotnet\sdk]
7.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.20 [<path-to-AspNetCore.App>]
Microsoft.AspNetCore.App 3.1.32 [<path-to-AspNetCore.App>]
Microsoft.AspNetCore.App 5.0.17 [<path-to-AspNetCore.App>]
Microsoft.AspNetCore.App 6.0.13 [<path-to-AspNetCore.App>]
Microsoft.AspNetCore.App 7.0.0 [<path-to-AspNetCore.App>]
Microsoft.NETCore.App 3.1.20 [<path-shared-NETCore>]
Microsoft.NETCore.App 3.1.32 [<path-shared-NETCore>]
Microsoft.NETCore.App 5.0.17 [<path-shared-NETCore>]
Microsoft.NETCore.App 6.0.13 [<path-shared-NETCore>]
Microsoft.NETCore.App 7.0.0 [<path-shared-NETCore>]
Microsoft.WindowsDesktop.App 3.1.20 [<path-shared-WindowsDesktop>]
Microsoft.WindowsDesktop.App 3.1.32 [<path-shared-WindowsDesktop>]
Microsoft.WindowsDesktop.App 5.0.17 [<path-shared-WindowsDesktop>]
Microsoft.WindowsDesktop.App 6.0.13 [<path-shared-WindowsDesktop>]
Microsoft.WindowsDesktop.App 7.0.0 [<path-shared-WindowsDesktop>]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables: Not set
global.json file: Not found
Update - using another branch returns 404
I did change the branch and dotnet run reached the part where localhost is started.
info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://localhost:7178 info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5057 info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\dev\mywebapp\
But it returns http 404
404 Not Found
The server cannot find the requested resource. ...
Servers may also send this response instead of 403 Forbidden to
hide the existence of a resource from an unauthorized client.
I tried a few different urls but every razor page failed (404). Only the static html page under wwwroot works (200)
path
url
result
C:\...\wwwroot\index.htm
https://localhost:7178/index.htm
200
C:\...\Pages\info.cshtml
https://localhost:7178/privacy
404
as above
https://localhost:7178/privacy.cshtml
404
as above
https://localhost:7178/Pages/privacy/
404
as above
https://localhost:7178/Pages/privacy.cshtml
404
Here you can see a screenshot of devtools

Related

/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

Cannot install dotnet-ef tool on Windows 10

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

Dotnet test ignoring filter when on Linux

I'm using xunit, with trait attributes set on some of my tests. When running dotnet test I'm trying to filter by these traits. I have it working fine locally on my Windows machine but when I run the same command on my CI container then it doesn't filter my tests.
The command is:
dotnet test --filter Category=Integration
I'm using CircleCI with the container mcr.microsoft.com/dotnet/core/sdk:2.2
When I SSH to the box and try running the command, it just runs all of the tests.
dotnet --info from the container:
.NET Core SDK (reflecting any global.json):
Version: 2.1.700
Commit: c2ef055a0f
Runtime Environment:
OS Name: debian
OS Version: 9
OS Platform: Linux
RID: debian.9-x64
Base Path: /usr/share/dotnet/sdk/2.1.700/
Host (useful for support):
Version: 2.1.11
Commit: d6a5616240
.NET Core SDKs installed:
2.1.700 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.11 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.11 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.11 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
I've managed to resolve my issue just about. It appears it's a bug with the 16.1.0 SDK version (which dictates the version of vstest). As the issue was just on CI for me, I pinned the container I was using to
mcr.microsoft.com/dotnet/core/sdk#sha256:d0a71e1312be2618f320a7b7cc6d7423af3810542b3ffd35438108800ecfb958
which contains the 16.0.1 SDK. It's not the perfect fix but resolves my immediate issue.

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