GACed .net 库项目仅在第二次尝试就成功构建

发布于 2024-09-24 21:49:22 字数 1632 浏览 4 评论 0原文

我正在尝试构建需要在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

坦然微笑 2024-10-01 21:49:22

你有这个集会的参考资料吗?

Microsoft 警告在存在活动引用时不要使用此工具。

/uf <程序集名称>

Forces uninstall of an assembly by removing all traced references.
<assembly_name> is the full name of the assembly to remove.
Assembly will be removed unless referenced by Windows Installer.

!!警告:请小心使用 /uf 命令,因为应用程序可能无法运行!

最好在 Visual Studio 之外使用此工具,例如在编译开始之前和程序集构建之后运行它。

(在 VSD2010 的单独脚本中):

gacutil /uf <assemblyname>

构建程序集,无需调用 gacutil 的构建前或构建后操作

(在 VSD2010 的单独脚本中):

gacutil /if <assemblyname>

Do you hold a reference to this assembly?

Microsoft warns on using this tool when active referencing is present.

/uf <assembly_name>

Forces uninstall of an assembly by removing all traced references.
<assembly_name> is the full name of the assembly to remove.
Assembly will be removed unless referenced by Windows Installer.

!! 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):

gacutil /uf <assemblyname>

build your assembly WITHOUT pre or post build actions that invoke gacutil

(in a separate script to VSD2010):

gacutil /if <assemblyname>
人间☆小暴躁 2024-10-01 21:49:22

我找到了一个临时解决方法,可以确保注册有效 - 使用此脚本进行构建后事件:

:start 
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe" -if "$(TargetPath)"
IF ERRORLEVEL 1 GOTO start

I found a temporary work around that makes sure the registration worked - using this script for the post-build event:

:start 
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe" -if "$(TargetPath)"
IF ERRORLEVEL 1 GOTO start
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文