Test fails in net6.0 with no info - c#

So i started writing xunit test in net 6.0 with visual studio 2022 community preview.
Everything was working fine on the first PC.
But then when i set the dev environment on another PC (both windows 10) and i try running tests i get this :
========== Starting test run ==========
Testhost process exited with error: . Please check the diagnostic logs for more information.
Testhost process exited with error: . Please check the diagnostic logs for more information.
========== Test run aborted: 0 Tests (0 Passed, 0 Failed, 0 Skipped) run in < 1 ms ==========
With no more information. Where can i find those "diagnostic logs" i don't find info about it on the web.
I tried running tests manually in command terminal with "dotnet test" but i get this :
**dotnet test
Determining projects to restore...
All projects are up-to-date for restore.
kis-project-information-core -> D:\Users\Thomas MEDARD\Documents\Apollo\Kis\Booth\Libraries\kis-project-information\sources\binaries\net6.0\kis-project-information-core.dll
kis-project-information-unit-tests -> D:\Users\Thomas MEDARD\Documents\Apollo\Kis\Booth\Libraries\kis-project-information\sources\binaries\net6.0\kis-project-information-unit-tests.dll
Test run for D:\Users\Thomas MEDARD\Documents\Apollo\Kis\Booth\Libraries\kis-project-information\sources\binaries\net6.0\kis-project-information-unit-tests.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.0.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Testhost process exited with error: . Please check the diagnostic logs for more information.
Test Run Aborted.**
I ran dotnet test -verbosity:diagnostic --diag:log.txt to see details and here is what i get
log.txt
log.host.21-11-30_10-19-44_26197_5.txt
So i see my test is detected but something is going wrong when running it

Ok so i found what is happening.
After reinstalling i thought everything worked but actually i found the same problem again.
What i realized is that i was in admin mode on my terminal. When i run the same command from non admin terminal, i get the problem explained.
So my problem is accessing to dotnet. I guess it has something to do with having my source code stored in a different drive from dotnet.
It's still weird that i can build without problem but testing need elevated privileges.

Related

Google Cloud Platform Visual Studio Publish

I have been deploying my C# MVC application for years now, as early as yesterday, successfully. Today however I started getting this error:
Step 6/6 : RUN npm install firebase-admin
---> Running in 6af72a3f9eaf
[91m/bin/sh: 1: npm: not found
The command '/bin/sh -c npm install firebase-admin' returned a non-zero code: 127
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 127
[0m
--------------------------------------------------------------------------------
ERROR: (gcloud.app.deploy) Cloud build failed. Check logs at https://console.cloud.google.com/cloud-build/builds/ea90f766-e252-4b9b-b707-746acf8ad686?project=186443889098 Failure status: UNKNOWN: Error Response: [2] Build failed; check build logs for details
Failed to deploy project [Project Name] to App Engine Flex.
The logs say this:
Step 6/6 : RUN npm install firebase-admin
---> Running in 6af72a3f9eaf
/bin/sh: 1: npm: not found
The command '/bin/sh -c npm install firebase-admin' returned a non-zero code: 127
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 127
Has anyone seen this error or know whats casing it?
The problem was the node.js version was wrong. It was trying to use the wrong node version when publishing vs what was defined in the code.

Backend tests only runs on 1 out of 3 TeamCity build agents. Error: 'Unable to find testhost.dll. Please publish your test project and retry.'

All backendtests works fine locally and on one of the TeamCity agents, but always fails when another TeamCity agent tries to run them.
I logged onto all agents, and can't find any differences between them.
Other issues I have found with 'Unable to find testhost.dll' error, have been solved with referencing Microsoft.Net.Test.SDK, but that doesn't work.
In the logs for the agent working:
[10:52:07][vstest] Starting test execution, please wait...
[10:52:09][vstest] NUnit Adapter 3.13.0.0: Test execution started
In the logs for one of the agents not working:
[12:27:56][vstest] Starting test execution, please wait...
[12:27:57][vstest] Unable to find D:\TeamCity\BuildAgent5\work\b75e42d21fae163\tests\UnitTests\bin\Release\netcoreapp2.2\testhost.dll. Please publish your test project and retry.
[12:27:57][vstest] Test Run Aborted.
Everything before this looks simular. I think the agents that are not working can't fint NUnit Adapter, but I have no idea why. I checked the folder over and all agents had both NUnit3.TestAdapter.dll and NUnit3.TestAdapter.pbd in the same versions.

Visual Studio publish doesn't report errors

I have a WCF web service using Visual Studio 2015. If I have a compile error in C# code, when I publish the web service (to a file location) the "build" will succeed, and continue through a successful publish:
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
If I then deploy to an IIS web server and call the web service there, the call fails and returns a page describing the compilation error.
When publishing, the output in VS starts with Build started: but apparently it isn't really doing a build because any build would have failed, and in fact if I do a build instead of publish, it does report the error(s). Do I have to remember to build before publishing to check for errors, or is there a way to get it to really for realz compile the code?
If solution has many projects then try building them one at a time.
Try below steps:
Restart Visual Studio.
Restart Computer
Rebuild all
Clean Solution then Rebuild All
Also you can check below
Setting the MSBuild project build output verbosity (in Options > Projects and Solutions > Build and Run setting area) to "Diagnostic" as shown below. This then showed that the custom action was what had failed.
https://blogs.msdn.microsoft.com/saraford/2008/10/07/did-you-know-you-can-configure-the-msbuild-verbosity-in-the-output-window-329/

How can I find out which test method in a batch of test methods fails to run?

In the Test Explorer window of Visual Studio 2015 for C#, I select all the 360 test methods in my solution, and choose "Run Selected Tests". But not all of them are executed, as indicated by the Output window:
------ Run test started ------
The active Test Run was aborted because the execution process exited unexpectedly. To investigate further,
enable local crash dumps either at the machine level or for process
te.processhost.managed.exe. Go to more details:
http://go.microsoft.com/fwlink/?linkid=232477
========== Run test finished: 188 run (0:00:12.7254721) ==========
How can I find out which test method fails to run, narrow the culprit test method down? Thanks.
Probably not the most subtle way to do it, but you could comment your tests one by one, and see at which point your run stops failing.

SonarQube MSBuild Runner defaults to h2 Database

I am using Win Server 2012, Developer Command Prompt for VS2013, SonarQube v5.1.2, SonarQube Scanner for MSBuild 1.1.
I have my Sonar instance running off this same server, but connected to an Oracle database. Using the default sonar runner, i can analyze projects properly and see them appear in the dashboard using this method. That cannot be said for using the recommended MSBuild.SonarQube.Runner.exe approach.
I have tried with the csharp and vbnet examples, as well as our actual code. Oddly, i want to say each of these have worked at least once, but fail to do so now. Today, I tried using the vbnet example project for the first time and discovered and it worked as intended when using the MSBuild runner. I deleted the project from the dashboard, and ran it again. At this point i do not remember it it worked or not, but the third time for sure it stopped working and began producing the error below (wherein it tries to connect to the default h2 database instead of the oracle one that SonarQube is connected to).
I tried deleting the examples folder, extracting it again, giving it a slightly different name, and running the Sonar on it giving THOSE a different name/key/version, but now it is consistently giving me the db error.
Any idea what could be going on here, and why it would go from working to not, without me making any changes to the runner, msbuild, or the code?
Running the begin step:
c:\sonar-examples-master\projects\languages\vbnet>msbuild.sonarqube.runner.exe b
egin /v:vbnet1 /k:vbnet1 /n:vbnet1
SonarQube Scanner for MSBuild 1.1
Default properties file was found at c:\sonarqube\bin\SonarQube.Analysis.xml
Loading analysis properties from c:\sonarqube\bin\SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
Checking for updates...
MSBuild SonarQube Runner Pre-processor 1.0.2.0
17:40:49.625 Loading analysis properties from c:\sonarqube\bin\SonarQube.Analys
is.xml
17:40:49.656 Updating build integration targets...
17:40:49.656 Fetching analysis configuration settings...
17:40:50.813 Generating rulesets...
Pre-processing succeeded.
MSBuild ran, but nothing worthwhile to post from it..
Running the end step:
c:\sonar-examples-master\projects\languages\vbnet>msbuild.sonarqube.runner.exe e
nd
SonarQube Scanner for MSBuild 1.1
Default properties file was found at c:\sonarqube\bin\SonarQube.Analysis.xml
Loading analysis properties from c:\sonarqube\bin\SonarQube.Analysis.xml
Post-processing started.
MSBuild SonarQube Runner Post-processor 1.0.2.0
WARNING: File is not under the project directory and cannot currently be analyse
d by SonarQube. File: C:\Users\ts3conusr\AppData\Local\Temp\.NETFramework,Versio
n=v4.5.AssemblyAttributes.vb, project: c:\sonar-examples-master\projects\languag
es\vbnet\ConsoleApplication1\ConsoleApplication1.vbproj
The SONAR_RUNNER_HOME environment variable is not required and will be ignored.
SONAR_RUNNER_OPTS is not configured. Setting it to the default value of -Xmx1024
m
Calling the sonar-runner...
c:\sonar-examples-master\projects\languages\vbnet\.sonarqube\bin\sonar-runner\bi
n\..
SonarQube Runner 2.4
Java 1.7.0_79 Oracle Corporation (32-bit)
Windows Server 2008 R2 6.1 x86
SONAR_RUNNER_OPTS=-Xmx1024m
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: c:\sonar-examples-master\projects\languages\vbn
et\.sonarqube\bin\sonar-runner\bin\..\conf\sonar-runner.properties
INFO: Project configuration file: c:\sonar-examples-master\projects\languages\vb
net\.sonarqube\out\sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: c:\sonar-examples-master\projects\languages\vbnet\.sonarqu
be\out\.sonar
INFO: SonarQube Server 5.1.2
17:41:04.563 INFO - Load global repositories
17:41:04.751 INFO - Load global repositories (done) | time=188ms
17:41:04.751 INFO - Server id: 20160120154951
17:41:04.751 INFO - User cache: C:\Users\ts3conusr\.sonar\cache
17:41:04.766 INFO - Install plugins
17:41:04.860 INFO - Install JDBC driver
17:41:04.860 INFO - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 1.047s
Final Memory: 3M/15M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
Of note: I feel that it is worth mentioning that the vbnet report didn't actually have any content in it, but did at least properly get generated in the Sonar dashboard. I have tried running the commands against both that and the csharp example with now neither of them being added to the dashboard.
In the MSBuild.SonarQube.Runner install folder, there is a SonarQube.Analysis.xml. Do you have the correct server details on the below line in there?
<Property Name="sonar.host.url">http://{host}:{port}/{optionalPath}</Property>
This property value should point to your Sonar server.
Couple other things to try. Do you see tables being populated with analysis data in your oracle database? When was the last time it got any record?
Also, are you seeing below warning on your SonarQube application pages (say default dashboard)? If yes, then oracle configuration is not being picked up.
So i upgraded to the latest SonarQube version (5.3) and upgraded a few of the extensions while i was at it and preliminary testing is showing positive results. Ill try it a few more times but im closing the question for now. Thank you all that helped!

Categories

Resources