C# 任务失败,因为找不到 AL.exe,

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1109955/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 08:27:51  来源:igfitidea点击:

Task failed because AL.exe was not found,

c#visual-studio-2008

提问by Juri

I'm getting the following error when compiling my project:

编译我的项目时出现以下错误:

Task failed because "AL.exe" was not found, or the correct Microsoft Windows SDK is not installed. The task is looking for "AL.exe" in the "bin" subdirectory beneath the location specified in the InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A. You may be able to solve the problem by doing one of the following:

  1. Install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5.
  2. Install Visual Studio 2008.
  3. Manually set the above registry key to the correct location.
  4. Pass the correct location into the "ToolPath" parameter of the task.

任务失败,因为未找到“AL.exe”,或未安装正确的 Microsoft Windows SDK。该任务正在注册表项的 InstallationFolder 值中指定的位置下的“bin”子目录中查找“AL.exe” HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A。您可以通过执行以下操作之一来解决问题:

  1. 安装适用于 Windows Server 2008 和 .NET Framework 3.5 的 Microsoft Windows SDK。
  2. 安装 Visual Studio 2008。
  3. 手动将上面的注册表项设置到正确的位置。
  4. 将正确的位置传递到任务的“ToolPath”参数中。

This error comes when I'm adding resource files to my folder in my UnitTest project. These resource files aren't directly used by my program for localization, they're just like normal files. I need them for unit testing some logic inside my program which loads these resource files using the ResXResourceReader.

当我将资源文件添加到我的 UnitTest 项目中的文件夹时,会出现此错误。这些资源文件不是我的程序直接用于本地化的,它们就像普通文件一样。我需要它们来对我的程序中的一些逻辑进行单元测试,这些逻辑使用ResXResourceReader.

Can someone explain me why this error comes up??

有人能解释一下为什么会出现这个错误吗??

Edit: Installing the Windows SDK solved the issue, as also described in the error. But I'd still like to know why the error appeared. I doesn't make sense to me.

编辑:安装 Windows SDK 解决了该问题,如错误中所述。但我仍然想知道为什么会出现错误。我对我没有意义。

回答by vicky koul

Unload your project and then edit your .csproj file you will see an import Task

卸载您的项目,然后编辑您的 .csproj 文件,您将看到一个导入任务

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> 

MSBuildBinPath = "C:\WINDOWS\Microsoft.NET\Framework\v3.5" if ur project is targetting .Net 3.5

MSBuildBinPath = "C:\WINDOWS\Microsoft.NET\Framework\v3.5" 如果你的项目是针对 .Net 3.5

then go to

然后去

C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.CSharp.targets file

C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.CSharp.targets 文件

open this file in notepad and search for AL task and you will get something like this

在记事本中打开这个文件并搜索 AL 任务,你会得到这样的东西

 <AL AlgorithmId="$(Satellite_AlgorithmId)"
            BaseAddress="$(Satellite_BaseAddress)"
            CompanyName="$(Satellite_CompanyName)"
            Configuration="$(Satellite_Configuration)"
            Copyright="$(Satellite_Copyright)"
            Culture="%(Culture)"
            DelaySign="$(DelaySign)"
            Description="$(Satellite_Description)"
            EmbedResources="@(_SatelliteAssemblyResourceInputs)"
            EvidenceFile="$(Satellite_EvidenceFile)"
            FileVersion="$(Satellite_FileVersion)"
            Flags="$(Satellite_Flags)"
            GenerateFullPaths="$(Satellite_GenerateFullPaths)"
            KeyContainer="$(KeyContainerName)"
            KeyFile="$(KeyOriginatorFile)"
            LinkResources="@(Satellite_LinkResource)"
            MainEntryPoint="$(Satellite_MainEntryPoint)"
            OutputAssembly="$(IntermediateOutputPath)%(Culture)$(TargetName).resources.dll"
            Platform="$(PlatformTarget)"
            ProductName="$(Satellite_ProductName)"
            ProductVersion="$(Satellite_ProductVersion)"
            ResponseFiles="@(AlResponseFile)"
            SourceModules="@(Satellite_SourceModule)"
            TargetType="$(Satellite_TargetType)"
            TemplateFile="$(IntermediateOutputPath)$(TargetName)$(TargetExt)"
            Title="$(Satellite_Title)"
            ****ToolPath="C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727"****
            Trademark="$(Satellite_Trademark)"
            Version="$(Satellite_Version)"
            Win32Icon="$(Satellite_Win32Icon)"
            Win32Resource="$(Satellite_Win32Resource)">

            <Output TaskParameter="OutputAssembly" ItemName="FileWrites"/>

        </AL>

Note that I chnaged the ToolPath to the location where AL exist on my machine.

请注意,我将 ToolPath 更改为我机器上存在 AL 的位置。

By default it uses $(AlToolPath), Not sure what is the value of this property but i am sure if you are getting this error it is not pointing to correct location

默认情况下,它使用 $(AlToolPath),不确定此属性的值是多少,但我确定如果您收到此错误,它没有指向正确的位置

So in simple words AL task can't find AL.exe and when you edit it and provide it ToolPath value you help him to locate it.

所以简单地说,AL 任务找不到 AL.exe,当您编辑它并提供 ToolPath 值时,您可以帮助他找到它。

Hope this explains you why you are getting this error message.

希望这能解释您为什么会收到此错误消息。

回答by AMissico

You are getting this error because you are building a 3.5 project that uses an assembly manifest, but do not have the 3.5 tools installed. (Hopefully, someone can provide more information.)

您收到此错误是因为您正在构建一个使用程序集清单的 3.5 项目,但没有安装 3.5 工具。(希望有人可以提供更多信息。)

I strongly recommend installing Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1and avoid the hacks, especially when you only need to install the tools, and be sure to check out the release notes for AL.exe information. (This SDK is the recommended installation for 3.5 due to a security update fix.)

我强烈建议为 Windows 7 和 .NET Framework 3.5 SP1安装Microsoft Windows SDK避免黑客攻击,尤其是当您只需要安装工具时,请务必查看 AL.exe 信息的发行说明。(由于安全更新修复,此 SDK 是 3.5 的推荐安装。)

The "Release Notes" for the SDK indicates that ALTOOLPATH is set by Visual Studio 2005, which might explain why some user have problems building. This is a guess on my part.

SDK 的“发行说明”表明 ALTOOLPATH 是由 Visual Studio 2005 设置的,这可能解释了为什么某些用户在构建时遇到问题。这是我的猜测。

Using SysInternals' Process Monitor, when building a 3.5 project, Visual Studio 2008 looks in the %SystemRoot%\Microsoft.NET\Framework\v3.5 folder for the Assembly Linker (AL.exe). Failing to find AL there, it will use the location specified in the specific v6.0A registry setting. (Note that v6.0A is not for .NET 3.5.) Therefore, installthe proper software and do not hack. :O)

使用 SysInternals 的 Process Monitor,在构建 3.5 项目时,Visual Studio 2008 在 %SystemRoot%\Microsoft.NET\Framework\v3.5 文件夹中查找程序集链接器 (AL.exe)。如果在那里找不到 AL,它将使用特定 v6.0A 注册表设置中指定的位置。(请注意,v6.0A 不适用于 .NET 3.5。)因此,请安装正确的软件,不要破解. :O)

The question I have is the Assembly Linker different between 2.0, 3.0, and 3.5?

我的问题是 2.0、3.0 和 3.5 之间的程序集链接器不同吗?



Windows SDK for Windows Server 2008 and .NET Framework 3.5

Installing the newly released Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 instead of this release is recommended. If you do go ahead and install this SDK after VS2008 SP1, please ensure the patch described in Knowledge Base 974479 is applied. See Overview section for more information.

适用于 Windows Server 2008 和 .NET Framework 3.5 的 Windows SDK

建议安装新发布的适用于 Windows 7 和 .NET Framework 3.5 SP1 的 Microsoft Windows SDK,而不是此版本。如果您在 VS2008 SP1 之后继续安装此 SDK,请确保应用了知识库 974479 中描述的补丁。有关更多信息,请参阅概述部分。

回答by Diego C.

No need to install VS2010 on the Build servers.

无需在 Build 服务器上安装 VS2010。

Export the "v7.0A" key from your dev box, import it into the build server's registry. Just make sure you rename any "Program Files (x86)" to just "Program Files" depending on what version of windows servers you are running.

从您的开发框中导出“v7.0A”密钥,将其导入构建服务器的注册表。只需确保将任何“程序文件(x86)”重命名为“程序文件”,具体取决于您运行的 Windows 服务器版本。

回答by Paige Cook

I did the same as dcadenas and just copied the SDKs\7.0A folder from a dev machine and exported the v7.0A registry settings from a dev box to the build server. This worked out great as I then did not need to install VS 2010 on the build server. Thanks.

我和 dcadenas 做了同样的事情,只是从开发机器复制了 SDKs\7.0A 文件夹,并将 v7.0A 注册表设置从开发框导出到构建服务器。这很有效,因为我不需要在构建服务器上安装 VS 2010。谢谢。

回答by BeardinaSuit

A report was done on Connect, when using TFS 2010 and project targeting the 3.5 framework. Its solution has worked for me.

当使用 TFS 2010 和面向 3.5 框架的项目时,在 Connect 上完成了一份报告。它的解决方案对我有用。

https://connect.microsoft.com/VisualStudio/feedback/details/594338/tfs-2010-build-agent-and-windows-7-1-sdk-targeting-net-3-5-generates-wrong-embedded-resources

https://connect.microsoft.com/VisualStudio/feedback/details/594338/tfs-2010-build-agent-and-windows-7-1-sdk-targeting-net-3-5-generates-wrong-embedded-资源

回答by lko

I had the same error, which came from adding resource files to a local folder and changing the build action to "Embedded Resources" (resources -> properties) while modifying localization resources to MVC3 from webforms see MVC2 Globalization. The exact error is caused by the Resources.lang.resx containing a "." in the name (combined with "emdedded resources").

我有同样的错误,它来自将资源文件添加到本地文件夹并将构建操作更改为“嵌入式资源”(资源 - > 属性),同时将本地化资源从 webforms 修改为 MVC3,请参阅 MVC2 Globalization。确切的错误是由包含“.”的 Resources.lang.resx 引起的。在名称中(与“嵌入式资源”结合使用)。

Previously the application compiled and ran fine while using global resources with a build action of "Content" (App_GlobalResources).

以前,该应用程序在使用具有“内容”(App_GlobalResources) 构建操作的全局资源时编译并运行良好。

The solution was similar to @vicky kole's above but I thought it's still worth mentioning due a few differences and the exact cause of the al.exe error in a previously working project.

该解决方案类似于上面的@vicky kole,但我认为由于一些差异以及之前工作项目中 al.exe 错误的确切原因,它仍然值得一提。

After some troubleshooting I installed the Windows 7 & ASP.NET 4 SDK, and located al.exe in the C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\x64 folder with a search.

经过一些故障排除后,我安装了Windows 7 和 ASP.NET 4 SDK,并通过搜索将 al.exe 定位在 C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\x64 文件夹中。

I then searched the C:\WINDOWS\Microsoft.NET\Framework\*NEWEST VERSION*\*.targets until I found the same AL node as @vicky koleabove. It was in a different file called Microsoft.Common.targets. I took the path from the newly installed SDK C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\x64 in my case and put it in the ToolPath as vicky did and restarted visual studio.

然后我搜索了 C:\WINDOWS\Microsoft.NET\Framework\*NEWEST VERSION*\*.targets,直到找到与上面的@vicky kole相同的 AL 节点。它位于另一个名为 Microsoft.Common.targets 的文件中。在我的情况下,我从新安装的 SDK C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\x64 中获取了路径,并将其像 vicky 一样放入 ToolPath 并重新启动了 Visual Studio。

<AL AlgorithmId="$(Satellite_AlgorithmId)"
ToolPath="C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\x64"

(this could be a comment to her post as it's really similar to her situation)

(这可能是对她帖子的评论,因为它与她的情况非常相似)

回答by Salami

I had a similar error getting a project building in Windows 10 where a resgen.exetool could not be found. I had to change a InstallationFolderregistry key in HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFX35Tools-x86to a path where it actually existed on my computer: C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools

我在resgen.exe无法找到工具的Windows 10 中构建项目时遇到了类似的错误。我必须将InstallationFolder注册表项更改为HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFX35Tools-x86它实际存在于我的计算机上的路径:C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools

回答by Mr.Buntha Khin

the problem fixed after I re-install the visual studio

重新安装visual studio后问题解决