Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Versioning my Maui Android App raise multiple errors #3690

Closed
Bronzato1 opened this issue Dec 7, 2021 · 8 comments · Fixed by #6628
Closed

Versioning my Maui Android App raise multiple errors #3690

Bronzato1 opened this issue Dec 7, 2021 · 8 comments · Fixed by #6628
Assignees
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) fixed-in-6.0.300-rc.3 Look for this fix in 6.0.300-rc.3! p/0 Work that we can't release without platform/android 🤖 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@Bronzato1
Copy link

Bronzato1 commented Dec 7, 2021

Description

Previously the way to define version code for Android in Maui .csproj file was like this:

<!-- Versions -->
<ApplicationVersion>3.1.2</ApplicationVersion>
<AndroidVersionCode>3</AndroidVersionCode>

With the new release of Visual Studio Preview, this has changed to:

<ApplicationVersion>3</ApplicationVersion>

It works, from Visual Studio, I can bundle a new .aab package (see image below). We see the version code is defined to 3. Unfortunately the version is defined to 1.0.0.

Bronzato_0-1638270460170

...when imported on the Google Play Console, it look like this:
Bronzato_2-1638270667736

Unfortunately, when imported on the Google Play Console I only see the versionCode 3 (which is defined in the .csproj file as ApplicationVersion). What about the versionName (in parentheses) ? Nothing is planned in the .csproj file ? When imported on the Google Play Console, I don't want to have 3 (1.0.0) but I want 3 (3.1.2)...

https://developer.android.com/studio/publish/versioning

versionCode — A positive integer used as an internal version number.
versionName — A string used as the version number shown to users.

Someone suggested me to update my csproj file by adding:
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>

or manually set in your androidmanifest.xml:
https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/OneDotNetSingleProject.md

By adjusting my csproj file to add ApplicationDisplayVersion it raise me multiple errors:

image

Is this a bug ?

As soon as I remove this code in my csproj file, the errors disappeared.

I'm using Visual Studio Professional 2022 - Preview Version 17.1.0 Preview 1.1

I did a maui-check

Steps to Reproduce

By adjusting my csproj file to add ApplicationDisplayVersion it raise me multiple errors:

image

Version with bug

Visual Studio Professional 2022 - Preview Version 17.1.0 Preview 1.1

Maui Preview 10

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

OS: Windows 10 - Visual Studio Professional 2022 - Preview Version 17.1.0 Preview 1.1

Did you find any workaround?

Manually set inside my AndroidManifest.xml do the trick.

image

Bronzato_2-1638636605253

Relevant log output

No response

@Bronzato1 Bronzato1 added the t/bug Something isn't working label Dec 7, 2021
@SilverioMiranda
Copy link

Same problem here

@kristinx0211 kristinx0211 added the s/verified Verified / Reproducible Issue ready for Engineering Triage label Mar 3, 2022
@kristinx0211
Copy link

Repro on Version 17.2.0 Preview 2.0 [32216.282.main] and the above project.

@Redth Redth added platform/android 🤖 area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) s/needs-repro Attach a solution or code which reproduces the issue labels Mar 22, 2022
@Redth Redth added this to the 6.0.300 milestone Mar 22, 2022
@ghost
Copy link

ghost commented Mar 22, 2022

Hi @Bronzato1. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@ghost ghost added the s/no-recent-activity Issue has had no recent activity label Mar 28, 2022
@ghost
Copy link

ghost commented Mar 28, 2022

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@SilverioMiranda
Copy link

Steps do reproduce :

Download latest VS 2022 Preview Version
Create New MAUI Blazor App
Change ApplicationDisplayVersion to anything other than 1.0
Build

image

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue s/no-recent-activity Issue has had no recent activity labels Mar 28, 2022
@Eilon
Copy link
Member

Eilon commented Apr 13, 2022

@zetaFairlight
Copy link

zetaFairlight commented Apr 26, 2022

I have VS 2022 RC, and in a MAUI new app by simply changing the version number in the project file, it creates fatal errors.
How to replicate the bug: Change from 1.0 to 0.1 <ApplicationDisplayVersion>0.1</ApplicationDisplayVersion>

The error in this case was: Error NETSDK1005
Assets file 'C:\Users\Pablo\source\repos\Test1\Test1\obj\project.assets.json' doesn't have a target for 'net6.0-windows10.0.19041'. Ensure that restore has run and that you have included 'net6.0-windows10.0.19041' in the TargetFrameworks for your project.

2022-04-25 21_02_12-Test1 - Microsoft Visual Studio Preview
2022-04-25 21_02_40-Test1 - Microsoft Visual Studio Preview

@davidortinau davidortinau added the p/0 Work that we can't release without label Apr 28, 2022
@jonathanpeppers
Copy link
Member

It looks like changing $(ApplicationDisplayVersion) triggers a bug in NuGet (when inside Visual Studio).

See:

jonathanpeppers added a commit to jonathanpeppers/maui that referenced this issue Apr 28, 2022
Fixes: dotnet#3690
Fixes: dotnet#6626

Changing `$(ApplicationDisplayVersion)` inside Visual Studio causes
builds to fail:

    Error NU1105 Unable to read project information for 'MauiApp15': Sequence contains more than one element
    Error NU1105 Unable to read project information for 'MauiApp15': Sequence contains more than one element
    Error NU1105 Unable to read project information for 'MauiApp15': Sequence contains more than one element
    Error NU1105 Unable to read project information for 'MauiApp15': Sequence contains more than one element

You get this error once per `TargetFramework`. Builds outside VS work
fine! `dotnet build` succeeds.

I was able to attach a debugger to VS, and hit a breakpoint on this
line in NuGet:

https://github.com/NuGet/NuGet.Client/blob/82630f7f8fb5114a207c295f2f9bea1bc2a6b3cf/src/NuGet.Clients/NuGet.SolutionRestoreManager/VsSolutionRestoreService.cs#L227

With a stack trace of:

    This exception was originally thrown at this call stack:
    System.Linq.Enumerable.SingleOrDefault<TSource>(System.Collections.Generic.IEnumerable<TSource>)
    NuGet.SolutionRestoreManager.VSNominationUtilities.GetPackageVersion(System.Collections.IEnumerable) in VSNominationUtilities.cs
    NuGet.SolutionRestoreManager.VsSolutionRestoreService.ToPackageSpec(NuGet.VisualStudio.ProjectNames, System.Collections.IEnumerable, string, string) in VsSolutionRestoreService.cs
    NuGet.SolutionRestoreManager.VsSolutionRestoreService.ToDependencyGraphSpec(NuGet.VisualStudio.ProjectNames, NuGet.SolutionRestoreManager.IVsProjectRestoreInfo, NuGet.SolutionRestoreManager.IVsProjectRestoreInfo2) in VsSolutionRestoreService.cs
    NuGet.SolutionRestoreManager.VsSolutionRestoreService.NominateProjectAsync(string, NuGet.SolutionRestoreManager.IVsProjectRestoreInfo, NuGet.SolutionRestoreManager.IVsProjectRestoreInfo2, System.Threading.CancellationToken) in VsSolutionRestoreService.cs

This appears to be caused by an issue with NuGet inside Visual Studio:

NuGet/Home#6461

If you get a different `$(PackageVersion)` for any TF, you run into
this.

It appears we set `$(Version)` based off of
`$(ApplicationDisplayVersion)` in all of the mobile workloads:
Android, MacCatalyst, iOS, etc. Then `$(PackageVersion)` is also based
on `$(Version)`.

* https://github.com/xamarin/xamarin-android/blob/d4da1c252f45c4910abc1bd9e5be9ecf9dc683a0/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets#L114
* https://github.com/xamarin/xamarin-macios/blob/b84b80902c91cc99e88aac734761c9d0d99ce42f/dotnet/targets/Xamarin.Shared.Sdk.targets#L7

Except when using MAUI for net6.0-windows. To workaround this issue,
we can put the same code in `WinUI.targets`:

    <Version Condition=" '$(ApplicationDisplayVersion)' != '' ">$(ApplicationDisplayVersion)</Version>

This seems reasonable for our WinUI support in MAUI anyway, as we have
code that makes `$(ApplicationDisplayVersion)` work there.
mattleibow pushed a commit that referenced this issue Apr 29, 2022
…6628)

Fixes: #3690
Fixes: #6626

Changing `$(ApplicationDisplayVersion)` inside Visual Studio causes
builds to fail:

    Error NU1105 Unable to read project information for 'MauiApp15': Sequence contains more than one element
    Error NU1105 Unable to read project information for 'MauiApp15': Sequence contains more than one element
    Error NU1105 Unable to read project information for 'MauiApp15': Sequence contains more than one element
    Error NU1105 Unable to read project information for 'MauiApp15': Sequence contains more than one element

You get this error once per `TargetFramework`. Builds outside VS work
fine! `dotnet build` succeeds.

I was able to attach a debugger to VS, and hit a breakpoint on this
line in NuGet:

https://github.com/NuGet/NuGet.Client/blob/82630f7f8fb5114a207c295f2f9bea1bc2a6b3cf/src/NuGet.Clients/NuGet.SolutionRestoreManager/VsSolutionRestoreService.cs#L227

With a stack trace of:

    This exception was originally thrown at this call stack:
    System.Linq.Enumerable.SingleOrDefault<TSource>(System.Collections.Generic.IEnumerable<TSource>)
    NuGet.SolutionRestoreManager.VSNominationUtilities.GetPackageVersion(System.Collections.IEnumerable) in VSNominationUtilities.cs
    NuGet.SolutionRestoreManager.VsSolutionRestoreService.ToPackageSpec(NuGet.VisualStudio.ProjectNames, System.Collections.IEnumerable, string, string) in VsSolutionRestoreService.cs
    NuGet.SolutionRestoreManager.VsSolutionRestoreService.ToDependencyGraphSpec(NuGet.VisualStudio.ProjectNames, NuGet.SolutionRestoreManager.IVsProjectRestoreInfo, NuGet.SolutionRestoreManager.IVsProjectRestoreInfo2) in VsSolutionRestoreService.cs
    NuGet.SolutionRestoreManager.VsSolutionRestoreService.NominateProjectAsync(string, NuGet.SolutionRestoreManager.IVsProjectRestoreInfo, NuGet.SolutionRestoreManager.IVsProjectRestoreInfo2, System.Threading.CancellationToken) in VsSolutionRestoreService.cs

This appears to be caused by an issue with NuGet inside Visual Studio:

NuGet/Home#6461

If you get a different `$(PackageVersion)` for any TF, you run into
this.

It appears we set `$(Version)` based off of
`$(ApplicationDisplayVersion)` in all of the mobile workloads:
Android, MacCatalyst, iOS, etc. Then `$(PackageVersion)` is also based
on `$(Version)`.

* https://github.com/xamarin/xamarin-android/blob/d4da1c252f45c4910abc1bd9e5be9ecf9dc683a0/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets#L114
* https://github.com/xamarin/xamarin-macios/blob/b84b80902c91cc99e88aac734761c9d0d99ce42f/dotnet/targets/Xamarin.Shared.Sdk.targets#L7

Except when using MAUI for net6.0-windows. To workaround this issue,
we can put the same code in `WinUI.targets`:

    <Version Condition=" '$(ApplicationDisplayVersion)' != '' ">$(ApplicationDisplayVersion)</Version>

This seems reasonable for our WinUI support in MAUI anyway, as we have
code that makes `$(ApplicationDisplayVersion)` work there.
@ghost ghost locked as resolved and limited conversation to collaborators May 29, 2022
@samhouts samhouts added the fixed-in-6.0.300-rc.3 Look for this fix in 6.0.300-rc.3! label Jul 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) fixed-in-6.0.300-rc.3 Look for this fix in 6.0.300-rc.3! p/0 Work that we can't release without platform/android 🤖 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants