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

Multiple output formats fails using Linux MSBuild #790

Closed
tillig opened this issue Apr 3, 2020 · 1 comment · Fixed by #795
Closed

Multiple output formats fails using Linux MSBuild #790

tillig opened this issue Apr 3, 2020 · 1 comment · Fixed by #795

Comments

@tillig
Copy link
Contributor

tillig commented Apr 3, 2020

This isn't a problem with Coverlet but maybe something to add to the documentation.

If you want to specify multiple output formats, the docs say you need to escape the quotes around the formats

/p:CoverletOutputFormat=\"json,cobertura\"

so in MSBuild it'd look like

<Exec Command="dotnet test MySolution.sln -c $(Configuration) /p:CollectCoverage=true /p:CoverletOutput=log /p:MergeWith=log/coverage.json /p:CoverletOutputFormat=\&quot;json,cobertura\&quot; -m:1" />

Unfortunately, there's an issue with Linux MSBuild that translates escape backslashes \ to slashes / on the fly. Thus on, say Azure DevOps where you're running on an Ubuntu agent, you'll get an error like:

MSBUILD : error MSB1006: Property is not valid. [/home/vsts/work/1/s/default.proj]
  Switch: cobertura/

The quotes aren't escaped and the command line gets parsed wrong.

On Windows this works as expected, and if you use dotnet msbuild on Linux it also works as expected. You'll see the error if you're on Linux and:

  • You call the binary Linux MSBuild rather than dotnet msbuild OR
  • You're in Azure DevOps on a Linux agent and use the MSBuild task (which uses the binary Linux MSBuild)

And maybe this issue is enough, something folks can search for and find later. I just know I spent like two hours trying to figure out why things worked fine on my Mac using dotnet msbuild but the Ubuntu agent was failing every time.

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Apr 4, 2020

Thank's Travis to reporting this!
We have a section for similar issue on msbuild documentation https://github.com/tonerdo/coverlet/blob/master/Documentation/MSBuildIntegration.md#note-for-powershell--vsts-users
Would you like to propose a PR with update next to Note for Powershell / VSTS users?Not obligated at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants