1

I am trying to get a C# Visual Studio 2019/MSBuild job to build on a Jenkins build server. I know that my file paths are too long, so I have enabled Long File Paths in the Group Policy Editor (and verified that it has persisted in the registry editor after a server restart).

However, now I am getting the following error "ALINK: fatal error AL1065: File name ... is too long or invalid".

A quick google search led me to this page for Alchemy Software. However I have no idea what Alchemy Software is and why it is being used in the build process and why it is failing. (Although for the last point, I'm guessing that the Alchemy Software .dll is not "Long Address Aware", which I believe is necessary for an application to take advantage of Long Paths in Windows. But since I can't locate any .dll or .exe associated with this software, I can't be certain.)

Does anyone know why my build is still failing with this error, what Alchemy Software is, and how to get it to take advantage of Long Paths in Windows?

P.S. And please, no comments about how I should restructure my file paths to be shorter. I have tried doing that but it's impractical for this application. And anyway, it keeps popping up and is becoming a whack-a-mole situation, so I'd really rather fix the root cause rather than constantly putting band-aids everywhere.

Andrew
  • 342
  • 3
  • 12
  • ALINK is a module used by the legacy C# compiler, it is responsible for generating the .dll or .exe file. It takes two to tango long paths, has to be enabled in the OS *and* the app needs to explicitly state that it is compatible in its manifest. The legacy C# compiler stored in c:\windows\microsoft.net doesn't have that manifest entry. The modern Roslyn-based one does. Not clear why you're using the legacy compiler, but it is a typical jenkins problem. Google "vs2019 build tools" to get ahead. – Hans Passant Jun 29 '22 at 23:47
  • Thanks for the insight, @HansPassant. I'm glad to hear someone has heard of this module. : ) So I combed through our build log and it looks like all references to MSBuild point to one of two locations: "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\bin\MSBuild.exe" and ":\Program Files\Microsoft Visual Studio\2022\Professional\Msbuild\Current\Bin\Roslyn\csc.exe" I have checked both of these exes and they both say they are Large Address Aware in their manifest. So from what I can tell, our job is using the most modern compiler. Unless I'm missing something? – Andrew Jun 30 '22 at 00:54
  • I noticed towards the bottom of our build log, there's a call to "(GenerateSatelliteAssemblies target)" right before the error message. A search led me to this page (https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-targets?view=vs-2022), and down where it references GenerateSatelliteAssemblies it says "Actually run al.exe to create the satellite assemblies". Further search and I found al.exe at "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin". I checked the headers and it is in fact NOT large address aware... So, what to do now...? – Andrew Jun 30 '22 at 01:14
  • Further digging in the build log and found that the al.exe being use is actually located at "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools", for whatever that's worth. I did try modifying that exe with "editbin /LARGEADDRESSAWARE al.exe" and verified that the header was changed to indicate that it was LAA. However that did not seem to resolve the issue. – Andrew Jun 30 '22 at 01:30
  • "Large address aware" is a very different kind of .exe option. Long path support takes a manifest entry, it typically looks like `true`. And yes, al.exe is missing it, and it also uses ALINK so you found the troublemaker. You're pretty stuck. A desperation move is googling "resource hacker edit manifest", but it is not so obvious that al.exe is actually long path compatible (built in C++). You could file a bug. – Hans Passant Jun 30 '22 at 01:32
  • Hm, that's a bummer. I'll have to ponder what my next step is. One of our IT guys suggested mapping the solution folder to a lettered drive so as to shorten the overall path. I might try that if no other options are left. But in regard to figuring out this this error, I appreciate all your input, @HansPassant. I learned quite a lot. – Andrew Jun 30 '22 at 16:11

1 Answers1

1

I am going to set this as an answer since, after Hans Passant's very helpful comments and subsequent research, I think it's pretty definitive that this can mostly only be worked around, not resolved. (As possible exception will be discussed at the end of this answer.)

As stated in those comments, this error originates from a linker module called al.exe that is utilized by MSBuild for certain project configurations (more on that later). This linker can be found in a couple places, but for me it was being called from C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools.

MSBuild can handle long file paths as long as Windows is configured to do so (by enabling long paths in the Group Policy Editor or by modifying the registry directly). However this al.exe module cannot. And as far as I can tell, there's no way to force it to do so. So if your build tool chain requires this al.exe module to be used, you're kind of SOL.

For my particular situation, for a job in Jenkins that was failing because my paths were too long, I worked around this by changing the workspace of my job. So now instead of the default of something like D:\Jenkins\workspaces\[product]\Releases\[product_version], I changed it to D:\j\dd0_1c, which is an encoding that makes sense to me. This shortening of the folder path avoids any subsequent file paths from exceeding the limit of 260 characters. It's not a satisfying solution, but it works for my particular situation.

I did mention that there was a possible exception to all of this: if you can get MSBuild to avoid using al.exe altogether, then you can avoid this error.

I don't know all of the scenarios or workflows in which MSBuild utilizes this module, but I do know that it does get utilized when your application has localized resources, and somehow, some way, MSBuild uses al.exe when it is generating those resources. This was exactly my scenario, and I found this page and this page describing how you can reconfigure your localization projects such that MSBuild does not utilize al.exe. I did try the steps described in these pages and was able to verify that I no longer got this ALINK error from al.exe. However I never got my project to fully build since this reconfiguration caused other build errors to crop up. So in the end, for the sake of expediency (and because it was cleaner than performing a major refactor of my code), I went with the Jenkins workspace workaround. However, it is interesting to note that you can get MSBuild to avoid using al.exe as long as your project is conducive to the solution given in those two links. So hopefully, if someone runs into this same issue, they might have more success than I in utilizing this method.

Andrew
  • 342
  • 3
  • 12