Unittests not working after changing ApplicationDisplayVersion different from ApplicationVersion
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 290
Description
### Description
When changing the `ApplicationDisplayVersion `to another value then the `ApplicationVersion `in the csproj file, the build is failing.
But since `ApplicationDisplayVersion `is a string and `ApplicationVersion`, this causes issues when my `ApplicationDisplayVersion `becomes f.e. `1.0.1` (no way to input this an integer in the `ApplicationVersion`)
I have found similar issues which are closed but no solution provided, see f.e.
- #25828
- #6626
- and on nuget github: https://github.com/NuGet/Home/issues/6461
Is there any workaround to run unittests if the `ApplicationDisplayVersion ` is different from the `ApplicationVersion `?
@jfversluis this also occurs on your sample project on https://github.com/jfversluis/MauixUnitTestSample but in #25828 you say you cannot reproduce this, my suspicion is that you didn't clean your bin & obj folders in between builds. Can you please check again after cleaning those folders between each build (`!delObjBinFolderInCurrentAndLower.cmd` from the repo here under can be used to clean them)
### Steps to Reproduce
1. open repo https://github.com/3sRykaert/MauiMemoryleak/tree/UnitTest (branch UnitTest)
2. Run all tests in solution => All ok
3. Run `!delObjBinFolderInCurrentAndLower.cmd` to clean all obj & bin folders
4. Change `1.0.0` in `MauiMemoryleak.csproj` to `1.0.1`
5. The builds fails with the following error:
`Assets file 'MauiMemoryleak\MauiMemoryleak\obj\project.assets.json' doesn't have a target for 'net10.0'. Ensure that restore has run and that you have included 'net10.0' in the TargetFrameworks for your project.`
And in `\MauiMemoryleak\MauiMemoryleak\obj\project.assets.json` the following error is thrown: `Unable to read project information for 'MauiMemoryleak': The property PackageVersion was expected to have a single value across all target frameworks, but instead had the following values: 1.0.0, 1.0.1`
### Link to public reproduction project repository
https://github.com/3sRykaert/MauiMemoryleak/tree/UnitTest (branch UnitTest)
### Version with bug
10.0.30
### Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
### Last version that worked well
Unknown/Other
### Affected platforms
Android, Windows, iOS, macOS, Other (Tizen, Linux, etc. not supported by Microsoft directly)
### Affected platform versions
_No response_
### Did you find any workaround?
No
### Relevant log output
```shell
```
Contributor guide
Research direction
Start with the MauiMemoryleak.csproj reproduction and the clean command !delObjBinFolderInCurrentAndLower.cmd, then inspect obj/project.assets.json after changing ApplicationDisplayVersion. Compare the generated PackageVersion values across target frameworks and run the solution's unit tests; done means the build and tests succeed when ApplicationDisplayVersion differs from ApplicationVersion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100