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

Dotnet restore fails when ApplicationDisplayVersion has some values to configure Unit Test for MAUI #12859

Closed
danielancines opened this issue Jan 23, 2023 · 11 comments · Fixed by #15238
Labels
fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! platform/windows 🪟 t/bug Something isn't working

Comments

@danielancines
Copy link

Description

Following links like https://www.youtube.com/watch?v=C9vIDLQwc7M&t=449s to configure xUnit Tests on my Maui App, I'm having problems to add net7.0 as a TargetFrameworks and add a condition to OutputType as Library to able xUnit Project test my classes.

dotnet restore fails when I add <ApplicationDisplayVersion>1.5.0</ApplicationDisplayVersion> 1.5.0 or 1.5 for the ApplicationDisplayVersion, if the value is 1.0.0 doens't occurs. This is the error:

  "logs": [
    {
      "code": "NU1105",
      "level": "Error",
      "message": "Unable to read project information for 'Maui.UnitTestError': Sequence contains more than one element"
    }

I've been testing this for days and I figure it out that the ApplicationDisplayVersion is the problem, but I don't have ideia why.

Steps to Reproduce

  1. Create a MAUI project
  2. Add net7.0 as a TargetFrameworks option: <TargetFrameworks>net7.0;net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
  3. Go to <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> and change the version to 1.5 or 1.5.0
  4. Try to restore packages: dotnet restore
  5. Restore will fail and the file project.assets.json in obj folder will show the log error above.

Link to public reproduction project repository

https://github.com/danielancines/Maui.UnitTestError

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

dotnet 7.0.102 - VS Community 2022 17.4.4

Did you find any workaround?

I'm changing the version of my app using a config.json file.

Relevant log output

Severity	Code	Description	Project	File	Line	Suppression State
Error	NU1105	Unable to read project information for 'Maui.UnitTestError': Sequence contains more than one element	Maui.UnitTestError	C:\Users\danie\Documents\code\Maui.UnitTestError\Maui.UnitTestError\Maui.UnitTestError.csproj	1	
Error	NU1105	Unable to read project information for 'Maui.UnitTestError': Sequence contains more than one element	Maui.UnitTestError	C:\Users\danie\Documents\code\Maui.UnitTestError\Maui.UnitTestError\Maui.UnitTestError.csproj	1	
Error	NU1105	Unable to read project information for 'Maui.UnitTestError': Sequence contains more than one element	Maui.UnitTestError	C:\Users\danie\Documents\code\Maui.UnitTestError\Maui.UnitTestError\Maui.UnitTestError.csproj	1	
Error	NU1105	Unable to read project information for 'Maui.UnitTestError': Sequence contains more than one element	Maui.UnitTestError	C:\Users\danie\Documents\code\Maui.UnitTestError\Maui.UnitTestError\Maui.UnitTestError.csproj	1	
Error	NU1105	Unable to read project information for 'Maui.UnitTestError': Sequence contains more than one element	Maui.UnitTestError	C:\Users\danie\Documents\code\Maui.UnitTestError\Maui.UnitTestError\Maui.UnitTestError.csproj	1
@danielancines danielancines added the t/bug Something isn't working label Jan 23, 2023
@Eilon
Copy link
Member

Eilon commented Jan 26, 2023

@jfversluis - looks like this is a question about something you showed in a video from your channel. Any idea?

@danielancines - can you show what exactly you tried to add that didn't work? The repro you shared seems to have a fairly standard CSPROJ file, so I'm not sure if I'm missing something in the repro?

@Redth
Copy link
Member

Redth commented Jan 27, 2023

It looks like the version properties being set cause some extra targets to run thinking it's an application if you have set OutputType to Library.

You can condition these properties so they only build when your app is building as an 'app' for instance:

<PropertyGroup Condition="'$(OutputType)' != 'Library'">
		<!-- Display name -->
		<ApplicationTitle>Maui.UnitTestError</ApplicationTitle>

		<!-- App Identifier -->
		<ApplicationId>com.companyname.maui.unittesterror</ApplicationId>
		<ApplicationIdGuid>11484137-87ce-4a1b-9fe6-3af1e44f2049</ApplicationIdGuid>

		<!-- Versions -->
		<ApplicationDisplayVersion>1.5</ApplicationDisplayVersion>
		<ApplicationVersion>1</ApplicationVersion>
	</PropertyGroup>

@Redth Redth added the s/needs-info Issue needs more info from the author label Jan 27, 2023
@ghost
Copy link

ghost commented Jan 27, 2023

Hi @danielancines. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. 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.

@Redth Redth added this to the Backlog milestone Jan 27, 2023
@ghost
Copy link

ghost commented Jan 27, 2023

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@ghost ghost added the s/no-recent-activity Issue has had no recent activity label Jan 31, 2023
@ghost
Copy link

ghost commented Jan 31, 2023

This issue has been automatically marked as stale because it has been marked as requiring author feedback 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.

@danielancines
Copy link
Author

@Eilon I only changed the ApplicationDisplayVersion to 1.0.5 and the command dotnet restore, just that. I'll try what @Redth wrote above and let you guys know.

Thanks.

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author s/no-recent-activity Issue has had no recent activity labels Feb 2, 2023
@Eilon Eilon removed the s/needs-attention Issue has more information and needs another look label Feb 2, 2023
@danielancines
Copy link
Author

danielancines commented Feb 3, 2023

@Redth Unfortunately dotnet restore still failing, I'm thinking that <ApplicationDisplayVersion>1.5</ApplicationDisplayVersion> ignores the condition and still getting the same issue,

"logs": [
    {
      "code": "NU1105",
      "level": "Error",
      "message": "Unable to read project information for 'Maui.UnitTestError': Sequence contains more than one element"
    }
  ]

@danielancines
Copy link
Author

Following what was asked on issue #6626, I ran using Project System Tools and got some errors. Logs attached.

logs.zip

@danielchalmers
Copy link
Contributor

Could be related to #14524

@mattleibow
Copy link
Member

For now the easiest workaround is to add <Version>$(ApplicationVersion)</Version> in your project directly after your <ApplicationVersion>1.0</ApplicationVersion> property.

@samhouts samhouts modified the milestones: Backlog, .NET 8 Jun 7, 2023
@StepKie
Copy link

StepKie commented Jun 17, 2023

@mattleibow I have the exact same issue, and the "easiest workaround" (or the other posted above) does nothing for me, I get the exact same failures for dotnet restore

Edit: After some crosschecking in the other linked issues, I think that the "fix" was just misspelled.
What seems to work for me is

<Version>$(ApplicationDisplayVersion)</Version>

instead of

<Version>$(ApplicationVersion)</Version>

@jonathanpeppers and you even mention that this is the property that really matters, not ApplicationVersion ?!

Edit2: After playing around with it from a dotnet new template, it seems it just purely depends on what was edited last.
whenever you change ONLY ApplicationDisplayVersion or ApplicationVersion, but not the other, and it is not the one set in $(ApplicationVersionOrApplicationDisplayVersion), dotnet restore will fail

@samhouts samhouts added the fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! label Jun 21, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jul 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants