internal BulkUninstallEntry(ApplicationUninstallerEntry uninstallerEntry, bool isSilent, UninstallStatus startingStatus) { CurrentStatus = startingStatus; IsSilent = isSilent; UninstallerEntry = uninstallerEntry; }
public BulkUninstallEntry(ApplicationUninstallerEntry uninstallerEntry, bool isSilentPossible, UninstallStatus startingStatus) { CurrentStatus = startingStatus; IsSilentPossible = isSilentPossible; UninstallerEntry = uninstallerEntry; }
/// <summary> /// Uninstalls the assembly. /// </summary> /// <param name="assemblyName">Name of the assembly.</param> /// <param name="force">if set to <c>true</c> force.</param> /// <param name="result">The UninstallStatus result.</param> /// <returns>Returns <c>true</c> if uninstall successful.</returns> public static bool UninstallAssembly(string assemblyName, bool force, out UninstallStatus result) { result = UninstallStatus.None; string fullName; string fullPath = GetAssemblyPath(assemblyName, out fullName); if (string.IsNullOrEmpty(fullPath)) { result = UninstallStatus.ReferenceNotFound; return(true); } IAssemblyCache cache = null; ThrowOnError(NativeMethods.CreateAssemblyCache(out cache, 0)); int flags = force ? (int)CommitFlags.Force : (int)CommitFlags.Refresh; ThrowOnError(cache.UninstallAssembly(flags, fullName, null, out result)); bool successful = false; switch (result) { case UninstallStatus.Uninstalled: case UninstallStatus.AlreadyUninstalled: case UninstallStatus.DeletePending: successful = true; break; } return(successful); }
} // unintall private void UnintallAssembly(string name) { Log.LogMessage("Uninstall: {0}", name); string fullName; string installPath = FusionWrapper.GetAssemblyPath(name, out fullName); if (string.IsNullOrEmpty(installPath)) { Log.LogMessage(" Status: {0}", UninstallStatus.ReferenceNotFound.ToString()); if (!_quiet) { Log.LogWarning("Assembly '{0}' not found in the GAC.", name); } _skipped++; return; } _installedPaths.Add(new TaskItem(installPath)); AssemblyName assemblyName = AssemblyName.GetAssemblyName(installPath); _installedNames.Add(assemblyName.FullName); UninstallStatus status = UninstallStatus.None; bool result = FusionWrapper.UninstallAssembly(fullName, _force, out status); if (result) { _successful++; } else { _failed++; } Log.LogMessage(" Status: {0}", status.ToString()); }
static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Usage:"); Console.WriteLine(" tgacutil {/i|/u} Assembly [Assembly]..."); Console.WriteLine(" /i : Install assemblies into GAC. Specify assemblies by full-path."); Console.WriteLine(" /u : Uninstall assemblies from GAC. Specify assemblies by assembly name."); return; } string mode = args[0].ToLower(); string[] assemblies = args.Skip(1).ToArray(); IAssemblyCache ac = null; int hr = NativeMethods.CreateAssemblyCache(out ac, 0); foreach (string assembly in assemblies) { if (mode == "/i") { hr = ac.InstallAssembly(0, assembly, null); if (hr == 0) { Console.WriteLine(string.Format("{0}: Installed", System.IO.Path.GetFileNameWithoutExtension(assembly))); } } else if (mode == "/u") { UninstallStatus result = 0; ac.UninstallAssembly(0, assembly, null, out result); Console.WriteLine(string.Format("{0}: {1}", Path.GetFileNameWithoutExtension(assembly), result.ToString())); } } }
/// <summary> /// Uninstalls the assembly. /// </summary> /// <param name="assemblyName">Name of the assembly.</param> /// <param name="force">if set to <c>true</c> force.</param> /// <param name="result">The UninstallStatus result.</param> /// <returns>Returns <c>true</c> if uninstall successful.</returns> public static bool UninstallAssembly(string assemblyName, bool force, out UninstallStatus result) { result = UninstallStatus.None; string fullName; string fullPath = GetAssemblyPath(assemblyName, out fullName); if (string.IsNullOrEmpty(fullPath)) { result = UninstallStatus.ReferenceNotFound; return true; } IAssemblyCache cache = null; ThrowOnError(NativeMethods.CreateAssemblyCache(out cache, 0)); int flags = force ? (int) CommitFlags.Force : (int) CommitFlags.Refresh; ThrowOnError(cache.UninstallAssembly(flags, fullName, null, out result)); bool successful = false; switch (result) { case UninstallStatus.Uninstalled: case UninstallStatus.AlreadyUninstalled: case UninstallStatus.DeletePending: successful = true; break; } return successful; }
/// <summary> /// Uninstalls the assembly. /// </summary> /// <param name="assemblyName">Name of the assembly.</param> /// <param name="force">if set to <c>true</c> force.</param> /// <returns>Returns <c>true</c> if uninstall successful.</returns> public static bool UninstallAssembly(string assemblyName, bool force) { UninstallStatus result = UninstallStatus.Uninstalled; return(UninstallAssembly(assemblyName, force, out result)); }