dnx test on Travis with mono hangs - mono

I'm trying to run my ASP.NET 5.0 (beta 8) tests which use xunit on Travis CI using language: CSharp as the build environment.
The project builds fine, and after installing dnvm I run the tests with dnx test.
However, whether the tests pass or fail, I get the following message after a while:
No output has been received in the last 10 minutes, this potentially indicates a stalled build or something wrong with the build itself.
The build has been terminated
I think this is happening because the dnx test command doesn't pass control back to the Travis console when the tests have completed. Travis thinks it is still running, but is not producing any output.
I think this is related to https://github.com/xunit/xunit/issues/489 and this bug in Mono: https://bugzilla.xamarin.com/show_bug.cgi?id=28793 but that thread says it was fixed in May 2015, and I'm running on the latest version of Mono (4.0.4).

It might be caused by a known bug. Try running the tests without parallelization and see if that helps:
dnx test -parallel none
You should be able to reproduce the issue locally too.

Related

Code coverage with .NET Core 2.0

I am trying to setup code coverage on our ASP.NET Core 2.0 web application. I use dotcover (from JetBrains) to provide code coverage on all my other builds (by running dotcover from the command-line during the build process).
When I run dotcover from our build server for our .NET Core 2.0 web app I see this.
It states that it has run successfully but then just hangs there and no code coverage files are created.
dotcover analyse /TargetExecutable:"C:\Program Files\dotnet\dotnet.exe" /TargetArguments:"test MyUnitTests.csproj" /Output:report.html /ReportType:HTML /LogFile=dotcover.log
If I try and add code coverage collection I see this.
dotcover analyse /TargetExecutable:"C:\Program Files\dotnet\dotnet.exe" /TargetArguments:"test MyUnitTests.csproj --collect:coverage" /Output:report.html /ReportType:HTML /LogFile=dotcover.log
And finally if I run dotnet test on its own (without dotcover) it seems to have worked, but again no coverage output is created.
dotnet test "MyUnitTests.csproj" -- collect:coverage
I'm unsure how to generate code coverage for a .NET Core 2.0 app, and not sure how / what data collectors are and how they should be used. Is dotcover the data collector in this example?
Basically, I just want to generate code coverage for a .NET Core 2.0 application.
UPDATE:
As per the suggestion I have installed coverlet as an alternative to dotcover. I have got it working but am getting inconsistent behaviour. When I run my batch file from the server it's all fine.
But when run from TFS I get an error.
System.IO.FileNotFoundException: No test is available in . Make sure test project has a nuget reference of package "Microsoft.NET.Test.Sdk" and framework version settings are appropriate and try again.
My project does have a reference to that assembly (it's installed by default by VS itself when you create a unit test project).
Why is TFS complaining about that assembly when it's definitely there and can be run manually from the command-line without an error?
I don't know if dotcover can works with net core, but you can take a look for coverlet, also you can find an example here: Cross platform code coverage arrives for .NET Core
I have just migrated a project from net461 to dotnet core and I wanted to maintain code coverage. Using the command line suggested by the OP was what I needed. I am migrating fake scripts where I was previously using dot cover to generate the snapshot file to be pushed to teamcity and an html report. I can confirm that the following works for me:
DotNet SDK 2.1.2
JetBrains.dotCover.CommandLineTools 2018.1.0
Also tested positive with 2017.1.20170403.131707
Microsoft.NET.Test.Sdk 15.7.0
NUnit 3.10.1
NUnit3TestAdapter 3.10.0
DotCover cover
<dotcoverpath>\dotCover.exe cover /TargetExecutable:"C:\Program Files\dotnet\dotnet.exe" /TargetArguments:"test --no-build --no-restore ./src/<test-project-root>" /Filters=+:<namespace-to-test> /Output:./bin/DotCover.snapshot
DotCover analyze
I am not doing the following as I use the DotCover report command on the generated snapshot file but I can also confirm that the following is working for me as well.
<dotcoverpath>\dotCover.exe analyze /TargetExecutable:"C:\Program Files\dotnet\dotnet.exe" /TargetArguments:"test --no-build --no-restore ./src/<test-project-root>" /Filters=+:<namespace-to-test> /ReportType=HTML /Output:./bin/coverage.html
Notes
In my test run I am not restoring packages (--no-restore) or compiling (--no-build) the project as I have already done this in a previous step. These can be removed to suit your needs.
The OP did say that dot cover appeared to hang after the tests had completed. It is worth pointing out that the effort in turning the snapshot at the end of the test coverage into a report can take a while if there is a large amount of code and or assemblies. You do in fact see dot cover pausing at the point the tests have completed whilst it generates the html report. Use the filter (/Filters=) parameter to cut down on the size of things being covered, especially if you don't want to do any coverage on third party components.
/Filters=ARG (Optional) Specifies coverage filters. Syntax:
+:module=*;class=*;function=*; Use -:myassembly to exclude an assembly from code coverage. Asterisk wildcard (*) is supported here

Using Crashlytics on iOS with CMake

Our projects all use CMake, and Fabric seems to require a script run in XCode's build environment to extract information. CMake doesn't seem to have a way to add a run script build phase.
So, I tried running the script manually after setting the following manually from known values in CMake:
INFOPLIST_PATH
BUILT_PRODUCTS_DIR
DWARF_DSYM_FILE_NAME
DWARF_DSYM_FOLDER_PATH
PROJECT_DIR
As a result, there were no errors when running the script but ..also nothing happened. I just got a "Launching uploader in validation mode" and then the process exited.
Is it possible I could get a full run-down of what the program needs in order to run? Our projects are built on a build server so having to VNC in and launch xcode to build is not really an option.
Thanks in advance.
Since you're using CMake, instead of using the run script build phase, I'd use the upload-symbols script as that will be a more reliable way to upload the dSYMs to Crashlytics.

DNX on VSO Host Build Controller

When trying to build an ASP.NET 5 DNX project on VSO, I get the following error:
Cannot find DNX runtime dnx-clr-win-x86.1.0.0-beta6 in the folder:
C:\Users\buildguest.dnx\runtimes (119,5): Error : The Dnx Runtime
package needs to be installed. See output window for more details.
Does this mean that we cannot use the host build controller with DNX projects yet?
Found a great guide on how to install dnx on vso host.
https://msdn.microsoft.com/Library/vs/alm/Build/azure/deploy-aspnet5
Added the first PreBuild.ps1 script as a Powershell build step and it worked right away.
Since I still use it, to compile my code, to me, it's not dead.
I integrated some travis-ci config in py project, have a look at my .travis.yml for an update, but I count on my host name, my pc, and my internet connection to serve it as I do since few years:
dnx-install.sh
Note that DNX should be able to build DNX,
from it's source code, even marked as obsolete, and that It would be possible, but painfull, to write some scripts and use mono-roslyn directly ... still not a dead branch to me.

Once a build fails in TFS 2010, all builds after it on the same agent fail until the service is restarted

This is an extension of an earlier issue I had, which I posted about here: VB.Net Method appears to be called multiple times when it actually isn't, and returns inconsistent results
At that time I had thought the issue was fully resolved, but I've since learned that there were multiple issues. I have worked out all the kinks with the code and logic, and now I've narrowed down the last remaining issue.
Builds will run perfectly fine until one legitimately fails. After that point, all the builds on that specific agent will fail, even if there were no actual errors with the subsequent builds. When they fail, I see the exact same symptoms as I did in the other thread, which I will summarize here:
A method that is only called once appears to be called multiple times as evidenced by the build messages
The build messages will show there is 1 error, but there are no errors in the logs generated by that method (The line to write the error to the log comes immediately after the line where the error is added to the result log, in the same if statement)
Restarting the build service on the build server "fixes" the problem until the next time a build legitimately fails, at which point the cycle starts again
Build server setup:
Windows Server 2008 R2
VS 2010 Premium
Build uses a custom library
There are 4 build agents, one for each environment (Dev, QA, UAT, Prod)
The build and deploy custom library is written in VB using .Net Framework 4.5, and it calls on another library that is written using .Net Framework 4.5 as well.
The build template doesn't use msbuild. It's strictly WF that's been stripped down to the bare minimum and only calls commandline programs (Like robocopy) or custom .net classes.
I have verified that if a build fails for one agent (such as Dev), then all builds using that agent will fail. When it happens, ONLY builds that run on that particular agent will fail, other agents run just fine. I have not had a chance to test yet if just restarting the agent will "fix" it, or if I have to restart the entire service.
I have tried clearing the Visual Studio cache for the user account running the builds, but that didn't help at all. I also have a GUI interface that I designed that does all the same things as the build, and uses all the same code, and I am not able to get it to repeat the behavior.
I've enabled logs on the build controller per these steps: How to enable build agent or build controller’s logs? however they were no help when this problem occurred (There were no errors logged, nothing was different in the logs for builds that were fine vs. ones that bugged out)
I'm not sure what my next troubleshooting steps should be, I know the problem isn't with my code, and I'm having no luck searching the internet via Google, MSDN, StackOverflow, or picking the brains of my peers at other organizations.
I'm wondering if this could be a bug due to running code that requires .Net Framework 4.5 in TFS 2010 build, since it only officially supports up to 4.0.
My advice would be to change the build logger to diagnostic and look at the output, there must be some rubbish being added to the environment.
You can do this with a switch like
/l:FileLogger,Microsoft.Build.Engine;logfile=c:\build.log;Verbosity=Diagnostic
you might want to take a look here

nunit-console tests produces different result from different locations

I have got nunit-console.exe in 2 locations on my machine. First is where I installed it (c:\program files (x86)\nunit 2.5.10) and second is where I have copied it into (d:\tests\nunit). I am required to work with the copied version.
I am trying to run a test from a test assembly and I get strange results. When I try to invoke the installed version, the test runs fine. But, when I try to invoke the copied version, the tests dont run. The copied version was initally throwing the NUnit components for version 4.0.30319 of the CLR are not installed error and I followed the solution for this question to fix it. But, now the tests (which include BizUnit 2010 maps and schemas) fail with an error which I am unable to fix.
The strange this is, if I invoke the installed version, all runs smooth. I am not required to do any config changes and tests pass ok.
I tried to use the /domain=None option of nunit-console.exe, the tests pass. But, I dont want to use it.
Please can someone help? What am I missing?
I am running on Win 2008R2 with .NET version 4 and NUnit version 2.5.10
Thanks
I've had the same problem. In my case it was because the path where I had copied nunit included a # letter. I renamed the folder and it worked flawlessly.
I got the answer from here:
https://groups.google.com/forum/#!topic/nunit-discuss/bc73uuP-Lbw