To deploy a C# class library to the GAC automatcially in the Visual Studio, perform the following steps:
1. Open the project Properties and go to Build events.
2. Set the Pre-build event command line to:
@echo ** Removing old GAC assemblies
"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\gacutil.exe" /u $(TargetName)
3. Set the Post-build event command line to:
@echo ** Install new GAC assemblies
"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\gacutil.exe" /i $(TargetPath)
When you compile a new version, before building the project, the existing class library will be removed from GAC. Then, once the build is successful, the new class library will be deloyed.