Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CoverletSourceRootsMapping path #863

Merged
merged 2 commits into from
Jun 4, 2020
Merged

Fix CoverletSourceRootsMapping path #863

merged 2 commits into from
Jun 4, 2020

Conversation

martincostello
Copy link
Contributor

Fix the path for the CoverletSourceRootsMapping file not being set correctly if the $(OutputPath) property does not end with a trailing directory separator.

I was trying to enable deterministic builds using version 2.9.0 of the MSBuild package, but the code coverage wasn't being reported. I then noticed that the file was being created with the name artifactsCoverletSourceRootsMapping in my solution root, rather than as CoverletSourceRootsMapping in the artifacts directory.

Fix the path for the CoverletSourceRootsMapping file not being set correctly if the OutputPath property does not end with a trailing directory separator.
Copy link
Collaborator

@MarcoRossignoli MarcoRossignoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank's Martin!
Seems ok to me, @clairernovotny can you double check if there is a better way or if it's ok as is(you're more expert than me on msbuild)?

@MarcoRossignoli
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@clairernovotny
Copy link
Contributor

You probably want EnsureTrailingSlash https://docs.microsoft.com/en-us/visualstudio/msbuild/property-functions?view=vs-2019#msbuild-ensuretrailingslash

@martincostello
Copy link
Contributor Author

Ah yes, I’d forgotten about that one. Will update the PR a bit later. Thanks!

Copy link
Collaborator

@MarcoRossignoli MarcoRossignoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank's to all

Use EnsureTrailingSlash() instead of Path.Combine().

Co-Authored-By: Claire Novotny <[email protected]>
@MarcoRossignoli MarcoRossignoli merged commit 8cf2b3c into coverlet-coverage:master Jun 4, 2020
@martincostello martincostello deleted the Fix-CoverletSourceRootsMapping-Path branch June 4, 2020 18:33
@MarcoRossignoli
Copy link
Collaborator

@martincostello you can try nigthly https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/ConsumeNightlyBuild.md tomorrow(published ~00.00)

Let me know!

Thank's again to all!

martincostello added a commit to martincostello/xunit-logging that referenced this pull request Jun 5, 2020
Remove workaround for coverage not working for deterministic builds and pick up changes from coverlet-coverage/coverlet#863.
@martincostello
Copy link
Contributor Author

@MarcoRossignoli I've pulled the nightly into this PR here and it's working as expected without my workaround for the incorrect path: martincostello/xunit-logging#139

However, I still need to use the CoverletGetPathMap MSBuild target for it to work. I was under the impression that the workaround wasn't needed with coverlet.msbuild 2.9.0+ and .NET SDK 3.1.300+?

Without: https://github.com/martincostello/xunit-logging/pull/139/checks?check_run_id=741352608#step:4:151

With: https://github.com/martincostello/xunit-logging/pull/139/checks?check_run_id=741370987#step:4:154

@MarcoRossignoli
Copy link
Collaborator

Interesting, I don't know what changes were done on that side, but we can keep the "fix"...btw in future version of sdk we can avoid target workaround dotnet/roslyn#43706 (comment)

@martincostello
Copy link
Contributor Author

I guess the fix that will make the extra target redundant will come in a future version of 3.1.3xx as it seems to have missed 3.1.300

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Jun 5, 2020

@tmat maybe can answer, but I think that will come since next release as servicing dotnet/roslyn#43476 (comment)
We'll need also some update to coverlet.

@clairernovotny
Copy link
Contributor

clairernovotny commented Jun 5, 2020

The target update missed the 3.1.300 and Coverlet needs an update to call the updated target as well.

There are two options for Coverlet: always call the target and fail not do the path mapping if it hasn't been updated (basically require the SDK that has the fix as a minimum), or conditionally call that target and also support the workaround target for lower SDK's.

0xced added a commit to 0xced/xunit-logging that referenced this pull request Apr 28, 2021
Adding a package reference in a non-test project would lead to this error when running `dotnet test` in the repository root:
> ~/.nuget/packages/coverlet.msbuild/3.0.3/build/coverlet.msbuild.targets(70,5): error MSB4044: The "Coverlet.MSbuild.Tasks.CoverageResultTask" task was not given a value for the required parameter "InstrumenterState".

See coverlet-coverage/coverlet#480 (comment)

Also delete the workaround for the bug in generation of _LocalTopLevelSourceRoot which is [no longer necessary](coverlet-coverage/coverlet#863).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants