Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's how I ended up automating the process of registering and GAC-ing my dll.</p> <p>First, I created a directory in the root folder of the solution called "ScriptedDevDellRegistration". I copied the most recent versions of <code>gacutil.exe</code> and <code>RegAsm.exe</code> (with their corresponding .config files) into this directory.</p> <p>Next, I added a file into that directory called <code>RegDll.cmd</code>. This file will register the dll with its tlb and then install it in the GAC. This is useful when needing to consume an assembly in the VB6 development environment via COM interop. The file's contents are:</p> <pre><code>cd "%~dp0" regasm MyDll.dll /tlb:MyDll.tlb /u regasm MyDll.dll /tlb:MyDll.tlb gacutil /u MyDll gacutil /i MyDll.dll </code></pre> <p>I also added a file called <code>UnGacDll.cmd</code> that will uninstall the assembly from the GAC. When running a console test application that uses an assembly in a different project, and that assembly has been added to the GAC, I've had trouble getting debug to work. This file simply removes the dll from the GAC so that I can debug more easily:</p> <pre><code>cd "%~dp0" gacutil /u MyDll </code></pre> <p>Now that I've got my files set up, I need to edit the Build Events of my project.</p> <p>In the project's properties (I'm using VS2010 with VB.NET) for the assembly being compiled and registered/GAC'd, click the compile tab and click the "Build Events" button. In the post-build events, add code that is similar to the following:</p> <pre><code>IF not "$(ConfigurationName)" == "Release Scripted Dev Dll Registration" GoTo elseIf1 :default COPY "$(TargetPath)" "$(SolutionDir)ScriptedDevDllRegistration\$(TargetFileName)" "$(SolutionDir)ScriptedDevDllRegistration\RegDll.cmd" GOTO exit :elseIf1 IF not "$(ConfigurationName)" == "Debug ConsoleTest" GoTo elseIf2 "$(SolutionDir)ScriptedDevDllRegistration\UnGacDll.cmd" GOTO exit :elseIf2 IF not "$(ConfigurationName)" == "Debug Console Web Library" GoTo exit "$(SolutionDir)ScriptedDevDllRegistration\UnGacDll.cmd" GOTO exit :exit </code></pre> <p>The cmd scripting is kinda ugly, but very useful. I use different build configurations to drive which scripts get executed in the post-build events. For example, the first line looks for a build configuration named "Release Scripted Dev Dll Registration", which copies the DLL to the subdirectory I made and then executes <code>RegDll.cmd</code> to register the assembly and its type libraries as well as GAC the assembly. </p> <p>The other configurations, "Debug ConsoleTest" and "Debug Console Web Library," work best when the dll is not in the GAC, so the post-build event calls <code>UnGacDll.cmd</code> for those configurations.</p> <p>I'm sure it's possible to script some of this functionality without physically copying dll's or the regasm.exe or gacutil.exe utilities, but the solution I explained above worked well for me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload