What gacutil.exe should I use?
Asked Answered
T

3

11

So, on a Win 2008 R2 Std x64, I have 6 (six) gacutil.exe all different (not counting ones in VS folders), in:

  1. c:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin
  2. c:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64
  3. c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin
  4. c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64
  5. c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools
  6. c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\x64

Questions are:

  1. Does x64 versions have any difference in behavior?
  2. Should I prefer v7.0A versions to other v6.0A?
  3. Should I use NETFX 4.0 Tools versions for .NET 4.0 assemblies, and the "standard" version for the rest?

Or, if there is some general type article on the subject, I will be grateful.

Update 1. Concerning Hans Passant's answer:

  1. gacutil.exe is a .NET Framework Tool part of a "Build, Deployment, and Configuration Tools (.NET Framework)" as now obsolete (!) shfusion.dll was;
  2. Indeed v6.0A are from VS2008 install, and can be ignored (1, 2);
  3. The 64-bit explanation theory also sounds reasonable. I also suppose that there is most probably an IA64 version of gacutil.exe, so it's like a "tool copy for each platform", it's just happened so that the x86 version runs fine everywhere because of WoW64. Minus 2 gacutil version from the list (4, 6);
  4. The part about which version to use, seems to be wrong. V4.0 gacutil.exe detects and places assembly according to its target CLR, and works fine for both .NET 4.0 and earlier version assemblies. So the question is, why leave V2.0 gacutil.exe? My guess would be for the purpose of deployment on environments there.NET4.0 is unavailable.
  5. To use or not to use GAC, wasn't in the question. So I leave the last paragraph with no comments.

Update 2.

So, to me seems like one can safely use either number 3 (then .NET4.0 is unavailable) or number 5 otherwise for all GAC operations on Windows x86 and x64. And the answers to the questions are:

  1. No.
  2. Doesn't matter, but using newer versions seems more logical.
  3. No, you can always use NETFX 4.0 Tools version (if .NET4.0 is available) for all GAC operations.
Timbered answered 27/3, 2012 at 11:53 Comment(3)
Really want to answer ... "None of them ... nuget or bin deploy FTW"!!Hyacinthie
@DanielElliott good one ;-) But still, this time I really want to clear this question up.Timbered
Interested in an answer myself too ... good luck!Hyacinthie
T
3

Short version: If you have .NET 4.0 installed, use NETFX 4.0 Tools version. Otherwise it doesn't really matter.

Answers to questions:

  1. No.
  2. Doesn't really matter unless there is no .NET 4.0 installed, in which case you should use NETFX 4.0 Tools version. Not sure if it is possible to have a v7.0 SDK and not have .NET 4.0 installed.
  3. No, you can always (and should) use NETFX 4.0 Tools version for all GAC operations.
Timbered answered 18/4, 2012 at 4:16 Comment(0)
A
5

Gacutil.exe is a Windows SDK tool, not a .NET framework tool. You got two versions of the SDK on your machine. You got 6.0A from the VS2008 install, 7.0A from the VS2010 install. You also have a 64-bit operating system so you got the 64-bit tools as well. Which doesn't matter for gacutil.exe, not sure why they include it separately. Probably to keep the Visual Studio Command Prompt working, note that you have separate 32-bit and 64-bit versions of it. Which matters a lot for C++ projects. VS2010 allows targeting both CLR version 4 and CLR version 2 so that's 6 versions total.

What does matter a great deal is that you have two GACs on your machine. The GAC for .NET 4 assemblies is stored in c:\windows\microsoft.net\assembly. For earlier versions it is stored in c:\windows\assembly. You must use the proper version of gacutil.exe to get an assembly into the proper GAC. For an assembly that targets .NET 4, you must use the one in Bin\NETFX 4.0 Tools. And for earlier ones, you must use the one in Bin.

Using it not at all is best, assemblies should have the Copy Local property set on a dev machine. The GAC is a deployment detail, you'll get in trouble when your GAC has an assembly that your user's GAC doesn't have.

Aftonag answered 27/3, 2012 at 12:47 Comment(1)
Also, users without administrative rights won't be able to install an application that requires assemblies to be in the GAC (like Oracle ODP.NET). In the case of ODP.NET, copy local doesn't work.Harber
T
3

Short version: If you have .NET 4.0 installed, use NETFX 4.0 Tools version. Otherwise it doesn't really matter.

Answers to questions:

  1. No.
  2. Doesn't really matter unless there is no .NET 4.0 installed, in which case you should use NETFX 4.0 Tools version. Not sure if it is possible to have a v7.0 SDK and not have .NET 4.0 installed.
  3. No, you can always (and should) use NETFX 4.0 Tools version for all GAC operations.
Timbered answered 18/4, 2012 at 4:16 Comment(0)
J
0

This is not the best answer, but I'm noticing an observation. Use the latest version folder, based on whatever you're using for your application being developed for the associated Visual Studio install.

C:\Program Files (x86)\Microsoft SDKs\Windows\{SDK version}\bin\NETFX 4.5.1 Tools\gacutil.exe

When comparing the Control Panel > Programs and Features > "Installed On" date for my Visual Studio installs, I'm seeing many different folders under here. I'm guessing multiple folders got updated during these two installations.

Folders where "gacutil.exe" resides and modified date:

C:\Program Files (x86)\Microsoft SDKs\Windows\
C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\ - 3/20/2014
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\ - 3/20/2014
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\ - 5/15/2015
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0\ - 3/20/2014
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\ - 5/15/2015
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1\ - 5/15/2015
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\ - 5/15/2015

Windows Visual Studio Installations with "Installed On" date:

Visual Studio 2012 - 3/20/2014
Visual Studio 2013 - 5/15/2015

To get a comparison of what is in the GAC, I ran this command and diff'ed the files to compare.

cd C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\
gacutil /l > c:\v8.1A.gac.txt

Then I changed the folder appropriately for each version.

Jaynajayne answered 23/7, 2015 at 17:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.