private static string BuildExtraCmdLine(string exeConfig, string appBase, NgenScenarios scenarios) { var cmdLine = string.Empty; if (exeConfig != null) cmdLine += string.Format(" /ExeConfig:\"{0}\"", exeConfig); if (appBase != null) cmdLine += string.Format(" /AppBase:\"{0}\"", appBase); if (scenarios.HasFlag(NgenScenarios.Debug)) cmdLine += " /Debug"; if (scenarios.HasFlag(NgenScenarios.Profile)) cmdLine += " /Profile"; if (scenarios.HasFlag(NgenScenarios.NoDependencies)) cmdLine += " /NoDependencies"; return cmdLine; }
/// <summary> /// Delete the native images of an assembly and its dependencies from the native image cache. /// </summary> /// <param name="assembly">Path of the assembly or full display name, e.g. /// "myAssembly, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0038abc9deabfle5".</param> /// <param name="exeConfig">Use the configuration of the specified executable assembly.</param> /// <param name="appBase">When locating dependencies, use the specified directory as the application base.</param> /// <param name="scenarios">Multiple images can be generated, depending on usage scenarios.</param> public void UninstallAssembly(string assembly, string exeConfig = null, string appBase = null, NgenScenarios scenarios = NgenScenarios.Default) { InitNgenAction(); var cmdLine = string.Format("uninstall \"{0}\" /nologo /verbose", assembly); cmdLine += BuildExtraCmdLine(exeConfig, appBase, scenarios); BuildAssemblyList(assembly, appBase); RunNgen(cmdLine); }