.netvisual-studiomaui

The property PackageVersion was expected to have a single value across all target frameworks


The error I'm getting after loading the solution is - "Unable to read project information for 'MauiApp': 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"

Does anyone here know how to solve this problem? I don't even know what it is saying. When I double click the error it opens the text of the csproj file but the very beginning at no particular line number. I'm not sure what versions it is referring to.

My Maui app was working perfectly fine 8 months ago, I built and published it to Google Play store. Now 8 months later I have to push an update, so I open the solution in VS 2022 and it doesn't work. all the NuGet packages are gone (it looks like nothing is installed from the package manager, but the dependencies are still listed in the solution explorer with warning symbols).

I created a brand new Maui App to check maybe my computer doesn't have .net 8 sdk on it, but I created the app just fine and no problems building it using sdk version 8.0. However when I look in my installed programs, I only had .net 9 installed. I tried installing .net 8 sdk as well but it still didn't fix the issue.

The one thing I'm not sure about is the exact version of the .net 8 sdk that I was using 8 months ago. One thought I had was that it was looking for the dependencies in the wrong sdk folder, but if that's true how do I check what exact version it is looking for?

Any other ideas?

EDIT: here is a copy of my csproj file

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
    <TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
    <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
    <!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
    <!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->

    <!-- Note for MacCatalyst:
    The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
    When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
    The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
    either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
    <!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->

    <OutputType>Exe</OutputType>
    <RootNamespace>mauiapp</RootNamespace>
    <UseMaui>true</UseMaui>
    <SingleProject>true</SingleProject>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>

    <!-- Display name -->
    <ApplicationTitle>mauiapp</ApplicationTitle>

    <!-- App Identifier -->
    <ApplicationId>com.companyname.mauiapp</ApplicationId>

    <!-- Versions -->
    <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
    <ApplicationVersion>1</ApplicationVersion>

    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
    <TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">
  <ApplicationTitle>appstorename</ApplicationTitle>
  <ApplicationId>com.companynameinc.appstorename</ApplicationId>
  <AndroidKeyStore>False</AndroidKeyStore>
  <RunAOTCompilation>False</RunAOTCompilation>
  <ApplicationVersion>2</ApplicationVersion>
  <ApplicationDisplayVersion>2.0</ApplicationDisplayVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'">
  <ApplicationTitle>appstorename</ApplicationTitle>
  <ApplicationId>com.companynameinc.appstorename</ApplicationId>
  <ApplicationVersion>2</ApplicationVersion>
  <ApplicationDisplayVersion>2.0</ApplicationDisplayVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-maccatalyst|AnyCPU'">
  <ApplicationTitle>appstorename</ApplicationTitle>
  <ApplicationId>com.companynameinc.appstorename</ApplicationId>
  <ApplicationVersion>2</ApplicationVersion>
  <ApplicationDisplayVersion>2.0</ApplicationDisplayVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-windows10.0.19041.0|AnyCPU'">
  <ApplicationTitle>appstorename</ApplicationTitle>
  <ApplicationId>com.companynameinc.appstorename</ApplicationId>
  <ApplicationVersion>2</ApplicationVersion>
  <ApplicationDisplayVersion>2.0</ApplicationDisplayVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android|AnyCPU'">
  <ApplicationTitle>appstorename</ApplicationTitle>
  <ApplicationId>com.companynameinc.appstorename</ApplicationId>
  <AndroidKeyStore>False</AndroidKeyStore>
  <ApplicationVersion>2</ApplicationVersion>
  <ApplicationDisplayVersion>2.0</ApplicationDisplayVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-ios|AnyCPU'">
  <ApplicationTitle>appstorename</ApplicationTitle>
  <ApplicationId>com.companynameinc.appstorename</ApplicationId>
  <ApplicationVersion>2</ApplicationVersion>
  <ApplicationDisplayVersion>2.0</ApplicationDisplayVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-maccatalyst|AnyCPU'">
  <ApplicationTitle>appstorename</ApplicationTitle>
  <ApplicationId>com.companynameinc.appstorename</ApplicationId>
  <ApplicationVersion>2</ApplicationVersion>
  <ApplicationDisplayVersion>2.0</ApplicationDisplayVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-windows10.0.19041.0|AnyCPU'">
  <ApplicationTitle>appstorename</ApplicationTitle>
  <ApplicationId>com.companynameinc.appstorename</ApplicationId>
  <ApplicationVersion>2</ApplicationVersion>
  <ApplicationDisplayVersion>2.0</ApplicationDisplayVersion>
</PropertyGroup>

<ItemGroup>
    <!-- App Icon -->

    <!-- Splash Screen -->
    <MauiSplashScreen Include="Resources\AppIcon\appiconfg.svg" />
    <MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

    <!-- Images -->
    <MauiImage Include="Resources\Images\*" />
    <MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />

    <!-- Custom Fonts -->
    <MauiFont Include="Resources\Fonts\*" />

    <!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
    <MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
  <None Remove="Resources\AppIcon\appicon.svg" />
  <None Remove="Resources\AppIcon\appiconfg.svg" />
  <None Remove="signed_bundles\com.companynameinc.appstorename.aab" />
</ItemGroup>

<ItemGroup>
    <PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
    <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
  <Folder Include="signed_bundles\" />
</ItemGroup>

<ItemGroup>
  <MauiIcon Include="Resources\AppIcon\appicon.svg" />
</ItemGroup>

<ItemGroup>
  <Compile Update="Properties\Resources.Designer.cs">
    <DesignTime>True</DesignTime>
    <AutoGen>True</AutoGen>
    <DependentUpon>Resources.resx</DependentUpon>
  </Compile>
</ItemGroup>

<ItemGroup>
  <EmbeddedResource Update="Properties\Resources.resx">
    <Generator>ResXFileCodeGenerator</Generator>
    <LastGenOutput>Resources.Designer.cs</LastGenOutput>
  </EmbeddedResource>
</ItemGroup>

Solution

  • Your project file has this in the top "general" PropertyGroup:

    <ApplicationVersion>1</ApplicationVersion>
    

    ... but in all the subsequent PropertyGroup entries, specific to individual platforms, you've got:

    <ApplicationVersion>2</ApplicationVersion>
    

    Assuming you actually want to publish a v2, I'd suggest you update the version in the "general" part to 2, and then remove the elements from all the specific sections. You may even want to get rid of the platform-specific sections entirely, given that they're all the same. The less variation you can have, the better.