-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[AOT] Clean up AOT build issue in Common.UI #36376
base: main
Are you sure you want to change the base?
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, just a minor comments.
<PropertyGroup> | ||
<UseWPF>true</UseWPF> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaimecbernardo - Did we have to add the UseWPF
and UseWindowsForms
in this project for the alignment of the dll versions? I can't remember if it was THIS one or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, This was the one. Well remembered. That's why CI isn't passing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh...sad news. Any suggestion? I will investigate how to align the dll version. If any suggestion ,please let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI isn't passing because different dll versions for the same dependencies are being used. This is one of the reasons why both WPF and UseWindowsForms are in Common.UI
@jaimecbernardo Could you please give me more context about why we need to do this check? I did some investigate and find out those dll (such as System.Drawing.dll) ref from "runtimepack.Microsoft.NETCore.App.Runtime.win-x64/9.0.0" and seems that it's hard to specific a version for those dll. Thoese assemblyVersion are the same (4.0.0.0) but the fileVersion are different. |
Hi @moooyo , This requires some context indeed 😄 When we upgraded to .NET 9, different .NET dlls where shipped on the 9.00 SDKs with different file versions. Here's a snippet of my analysis at the time. Not even assembly Versions match.
So on the .NET 9 Upgrade PR, we made everything depend on WPF and WinForms to make sure the latest dll version would be picked for every dependency. I hope this helps. |
@jaimecbernardo Thanks for your reply. That's a amazing work. Make a exception (add some change to let them use different dll) maybe a choice, but I don't wan to solve by this way. If we add one exception, I believe there will be more and more exceptions... So, how about adding another props file to do the same thing? I mean we can create a props file and add UseWPF in this file. Then let every csproj file import it. By this way, we can keep the aot compatibility of common.UI logic code and avoid the new code to break it. |
Currently, most of our modules use WPF or WindowsForm to implement UI. We can not make these publish with AOT enabled. That's why I want to remove UseWPF and UseWindowsForms in common.UI. |
@moooyo , you can give it a try, but I think you'll likely still get these conflicts on different applications reporting using different dll versions 🤔 $targetDir = 'D:\janeasystems\PowerToys\x64\Release'
$referencedFileVersionsPerDll = @{}
$totalFailures = 0
Get-ChildItem $targetDir -Recurse -Filter *.deps.json -Exclude UITests-FancyZones*,MouseJump.Common.UnitTests* | ForEach-Object {
$depsJsonFullFileName = $_.FullName
$depsJsonFileName = $_.Name
$depsJson = Get-Content $depsJsonFullFileName | ConvertFrom-Json
# We're doing a breadth first search to look for every runtime object.
$iterateThroughEveryField = New-Object System.Collections.Generic.Queue[System.Object]
$iterateThroughEveryField.Enqueue($depsJson)
while($iterateThroughEveryField.Count -gt 0)
{
$currentObject = $iterateThroughEveryField.Dequeue();
$currentObject.PSObject.Properties | ForEach-Object {
if($_.Name -ne 'SyncRoot') {
# Skip SyncRoot to avoid looping in array objects.
# Care only about objects, not value types.
$iterateThroughEveryField.Enqueue($_.Value)
if($_.Name -eq 'runtime')
{
# Cycle through each dll.
$_.Value.PSObject.Properties | ForEach-Object {
if($_.Name.EndsWith('.dll')) {
$dllName = Split-Path $_.Name -leaf
if([bool]($_.Value.PSObject.Properties.name -match 'fileVersion')) {
$dllFileVersion = $_.Value.fileVersion
if ([string]::IsNullOrEmpty($dllFileVersion) -and $dllName.StartsWith('PowerToys.'))` {
# After VS 17.11 update some of PowerToys dlls have no fileVersion in deps.json even though the
# version is correctly set. This is a workaround to skip our dlls as we are confident that all of
# our dlls share the same version across the dependencies.
continue
}
# Add the entry to the dictionary of dictionary of lists
if(-Not $referencedFileVersionsPerDll.ContainsKey($dllName)) {
$referencedFileVersionsPerDll[$dllName] = @{ $dllFileVersion = New-Object System.Collections.Generic.List[System.String] }
} elseif(-Not $referencedFileVersionsPerDll[$dllName].ContainsKey($dllFileVersion)) {
$referencedFileVersionsPerDll[$dllName][$dllFileVersion] = New-Object System.Collections.Generic.List[System.String]
}
$referencedFileVersionsPerDll[$dllName][$dllFileVersion].Add($depsJsonFileName)
}
}
}
}
}
}
}
}
$referencedFileVersionsPerDll.keys | ForEach-Object {
if($referencedFileVersionsPerDll[$_].Count -gt 1) {
$dllName = $_
Write-Host $dllName
$referencedFileVersionsPerDll[$dllName].keys | ForEach-Object {
Write-Host "`t" $_
$referencedFileVersionsPerDll[$dllName][$_] | ForEach-Object {
Write-Host "`t`t" $_
}
}
$totalFailures++;
}
}
|
@jaimecbernardo Ohh, you are right. That's no benefit to solve this problem. Let me add them back first. |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Anyway, we can continue to move on this PR. Could you please review again. In addition, I saw you mentioned that currently, WinUI3 app use their own dlls not the root folder one. Now, we can not enable AOT in the WinUI3 modules. That's a trick thing I guess. Maybe we can change the check script to do the independent check for root folder and WinUI3 folder? I'm not sure my understanding is true. Any insight? @jaimecbernardo |
@moooyo , That might be something that works, but I do wonder I then some dlls that are conflicting won't be verified because of "dependencies of dependencies" which deps.json file would be verified in root but not in WinUI3Apps folders 🤔 Something that can be tried out, I guess, but it must be verified that we still get a good check within WinUI3Apps folder. |
Sure, Thanks! I will continue to investigate. Anyway, we can continue to move on this PR without the change of remove UseWPF and UseWindowsForms. |
Summary of the Pull Request
PR Checklist
I have tested this PR in my local env.
Detailed Description of the Pull Request / Additional comments
Let me explain why we need this change.
Validation Steps Performed