1

GAC に必要なプロジェクト ライブラリをビルドしようとしているので、ビルド後のイベントとして次の行を追加しました。

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

偶数(2番目のビルド、4番目のビルドなど)のビルド実行ごとに、次のようになります。

------ 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 ==========

これは良いことです - ビルドは成功しました。

しかし、奇数(最初のビルド、3番目のビルドなど)のビルド実行ごとに、次のようになります。

------ 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 ==========

これは悪く、非常に奇妙です。

この問題を解決するにはどうすればよいですか?

4

2 に答える 2

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アプリケーションの実行に失敗する可能性があるため、コマンドは注意して使用してください !!

Visual Studio の外でこのツールを使用することをお勧めします。たとえば、コンパイルの開始前やアセンブリのビルド後に実行します。

(VSD2010 への別のスクリプトで):

gacutil /uf <assemblyname>

gacutil を呼び出すビルド前またはビルド後のアクションなしでアセンブリをビルドします

(VSD2010 への別のスクリプトで):

gacutil /if <assemblyname>
于 2011-03-08T07:36:14.487 に答える
0

ビルド後のイベントに次のスクリプトを使用して、登録が機能することを確認する一時的な回避策を見つけました。

:start 
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe" -if "$(TargetPath)"
IF ERRORLEVEL 1 GOTO start
于 2010-10-04T09:06:03.763 に答える