Facing issue in running a 'Code-coverage' build.cake task in linux machine

21 Views Asked by At

Working on a task, migrating the existing cake running in windows to a Linux machine. Previously, using a cake boostrapper file from this link to run the cake script in windows machine for DevOps functions.

In a task to migrate this to run in linux machine, I've modified the Jenkins file to use 'build.sh' as a cake boostrapper file to run the cake script. Upon migrating, I face this issue on two tasks particular other tasks ran successfully.

This was a screenshot of the problem:enter image description here

(Screenshot) Other tasks were successful:

enter image description here

The code-part of this tasks in build.cake:
enter image description here

Task("Code-Coverage")
    .ContinueOnError()
    .Does(() =>
    {
    try
    {
        if (!DirectoryExists(cireports))
        {
            CreateDirectory(cireports);
            CreateDirectory(xunitReportDir);
        } else {
            if(!DirectoryExists(xunitReportDir))
            {
                CreateDirectory(xunitReportDir);
            }
            else {
                DeleteDirectory(xunitReportDir, recursive:true);
                CreateDirectory(xunitReportDir);
            }
        }

        if (!DirectoryExists(codecoverageReportDir))
        {
            CreateDirectory(codecoverageReportDir); 
        } else { 
                DeleteDirectory(codecoverageReportDir, recursive:true);
                CreateDirectory(codecoverageReportDir); 
        }

        var projects = GetFiles(unitTestProjectDirPathPattern);
        var settings = new DotCoverCoverSettings()
                    .WithFilter(codeCoverageFilter)
                    .WithAttributeFilter("System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute");

        foreach(var project in projects)
        {
            DotCoverCover(
                x => x.DotNetCoreTest(
                     project.FullPath,
                     new DotNetCoreTestSettings() {
                          Configuration = configuration,
                          Logger = $"trx;LogFileName={unitTestingReport}",
                          NoBuild = true,
                           }
                ),
                dotCodeCoverageReport,
                settings
            );
        }
    }   
    catch(Exception ex) {        
        throw new Exception(String.Format("Please fix the project compilation failures"));  
    }
    });

I would like your suggestions to fix this problem. Thank You !

0

There are 0 best solutions below