Wednesday, September 12, 2007

Conditional build events

In my current C# interop project, I unregister the existing COM dll using a pre-build event:

regasm /u $(TargetPath)

However, this fails if the file is not present (after a clean), so I use the following command to only unregister it if it is present.

path= $(TargetDir) for %f in ($(TargetFileName)) do C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe /u %f

No comments: