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

GACed.net库项目仅在第二次尝试时成功构建,.net,visual-studio-2010,gac,gacutil,.net,Visual Studio 2010,Gac,Gacutil,我正在尝试构建一个需要在GAC中的项目库,因此我添加了以下行作为构建后事件: :start "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe" -if "$(TargetPath)" IF ERRORLEVEL 1 GOTO start “C:\Program Files(x86)\Microsoft SDK\Windows\v7.0A\Bin\gacutil.exe”-如果“$(TargetPath)”

我正在尝试构建一个需要在GAC中的项目库,因此我添加了以下行作为构建后事件:

:start 
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe" -if "$(TargetPath)"
IF ERRORLEVEL 1 GOTO start
“C:\Program Files(x86)\Microsoft SDK\Windows\v7.0A\Bin\gacutil.exe”-如果“$(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 ==========
这是好的-构建是成功的

但对于每一次奇怪的(第一次构建、第三次构建等)构建执行,我都会得到以下结果:

------ 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 ==========
这很糟糕也很奇怪


如何解决此问题?

我找到了一个临时解决方案,确保注册成功-使用此脚本进行后期生成事件:

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

我找到了一个临时解决方案,确保注册工作正常进行-将此脚本用于生成后事件:

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

您是否持有对该程序集的引用

当存在活动引用时,Microsoft警告使用此工具

/uf

生成程序集时不需要调用gacutil的生成前或生成后操作

(在VSD2010的单独脚本中):

gacutil/if

您是否持有此程序集的引用

当存在活动引用时,Microsoft警告使用此工具

/uf

生成程序集时不需要调用gacutil的生成前或生成后操作

(在VSD2010的单独脚本中):

gacutil/if

好吧,奇怪的错误,毫无疑问。禁用病毒扫描程序。是否有意使用gacutil的3.5版本?是的,我没有使用.Net 4.0。我已经禁用了AV,但问题仍然存在。我有一台服务器和另一台台式计算机,它们都与VS 2010有相同的问题。在同一解决方案中是否有其他项目引用此项目?如果是,它是项目引用还是程序集引用?@Mattias S,我有两个项目使用GAC程序集引用引用它。这些引用的“复制本地”设置为true还是false?如果你改变它会有什么不同吗?如果你把它改成项目参考,会有什么不同吗?好吧,奇怪的错误,毫无疑问。禁用病毒扫描程序。是否有意使用gacutil的3.5版本?是的,我没有使用.Net 4.0。我已经禁用了AV,但问题仍然存在。我有一台服务器和另一台台式计算机,它们都与VS 2010有相同的问题。在同一解决方案中是否有其他项目引用此项目?如果是,它是项目引用还是程序集引用?@Mattias S,我有两个项目使用GAC程序集引用引用它。这些引用的“复制本地”设置为true还是false?如果你改变它会有什么不同吗?如果您将其更改为项目引用,会有什么不同吗?