Skip to content

CD pipeline, running against dlls and coverage generation on a different machine to the build machine #1364

Open
@danpowell88

Description

@danpowell88

I'm trying to setup a CI/CD pipeline where we reduce the number of builds we do and just run our unit tests agains the built source, potentially on a different machine to the machine that built the dll itself (and almost definitely in a different checkout directory).

So

Machine #1 (working directory c:\build{GUID})

dotnet restore
dotnet build MySolution.sln
dotnet publish UnitTests/UnitTest.csproj -o output/tests/unittests

/output/tests/unittests is then published as a build artifact

I've also included the dotnet reproducible builds package (and building using TeamCity)

Machine 2 (working directory c:\build{GUID2})
Copy build artifacts to /output/tests/Api.UnitTests

dotnet test output/tests/Api.UnitTests/UnitTests.dll --logger:TeamCity --collect:"XPlat Code Coverage" --ResultsDirectory:output/results/tests -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura`

The tests run correctly however no coverage is output for them. I did notice that the CoverletSourceRootsMapping is not copied into the output when I do a dotnet publish, I have added a step to manually copy this into the publish directory and I can see the coverage then works, but only if the test coverage is run on the same machine that the build ran on.

What am I missing here, should I give up and just revert back to building everything and running the coverage all together ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions