IMPORTANT: This article contains information about modifying the registry.
Before you modify the registry, make sure to back it up and make sure that you
understand how to restore the registry if a problem occurs. For information
about how to back up, restore, and edit the registry, click the following
article number to view the article in the Microsoft Knowledge Base:
256986
(http://support.microsoft.com/kb/256986/EN-US/
)
Description of the Microsoft Windows Registry
This step-by-step article describes how to implement build
events in Visual C# .NET or Visual C# 2005.
When you use build events, you can specify
an action that occurs at a specific time during the build process. For example,
you can specify a post-build event to register a file by using regsvr32.exe.
You can also view and make a change to a generated assembly in the GAC (Global
Assembly Cache) by using the Gacutil.exe tool.
In Visual C# .NET or Visual C# 2005,
there are no direct methods to specify pre-build and post-build
events.
Use a Visual C++ Makefile Project to Implement Build Events
Build events are a built-in feature of
Microsoft Visual C++ .NET projects. You can implement these events in a Visual
C# .NET or Visual C# 2005 project by including a Visual C++ .NET Makefile project in the
solution. To implement pre-build events, you must make the Visual C++ .NET Makefile project
dependant on the Visual C# .NET or Visual C# 2005 project. To implement post-build events, you must make the Visual C# .NET or Visual C# 2005 project dependant on the
Visual C++ .NET Makefile project.
To do this, follow these steps:
Open your existing Visual C# .NET or Visual C# 2005 solution.
On the File menu, point to Add
Project, and then click New Project.
Under Project Types, click Visual
C++ Projects, and under Templates, click
MakeFile Project. Note In Visual Studio 2005, "Visual
C++ Projects" should be changed to "Visual
C++."
Type the name for the solution, specify a location for the
solution, and then click OK.
In the Makefile Application Wizard, click Finish.
On the Project menu of the Makefile Project, click Properties.
In the Configuration Type box, select Utility, and then click OK.
On the Project menu, click Project Dependencies…. To perform the pre-build events, follow these steps:
On the Dependencies tab, select the
appropriate Visual C# .NET project from the
Projects list, and then under Depends on,
click the Visual C++ Makefile project .
Click OK to apply the change. This
makes sure that the Visual C# .NET or Visual C# 2005 project is built last.
Right-click the Visual C++ Makefile project in Solution Explorer, and then click Properties.
Click Build Events, and then specify the pre-build event command. For example,
to copy the file before building, specify the following:
copy c:\AddinReg.reg $(OutDir)
To perform the post-build setup, follow these steps:
Click the Visual C++ Makefile project
in the Projects list, and then select the appropriate Visual
C# .NET or Visual C# 2005 project under Depends on.
Click OK to apply the change. This makes sure that the Visual C++ project
is built last.
Right-click the Visual C++ Makefile project in Solution
Explorer, click Properties, and then click Build
Events to specify the post-build event command.
Use the PrePostBuildRules Add-In to Implement Build Events
This add-in provides pre-build and post-build rules at the
solution and project levels. To download the add-in, see the the following
Microsoft Web site:
WARNING: If you use Registry Editor incorrectly, you may cause serious
problems that may require you to reinstall your operating system. Microsoft
cannot guarantee that you can solve problems that result from using Registry
Editor incorrectly. Use Registry Editor at your own risk.
To use this add-in, follow these steps :
Load the solution file with this source, and then
build the solution.
On Tools menu, click Add-In Manager. If the Add-In Manager is already open, close it, and then open
it again.
Note If the new add-in appears in the Add-In
Manager list of add-ins, you have successfully registered the add-in.
If the add-in does not appear in the Add-In
Manager list, follow the steps to register it manually:
Locate the AddinReg.reg file in the BuildRules folder.
Right-click AddinReg.reg, and then
click Merge. Click Yes when prompted to add the entries to the registry.
The new entries made to the registry can be seen in
the following location: