我正在尝试构建一个需要在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 ==========
这很糟糕而且非常奇怪。
我该如何解决这个问题?
答案 0 :(得分:1)
你持有这个集会的参考吗?
Microsoft警告在存在活动引用时使用此工具。
/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.
!!警告:请谨慎使用/uf
命令,因为应用程序可能无法运行!
最好在视觉工作室之外使用此工具,例如在编译开始之前运行它,并在构建程序集之后运行它。
(在VSD2010的单独脚本中):
gacutil /uf <assemblyname>
使用调用gacutil的前置或后置构建操作构建程序集
(在VSD2010的单独脚本中):
gacutil /if <assemblyname>
答案 1 :(得分:0)
我发现了一个临时工作,确保注册工作 - 使用此脚本进行构建后事件:
:start
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe" -if "$(TargetPath)"
IF ERRORLEVEL 1 GOTO start