Anel
Anel

Reputation: 101

Using coverlet with. Net Framework generates an error: The expression "[System.Version]::Parse('')" canot be evaluated

I wrote a very simple C# .Net Framework application and added some unit tests. Now, trying to check the coverage using coverlet. Getting error MSB4184.

The expression "[System.Version]::Parse('')" canot be evaluated. Version string portion was too short or too long. (parameter 'input' ).

Does anyone encounter such an error?

Upvotes: 10

Views: 6345

Answers (3)

Dieter V
Dieter V

Reputation: 11

I resolved this by using .Net6 for my test project rather than .Net 4.x . the .Net6 library was still able to execute my functions in my .net4.x library and coverlet restored without any issues

Upvotes: 0

Edward J. Stembler
Edward J. Stembler

Reputation: 2052

One way I got around this issue was by renaming (or deleting) the coverlet.collector directory in your $HOME\.nuget\packages directory. Close Visual Studio completely, then re-open your solution or project.

File Explorer with renamed coverlet.collector directory

Upvotes: 9

Marcel Melzig
Marcel Melzig

Reputation: 363

Coverlet has some limitations. It only supports SDK-style projects and in some cases only .NET Core test projects. This is not an issue if you start a new test project in a solution because you can mix up project types.

But migration of an existing old test project to an SDK style .NET Core project could be necessary.

https://github.com/coverlet-coverage/coverlet#Quick-Start has more information about the requirements.

Upvotes: 2

Related Questions