我正在尝试获得C#Visual Studio 2019/MSBuild作业,以在Jenkins Build Server上构建。我知道我的文件路径太长了,因此我启用了组策略编辑器中的长文件路径(并验证了它在“重新启动”服务器后已在注册表编辑器中持续存在)。
但是,现在我遇到以下错误“ Alink:致命错误AL1065:文件名...太长或无效”。
快速的Google搜索导致我进入。但是,我不知道什么是炼金术软件,以及为什么在构建过程中使用它以及为什么失败。 (尽管在最后一点,我猜想Alchemy Software .dll并不是“长地址意识”,我认为这对于应用Windows中的长路径是必不可少的。但是由于我无法找到任何 无法确定。
.dll或.exe与此软件关联,我
PS和请,没有评论我应该如何重组文件路径以使其短。我已经尝试这样做,但对于此应用程序是不切实际的。无论如何,它不断弹出并正在成为一种摩尔的情况,所以我真的宁愿修复根本原因,而不是不断地将创可贴放在各处。
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.
发布评论
评论(1)
我将把这个设置为答案,因为在汉斯·帕斯特(Hans Passant)的非常有用的评论和随后的研究之后,我认为这是非常确定的,所以这大多可以解决,而不是解决。 (可能会在此答案的末尾讨论例外。)
如那些注释中所述,此错误源自a 链接器模块称为
al.exe
smbuild用于某些项目配置之后)。可以在几个位置找到此链接器,但是对我来说,它是从c:\ program Files(x86)\ Microsoft SDKS \ Windows \ Windows \ v10.0a \ bin \ bin \ bin \ netfx 4.8 Tools
中调用的。msbuild可以处理长文件路径只要Windows配置为这样做(通过在组策略编辑中启用长路径或直接修改注册表)。但是,此
al.exe
模块不能。据我所知,没有办法强迫它这样做。因此,如果您的构建工具链需要使用此al.exe
要使用的模块,则是Sol。对于我的特殊情况,对于詹金斯(Jenkins)的工作而失败,因为我的道路太长,我通过更改工作空间来解决这个问题。因此,现在我将其更改为
d:\ jenkins \ workspaces \ [product] \ earseases \ [product_version]
,而不是默认的东西,我将其更改为d:\ j \ dd0_1c
,这对我来说很有意义。该文件夹路径的缩短避免了任何后续文件路径,从而超过了260个字符的限制。这不是一个令人满意的解决方案,但它适用于我的特定情况。我确实提到了所有这些可能的例外:如果您可以让MSBUILD完全避免使用
al.exe
,那么您可以避免此错误。我不知道MSBuild使用此模块的所有场景或工作流程,但是我确实知道,当您的应用程序具有本地化资源时,它确实可以使用。代码> al.exe 当它生成这些资源时。这正是我的情况,我发现和此页面msbuild do 利用
al.exe
。我确实尝试了这些页面中描述的步骤,并且 能够验证我不再从al.exe
中获得此Alink错误。但是,我从来没有让我的项目完全构建,因为这种重新配置会导致其他构建错误出现。因此,最终,为了权宜之计(并且因为它比执行我的代码重构更干净),所以我选择了Jenkins Workspace解决方案。但是,有趣的是,只要您的项目有利于这两个链接中给出的解决方案,您 can 避免使用
al.exe
。因此,希望,如果有人遇到同一问题,他们可能比我在使用这种方法方面取得了更多的成功。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 fromC:\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 thisal.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 toD:\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 utilizeal.exe
. I did try the steps described in these pages and was able to verify that I no longer got this ALINK error fromal.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.