Discussion:
regasm /unregister during clean
(too old to reply)
Edwin G. Castro
2005-01-20 23:49:01 UTC
Permalink
I have a C# project in a solution with many unmanaged C++ projects. The
C# project does a "regasm" as a postbuild event. I'd like to
automatically call "regasm /unregister" for the C# project when I clean
the solution. Is this possible?
Gary Chang[MSFT]
2005-01-21 07:59:09 UTC
Permalink
Hi Edwin,
I'd like to automatically call "regasm /unregister" for the
C# project when I clean the solution. Is this possible?
Since there is no After_CleanSoluiton event to trap in the VS.NET, I think
you can customize a macro command to automate this task:
First you need to add an external tools(Tools/External Tools...) to perform
the "regasm /unregister ...", please make sure you could use this external
tools command to unregister your target assembly and take note of what is
the No.# command in the external tools's list(e.g. it would be the No.9
command which used in the following sample code).

Then you could use the following IDE Macro to implement the customzied
command:
Sub CleanSolutionAndUnregasm()
DTE.ExecuteCommand("Build.CleanSolution")
DTE.ExecuteCommand("Tools.ExternalCommand9")
End Sub

By the way, you can also wrap the above macro inside an customized VS.NET
Addin command:
Adding and Handling Commands
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/ht
ml/vxconcontrollingcommands.asp

with the sample in that article, please insert the above two macro
ExecuteCommand codes just before the code "handled = True"(inside the Exec
Sub)


Thanks!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
Edwin G. Castro
2005-01-21 21:25:17 UTC
Permalink
Thanks for the info! Unfortunately the land of IDE Macros is alien to
me! I understand the VB (for the most part) but I don't know how to use
macros. Could you please point me in the correct direction to learn
about macros?

Also I should have mentioned that any truely helpful solution needs to
be usable from the command line. And it would optimally work at the
project level. For management purposes it makes more sense for the
project to handle registration and unregistration.

Thanks again!
Edwin G. Castro
2005-01-21 22:05:16 UTC
Permalink
So I looked at the Project properties and found "Register for COM
Interop". This was set to false which explains why we are registering
the component ourselves in the Post-Build Event. I ran a simple
experiment and when I tell the projec to rebuild vsnet unregisters the
component prior to building. This is useful but not quite what I need.

I have an automated build process. Currently the process cleans all the
solutions, gets the latest code from source control, builds all the
solutions, builds tests, and finally executes the tests. As part of the
clean process the COM components unregister themselves but the .NET
component does not.

I don't want to use the rebuild command because that build the code
again. It is very useful to tell the project to clean itself
(unregister yourself and delete the output files). That allows me to
start from a somewhat standard environment every build.
Any ideas/comments?
Gary Chang[MSFT]
2005-01-22 10:24:18 UTC
Permalink
Hi Edwin,
Post by Edwin G. Castro
Could you please point me in the correct direction to learn
about macros?
please refer to the following MSDN doc:
Visual Studio Macros
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsa/html/vm
orivisualstudiomacros.asp
Post by Edwin G. Castro
Also I should have mentioned that any truely helpful solution
needs to be usable from the command line. And it would
optimally work at theproject level.
for cleanning at project level. you can use the command
"Build.CleanOnlyProject" or "Build.CleanSelection" instead of the
"Build.CleanSolution" in my previus sample.

Meantime, you can run my Macro from the the cmmand line when the VS.NET is
running, if you save my sample macro in the MyMacros.Module1:
devenv /command "Macros.MyMacros.Module1.CleanSolutionAndUnregasm"

please also refer to the following MSDN article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/ht
ml/vxlrfcommand.asp


Hope this helps!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
Loading...