I have a .NET MAUI app that I want to run unit tests against. I already have some MsTest tests but never could get the MsTest project to build. Enter Gerald versluis’ fine video on how to do that here and a working sample using xUnit (here) [https://stackoverflow.com)https://github.com/jfversluis/MauixUnitTestSample.git]. Basically he just adds a Net8 target to the original project and goes on from there. Problem is when the project has a version other than 1.0 Nuget restore fails with “…The property PackageVersion was expected to have a single value across all target frameworks, but instead had the following values: 1.0.0, 2.0” (I took Gerald’s original code set the version to 2.0 in my test). I’m guessing PackageVersion is normally inherited from Version, but I’m at a bit of a loss as to how it should be fixed. My workaround is to add a couple of lines to my csproj file as follows:
<PackageVersion>1.0.0</PackageVersion>
<AssemblyVersion>$(ApplicationDisplayVersion).$(ApplicationVersion)</AssemblyVersion>
That works, but has a bad smell, should I be doing something else and/or is this a bug somewhere?
David Maw is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.