Jamie Cansdale's Radio Weblog


Subscribe to "Jamie Cansdale's Radio Weblog" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.


02 December 2002
 

Q:
[6.4] How can I automatically register my assembly when I build it from Visual Studio.NET? 5top
A:
It is possible to execute pre and post build steps for C# and VB.NET projects by utilizing a special project type from C++ called a utility project.  Prior to testing a server application you must install it into the GAC and register it using regsvcs running on an account with administrative privileges.  You can create scripts that will automate this process by doing the following:
  1. Add a new project to your solution
  2. Select the project type Visual C++ projects
  3. Select the template Makefile Project
  4. Enter the name Pre-Build
  5. Click OK - this will display the makefile project wizard
  6. Click finish on the makefile project wizard
  7. Right click on the Pre-Build project and select properties
  8. In the General page of the configuration properties, change the configuration type to Utility
  9. Click the apply button - new options will appear when you do this
  10. Select the build events folder and Pre-Build Event
  11. In the Command Line enter Pre-Build.bat along with any parameters you require for your build script.
  12. Repeat steps 1-11 for Post-Build events (substitute Post-Build wherever it says Pre-Build)
  13. Select Project / Project Dependencies... from the menu
  14. All projects should depend on Pre-Build, this will cause it to build first
  15. Post-Build should depend on all the other projects, this will cause it to build last.

Now you can create the two build scripts Pre-Build.bat and Post-Build.bat with the commands that you want to run when these events occur.

Pre-Build
In the pre-build event, you should return the machine to a known state so you will want to remove the assembly from the GAC and uninstall the Enterprise Services application if the assembly exists.  Be aware that regsvcs.exe returns an error if the assembly does not exist which Visual Studio will interpret as a build error.

Post-Build
In the post build event, you will want to take the steps necessary to deploy and register the server app in preparation for debugging.  For most Enterprise Services assemblies this includes adding it to the GAC and calling regsvcs.exe to register the assembly.


7:41:20 PM    

Enterprise Services FAQ
http://www.gotdotnet.com/team/xmlentsvcs/esfaq.aspx


7:14:54 PM    

This is cool! Rotor Source Code indexed by namespace, class, enumerator, delegate and interface. [Sam Gentile's Radio Weblog]
5:29:34 PM    


Click here to visit the Radio UserLand website. © Copyright 2003 Jamie Cansdale.
Last update: 02/01/2003; 22:34:26.
December 2002
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Nov   Jan