I would like to reliably auto-install my application assemblies in the GAC when I compile my application using Visual Studio. I've setup pre- and post-build events in my web application's build.
Pre build event:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\gacutil.exe" /f /ul Uninstall.Gac.txt
Post build event:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\gacutil.exe" /f /il Install.Gac.txt
%windir%\system32\inetsrv\appcmd.exe recycle apppool -apppool.name:"Sharepoint IIS WebApps"
As you can see I'm also recycling my web application pool for the new assemblies to start working.
The problem I'm having is that this is a very unreliable process. In case my Web application fails, my next build will fail because uninstall will fail (post-build didn't run on previous build)... Etc.
I would like to make this process ass reliable as possible. I would like to conditionally uninstall and assemblies if they are present and forcibly install no matter whether they're there or not... But pre-build event is still important for the next reason:
It's important that all my assemblies are completely uninstalled before build takes place, otherwise they're not copied to my output directory (since compiler finds them in GAC) hence GAC install fails since it can't find assemblies in the output \bin folder.
How should I reliably do GAC uninstallation and installation on my web application build?
Instead onrelying on the GACUTIL tool, couldn't you program GAC install/uninstall? With code, you could at least rely on hresults error codes and react accordingly.
Information on the GAC API can be found here:
http://blogs.msdn.com/b/junfeng/archive/2004/09/14/229649.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With