Al.exe finds the correct tool based on platform#7051
Conversation
Added an X64 processor architecture variable for consistency. Ref assemblies also updated.
e51a1e6 to
753ffff
Compare
| /// <summary> | ||
| /// Represents the 64-bit AMD64 processor architecture. | ||
| /// </summary> | ||
| public const string X64 = "x64"; |
There was a problem hiding this comment.
I don't think I like adding this since it's redundant with AMD64. Can it be avoided, perhaps by mapping x64->amd64 higher in the callstack?
There was a problem hiding this comment.
You mean modifying the switch case to be "x64" => Path.Combine(sdkToolsPath, "x64"),? Or checking if the platform is x64, then pass AMD64 into GeneratePathToTool?
I'll add another switch 1 stack frame higher than GeneratePathToTool
There was a problem hiding this comment.
I was thinking the latter (around the archToLookFor thing).
There was a problem hiding this comment.
The task has a Prefer32Bit parameters which also plays a role in the tool invocation. It is intentional to ignore it here and use only Platform, is that correct?
There was a problem hiding this comment.
I think that's only if the platform is AnyCPU.
There was a problem hiding this comment.
The task has a Prefer32Bit parameters which also plays a role in the tool invocation. It is intentional to ignore it here and use only Platform, is that correct?
I was sort of torn here. Prefer32Bit has existed here for a while, but I decided not to use it for the sake of the customer. I haven't seen a single customer want to use x64 Al on a 32 bit platform (and vise-versa), and I'm not sure a customer would want that warning? If we take on Prefer32Bit (which csc uses), we increase complexity unless it's some new AlPrefer32Bit which is a new opt in for customers.
If we just use Platform customer's don't need to do anything and it "just works."
There was a problem hiding this comment.
Nit:
Delete extra space in untouched file.
There was a problem hiding this comment.
I think that's only if the platform is AnyCPU.
There was a problem hiding this comment.
Is this one of those cases where SdkToolsPathUtility.FileInfoExists is secretly slower than f => SdkToolsPathUtility.FileInfoExists(f)?
There was a problem hiding this comment.
😮 can you post an example of us making that change?
There was a problem hiding this comment.
Yeah, this thing is devious. It's not a big deal here since this isn't a hot loop but please go ahead and fix.
655bd2d to
0436d43
Compare
There was a problem hiding this comment.
Yeah, this thing is devious. It's not a big deal here since this isn't a hot loop but please go ahead and fix.
Finally puts #5981 to bed.
(to trigger an auto-close: fixes #5981)
Context
The underlying problem with the Al issues is that the Al task finds its own tool based on the current process' architecture. This means:
x86 msbuild.exe -> x86 Al.exe
x64 msbuild.exe -> x64 Al.exe
Now, if your x86 msbuild.exe is building with
Platform=x64, the x86 Al.exe gets passedplatform:x64and logs its own warning because of mismatched platforms.So we fixed that by checking if the platform was x64, then look in the x64 tools directory in common.targets.
Now we're hitting problems where the x64 msbuild.exe is calling the x64 Al.exe and being passed
platform:x86, causing the reverse of the original issue!Changes Made
The Al task checks the platform that was passed. If it's x86, it will find the 32 bit al.exe. If x64, it will append x64 to the path before finding the tool.
This also reverts appending x64 to the tools directory in common.currentversion.targets before calling the Al task. It shouldn't have worked in today's x64 msbuild.exe, but does because of the x86 fallback behavior. Apending x64 before the task is called is no longer required.
Testing
Notes
I allowed
_ALExeToolPathto be overridden to account for projects that may be using it today with older msbuild binaries.A mismatched common.currentversion.targets & microsoft.build.dll can fail.
Old targets & new dll: if platform is x64 it will double append x64, but the fallback will find the x64 al.exe.
no fix required.
if platform is x86 and x64 is appended to the path: will likely find the x64 tool and log the error.
fix: customer should no longer append x64 to the path.
new targets & old dll: for platform=x64,
x64needs to be manually appended. The "source of truth" is settingAlToolPathto end inx64.for platform=x86, no fix needed.