Evan
Evan

Reputation: 2113

Register Multiple Assemblies to the GAC in Vista

I've got a whole directory of dll's I need to register to the GAC. I'd like to avoid registering each file explicitly- but it appears that gacutil has no "register directory" option. Anyone have a fast/simple solution?

Upvotes: 21

Views: 13329

Answers (4)

Piotr Bujak
Piotr Bujak

Reputation: 1

I was helped by Daniel answer but i would also add that we need to run Command Prompt as Administrator, and I also added a .dll to avoid trying to add other files

FOR %1 IN (*.dll) DO Gacutil /i %1

Upvotes: 0

Legends
Legends

Reputation: 22712

Use

gacutil /il YourPathTo_A_TextFile.txt

switch, if you have dlls in multiple different folders. Otherwise go with the for ... in loop mentioned by Euro.

The text file should contain a list of assembly paths (one path per line) which should be installed. The paths can also be different folders all over the system. Run the command line as an administrator!

Here an example of the YourPathTo_A_TextFile.txt:

C:\...Microsoft.Practices.EnterpriseLibrary.Common.dll C:\...Microsoft.Practices.EnterpriseLibrary.Configuration.Design.HostAdapter.dll C:\...Microsoft.Practices.EnterpriseLibrary.Configuration.Design.HostAdapterV5.dll C:\...Microsoft.Practices.EnterpriseLibrary.Configuration.DesignTime.dll C:\...Microsoft.Practices.EnterpriseLibrary.Configuration.EnvironmentalOverrides.dll C:\...Microsoft.Practices.EnterpriseLibrary.Data.dll

Upvotes: 2

Daniel Jennings
Daniel Jennings

Reputation: 6480

Here is the script you would put into a batch file to register all of the files in the current directory with Gacutil. You don't need to put it in a batch file (you can just copy/paste it to a Command Prompt) to do it.

FOR %1 IN (*) DO Gacutil /i %1

Edit: Bah, sorry I was late. I didn't see the previous post when I posted mine.

Upvotes: 11

Euro Micelli
Euro Micelli

Reputation: 34056

GACUTIL doesn't register DLLs -- not in the "COM" sense. Unlike in COM, GACUTIL copies the file to an opaque directory under %SYSTEMROOT%\assembly and that's where they run from. It wouldn't make sense to ask GACUTIL "register a folder" (not that you can do that with RegSvr32 either).

You can use a batch FOR command such as:

FOR %a IN (C:\MyFolderWithAssemblies\*.dll) DO GACUTIL /i %a

If you place that in a batch file, you must replace %a with %%a

Upvotes: 38

Related Questions