views:

43

answers:

1

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?

A: 

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
Eran Betzalel