x64 计算机上的 MSBuild.Community.Tasks.Attrib 失败
在 64 位构建计算机上运行时,我遇到 MSBuild 社区任务项目 中的 Attrib 任务问题。
我将这个小测试项目放在一起以显示问题所在:
<Project ToolsVersion="3.5" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath32)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<Target Name="PrintProperties">
<Message Text="MSBuildCommunityTasksPath: $(MSBuildCommunityTasksPath)"/>
<Message Text="MSBuildCommunityTasksLib: $(MSBuildCommunityTasksLib)"/>
<Message Text="MSBuildNodeCount: $(MSBuildNodeCount)"/>
<Message Text="MSBuildExtensionsPath: $(MSBuildExtensionsPath)"/>
<Message Text="MSBuildExtensionsPath32: $(MSBuildExtensionsPath32)"/>
<Message Text="MSBuildProjectDirectoryNoRoot: $(MSBuildProjectDirectoryNoRoot)"/>
<Message Text="MSBuildToolsPath: $(MSBuildToolsPath)"/>
<Message Text="MSBuildToolsVersion: $(MSBuildToolsVersion)"/>
<Message Text="MSBuildBinPath: $(MSBuildBinPath)"/>
<Message Text="MSBuildExtensionsPath: $(MSBuildExtensionsPath)"/>
<Message Text="MSBuildProjectDefaultTargets: $(MSBuildProjectDefaultTargets)"/>
<Message Text="MSBuildProjectDirectory: $(MSBuildProjectDirectory)"/>
<Message Text="MSBuildProjectExtension: $(MSBuildProjectExtension)"/>
<Message Text="MSBuildProjectFile: $(MSBuildProjectFile)"/>
<Message Text="MSBuildProjectFullPath: $(MSBuildProjectFullPath)"/>
<Message Text="MSBuildProjectName: $(MSBuildProjectName)"/>
<Message Text="MSBuildStartupDirectory: $(MSBuildStartupDirectory)"/>
</Target>
<Target Name="TestAttrib" DependsOnTargets="PrintProperties">
<Attrib Files="Test.txt" ReadOnly="false" />
</Target>
</Project>
当我尝试使用 TestAttrib 作为目标使用 MSBuild 构建此项目时,我得到以下结果
C:>msbuild "C:_Source Code\Test.vbproj" /t:测试属性 Microsoft(R)构建引擎版本3.5.30729.1 [微软.NET框架,版本2.0.50727.4016] 版权所有 (C) Microsoft Corporation 2007。保留所有权利。
构建于 7/09/2009 2:50:12 PM 开始。
节点 0 上的项目“C:_Source Code\Test.vbproj”(TestAttrib 目标)。
MSBuildCommunityTasksLib:C:\ Program Files \ MSBuild \ MSBuildCommunityTasks \ MSBu ild.Community.Tasks.dll
MSBuildNodeCount:1
MSBuildExtensions路径:C:\Program Files\MSBuild
MSBuildExtensionsPath32:C:\Program Files (x86)\MSBuild
MSBuildProjectDirectoryNoRoot:_源代码
MSBuildTools路径:c:\Windows\Microsoft.NET\Framework64\v3.5
MSBuildTools版本:3.5
MSBuildBinPath: c:\Windows\Microsoft.NET\Framework64\v3.5
MSBuildExtensions路径:C:\Program Files\MSBuild
MSBuildProjectDefaultTargets:构建
MSBuildProject目录:C:_源代码
MSBuildProject扩展名:.vbproj
MSBuildProjectFile:Test.vbproj
MSBuildProjectFullPath: C:_Source Code\Test.vbproj
MSBuild项目名称:测试
MSBuildStartup目录:C:\
C:_Source Code\Test.vbproj(26,5):错误 MSB4062:无法从程序集 C:\Program Files\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks 加载“MSBuild.Community.Tasks.Attrib”任务.dll。无法加载文件或程序集“file:///C:\Program Files\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.dll”或其依赖项之一。系统找不到指定的文件。确认声明正确,并且程序集及其所有依赖项均可用。 完成构建项目“C:_Source Code\Test.vbproj”(TestAttrib 目标)——失败。
构建失败。
“C:_Source Code\Test.vbproj”(TestAttrib 目标)(1) ->(TestAttrib 目标)-> C:_Source Code\Test.vbproj(26,5):错误 MSB4062:无法从程序集 C:\Program Files\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks 加载“MSBuild.Community.Tasks.Attrib”任务.dll。无法加载文件或程序集“file:///C:\Program Files\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.dll”或其依赖项之一。系统找不到指定的文件。确认声明正确,并且程序集及其所有依赖项均可用。
0 Warning(s)
1 Error(s)
已用时间 00:00:00.05
当我使用 (MSBuildExtensionsPath32) 变量显式导入任务时,为什么 MSBuild 会在 C:\Program Files\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.dll 中搜索 Attrib 任务?
I'm having an issue with the Attrib task from the MSBuild Community Tasks Project when running on a 64 bit build machine.
I've put together this small test project to show what the problem is:
<Project ToolsVersion="3.5" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath32)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<Target Name="PrintProperties">
<Message Text="MSBuildCommunityTasksPath: $(MSBuildCommunityTasksPath)"/>
<Message Text="MSBuildCommunityTasksLib: $(MSBuildCommunityTasksLib)"/>
<Message Text="MSBuildNodeCount: $(MSBuildNodeCount)"/>
<Message Text="MSBuildExtensionsPath: $(MSBuildExtensionsPath)"/>
<Message Text="MSBuildExtensionsPath32: $(MSBuildExtensionsPath32)"/>
<Message Text="MSBuildProjectDirectoryNoRoot: $(MSBuildProjectDirectoryNoRoot)"/>
<Message Text="MSBuildToolsPath: $(MSBuildToolsPath)"/>
<Message Text="MSBuildToolsVersion: $(MSBuildToolsVersion)"/>
<Message Text="MSBuildBinPath: $(MSBuildBinPath)"/>
<Message Text="MSBuildExtensionsPath: $(MSBuildExtensionsPath)"/>
<Message Text="MSBuildProjectDefaultTargets: $(MSBuildProjectDefaultTargets)"/>
<Message Text="MSBuildProjectDirectory: $(MSBuildProjectDirectory)"/>
<Message Text="MSBuildProjectExtension: $(MSBuildProjectExtension)"/>
<Message Text="MSBuildProjectFile: $(MSBuildProjectFile)"/>
<Message Text="MSBuildProjectFullPath: $(MSBuildProjectFullPath)"/>
<Message Text="MSBuildProjectName: $(MSBuildProjectName)"/>
<Message Text="MSBuildStartupDirectory: $(MSBuildStartupDirectory)"/>
</Target>
<Target Name="TestAttrib" DependsOnTargets="PrintProperties">
<Attrib Files="Test.txt" ReadOnly="false" />
</Target>
</Project>
when I attempt to build this project with MSBuild using TestAttrib as the Target I get the following results
C:>msbuild "C:_Source Code\Test.vbproj" /t:TestAttrib
Microsoft (R) Build Engine Version 3.5.30729.1
[Microsoft .NET Framework, Version 2.0.50727.4016]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
Build started 7/09/2009 2:50:12 PM.
Project "C:_Source Code\Test.vbproj" on node 0 (TestAttrib target(s)).
MSBuildCommunityTasksLib: C:\Program Files\MSBuild\MSBuildCommunityTasks\MSBu
ild.Community.Tasks.dll
MSBuildNodeCount: 1
MSBuildExtensionsPath: C:\Program Files\MSBuild
MSBuildExtensionsPath32: C:\Program Files (x86)\MSBuild
MSBuildProjectDirectoryNoRoot: _Source Code
MSBuildToolsPath: c:\Windows\Microsoft.NET\Framework64\v3.5
MSBuildToolsVersion: 3.5
MSBuildBinPath: c:\Windows\Microsoft.NET\Framework64\v3.5
MSBuildExtensionsPath: C:\Program Files\MSBuild
MSBuildProjectDefaultTargets: Build
MSBuildProjectDirectory: C:_Source Code
MSBuildProjectExtension: .vbproj
MSBuildProjectFile: Test.vbproj
MSBuildProjectFullPath: C:_Source Code\Test.vbproj
MSBuildProjectName: Test
MSBuildStartupDirectory: C:\
C:_Source Code\Test.vbproj(26,5): error MSB4062: The "MSBuild.Community.Tasks.Attrib" task could not be loaded from the assembly C:\Program Files\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.dll. Could not load file or assembly 'file:///C:\Program Files\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, and that the assembly and all its dependencies are available.
Done Building Project "C:_Source Code\Test.vbproj" (TestAttrib target(s)) -- FAILED.
Build FAILED.
"C:_Source Code\Test.vbproj" (TestAttrib target) (1) ->(TestAttrib target) -> C:_Source Code\Test.vbproj(26,5): error MSB4062: The "MSBuild.Community.Tasks.Attrib" task could not be loaded from the assembly C:\Program Files\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.dll. Could not load file or assembly 'file:///C:\Program Files\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, and that the assembly and all its dependencies are available.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.05
Why is the MSBuild searching for the Attrib task in C:\Program Files\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.dll when I've explicitly imported the tasks using the (MSBuildExtensionsPath32) variable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我似乎通过编辑“C:\Program Files (x86)\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets”的第 6 行解决了该问题
最初是:
我将其更改为:
注意 $(MSBuildExtensionsPath) 更改为 $(MSBuildExtensionsPath32)
虽然这似乎暂时解决了我的问题,但我不确定为什么我必须编辑 MSBuild.Community。首先,Tasks.Targets 文件 - 我假设安装程序会确保该文件是正确的。因此,也许编辑 MSBuild.Community.Tasks.Targets 文件并不是世界上最好的主意,所以如果您决定遵循我的指导,请务必小心。
I seem to have fixed the issue by editing line 6 of "C:\Program Files (x86)\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"
Originally it was:
and I altered it to:
note the change of $(MSBuildExtensionsPath) to $(MSBuildExtensionsPath32)
While this seems to have sorted out my issue for now, I'm not sure why I had to edit the MSBuild.Community.Tasks.Targets file in the first place - I assumed the installer would have made sure the file was correct. So perhaps editing the MSBuild.Community.Tasks.Targets file isn't the best idea in the world, so be careful if you decide to follow my lead.
这显然是一个太晚的答案,但我想我会补充这一点,以防其他人遇到这个问题。您无需编辑 MSBuild.Community.Tasks.Targets 文件,只需在生成文件的属性组中定义 MSBuildCommunityTasksPath 属性即可。例如,我的构建脚本顶部有类似的内容:
然后,我将 MSBuildCommunityTasks 文件夹存储在源代码管理中的工具目录中。这意味着其他人可以提取源代码并立即构建它,而无需安装任何东西。
干杯,
亚当
This is obviously far too late an answer, but I thought I would add to this in case anyone else is having this problem. Instead of editing the MSBuild.Community.Tasks.Targets file, you can just define the MSBuildCommunityTasksPath property in a property group in your build file. For example, I have something like this at the top of my build script:
I then store the MSBuildCommunityTasks folder in a tools directory in source control. It means that other folk can pull out the source and build it straight away without installing anything.
Cheers,
Adam
这是非常过时的帮助。自此票证以来,MS 构建过程已发生变化,最好按照此处的说明进行操作 https://github.com/loresoft/ msbuildtasks
对于我的项目,我在解决方案中使用了 Build 文件夹,并在解决方案中创建了一个 MSBuildTasks 文件夹,在其中复制 Zip 文件版本中的最新 MBBuild.Community.Task 文件。并将以下行放入我的 msbuild 文件中
This is very out of date help. The ms build process has changed since this ticket, best to follow the instructions here https://github.com/loresoft/msbuildtasks
For my project, I used a Build folder in my solution and in the solution I create a MSBuildTasks Folder where I copy the latests MBBuild.Community.Task files in the Zip file release. and put the following lines in my msbuild file