.NET MAUI PackageVersion was expected to have a single value across all target frameworks
Asked Answered
S

0

7

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. 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?

Selestina answered 27/6, 2024 at 21:27 Comment(2)
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.Knowland
I am asking the two questions my post ended with: 1. Should I be doing something else? 2. Is this a bug somewhere"? I do not know enough about either msbuild or Nuget to have an authoritative opinion on either question, hopefully someone else does.Selestina

© 2022 - 2025 — McMap. All rights reserved.