Relative Content

Tag Archive for .netnuget

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

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:

How to hide types of a NuGet package

I developed a .NET 8 NuGet package “A”, which uses a 3rd party NuGet packages “B”, in turn uses the Json.Net(Newtonsoft.Json) package.