GACed .net 库项目仅在第二次尝试就成功构建
我正在尝试构建需要在 GAC 中的项目库,因此我添加了以下行作为构建后事件:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A \Bin\gacutil.exe" -if "$(TargetPath)"
对于每个偶数(第二个构建、第四个构建等)构建执行,我得到以下信息:
------ Build started: Project: Test.BusinessLogic, Configuration: Debug Any CPU ------
Test.BusinessLogic -> C:\Users\Eran\Documents\Test\Trunk\Test.BusinessLogic\bin\Debug\Test.BusinessLogic.dll
Microsoft (R) .NET Global Assembly Cache Utility. Version 3.5.30729.1
Copyright (c) Microsoft Corporation. All rights reserved.
Assembly successfully added to the cache
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
哪个很好 - 构建成功。
但对于每一个奇怪的(第一次构建、第三次构建等)构建执行,我都会得到这样的信息:
------ Build started: Project: Test.BusinessLogic, Configuration: Debug Any CPU ------
Test.BusinessLogic -> C:\Users\Eran\Documents\Test\Trunk\Test.BusinessLogic\bin\Debug\Test.BusinessLogic.dll
Microsoft (R) .NET Global Assembly Cache Utility. Version 3.5.30729.1
Copyright (c) Microsoft Corporation. All rights reserved.
Failure adding assembly to the cache: Cannot create a file when that file already exists.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3717,9): error MSB3073: The command ""C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe" -if "C:\Users\Eran\Documents\Test\Trunk\Test.BusinessLogic\bin\Debug\Test.BusinessLogic.dll"" exited with code 1.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
这很糟糕而且非常奇怪。
我该如何解决这个问题?
I'm trying to build a project library that needs to be in the GAC, so I added the following line as a post build event:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe" -if "$(TargetPath)"
For every even (second build, forth build, etc...) build execution I get this:
------ Build started: Project: Test.BusinessLogic, Configuration: Debug Any CPU ------
Test.BusinessLogic -> C:\Users\Eran\Documents\Test\Trunk\Test.BusinessLogic\bin\Debug\Test.BusinessLogic.dll
Microsoft (R) .NET Global Assembly Cache Utility. Version 3.5.30729.1
Copyright (c) Microsoft Corporation. All rights reserved.
Assembly successfully added to the cache
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
Which is good - build was successful.
But for every odd (first build, third build, etc...) build execution I get this:
------ Build started: Project: Test.BusinessLogic, Configuration: Debug Any CPU ------
Test.BusinessLogic -> C:\Users\Eran\Documents\Test\Trunk\Test.BusinessLogic\bin\Debug\Test.BusinessLogic.dll
Microsoft (R) .NET Global Assembly Cache Utility. Version 3.5.30729.1
Copyright (c) Microsoft Corporation. All rights reserved.
Failure adding assembly to the cache: Cannot create a file when that file already exists.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3717,9): error MSB3073: The command ""C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe" -if "C:\Users\Eran\Documents\Test\Trunk\Test.BusinessLogic\bin\Debug\Test.BusinessLogic.dll"" exited with code 1.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
Which is bad and very weird.
How can I solve this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你有这个集会的参考资料吗?
Microsoft 警告在存在活动引用时不要使用此工具。
/uf <程序集名称>
!!警告:请小心使用
/uf
命令,因为应用程序可能无法运行!最好在 Visual Studio 之外使用此工具,例如在编译开始之前和程序集构建之后运行它。
(在 VSD2010 的单独脚本中):
构建程序集,无需调用 gacutil 的构建前或构建后操作
(在 VSD2010 的单独脚本中):
Do you hold a reference to this assembly?
Microsoft warns on using this tool when active referencing is present.
/uf <assembly_name>
!! Warning: use the
/uf
command with care as applications may fail to run !!It better of to work with this tool outside of the visual studio, e.g. run it before compilation starts, and after your assembly gets built.
(in a separate script to VSD2010):
build your assembly WITHOUT pre or post build actions that invoke gacutil
(in a separate script to VSD2010):
我找到了一个临时解决方法,可以确保注册有效 - 使用此脚本进行构建后事件:
I found a temporary work around that makes sure the registration worked - using this script for the post-build event: