示例#1
0
        public static void Initialize(bool updateAddinRegistry)
        {
            if (initialized)
            {
                return;
            }
            Counters.RuntimeInitialization.BeginTiming();
            SetupInstrumentation();

            if (Platform.IsMac)
            {
                InitMacFoundation();
            }

            // Set a default sync context
            if (SynchronizationContext.Current == null)
            {
                SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
            }

            AddinManager.AddinLoadError += OnLoadError;
            AddinManager.AddinLoaded    += OnLoad;
            AddinManager.AddinUnloaded  += OnUnload;

            //provides a development-time way to load addins that are being developed in a asperate solution
            var devAddinDir = Environment.GetEnvironmentVariable("MONODEVELOP_DEV_ADDINS");

            if (devAddinDir != null && devAddinDir.Length == 0)
            {
                devAddinDir = null;
            }

            try {
                Counters.RuntimeInitialization.Trace("Initializing Addin Manager");
                AddinManager.Initialize(
                    UserProfile.Current.ConfigDir,
                    devAddinDir ?? UserProfile.Current.LocalInstallDir.Combine("Addins"),
                    devAddinDir ?? UserProfile.Current.CacheDir);
                AddinManager.InitializeDefaultLocalizer(new DefaultAddinLocalizer());

                if (updateAddinRegistry)
                {
                    AddinManager.Registry.Update(null);
                }
                setupService = new AddinSetupService(AddinManager.Registry);
                Counters.RuntimeInitialization.Trace("Initialized Addin Manager");

                PropertyService.Initialize();

                //have to do this after the addin service and property service have initialized
                if (UserDataMigrationService.HasSource)
                {
                    Counters.RuntimeInitialization.Trace("Migrating User Data from MD " + UserDataMigrationService.SourceVersion);
                    UserDataMigrationService.StartMigration();
                }

                RegisterAddinRepositories();

                Counters.RuntimeInitialization.Trace("Initializing Assembly Service");
                systemAssemblyService = new SystemAssemblyService();
                systemAssemblyService.Initialize();

                initialized = true;
            } catch (Exception ex) {
                Console.WriteLine(ex);
                AddinManager.AddinLoadError -= OnLoadError;
                AddinManager.AddinLoaded    -= OnLoad;
                AddinManager.AddinUnloaded  -= OnUnload;
            } finally {
                Counters.RuntimeInitialization.EndTiming();
            }
        }
        public static BuildResult Compile(ProjectItemCollection projectItems, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, IProgressMonitor monitor)
        {
            var compilerParameters = (CSharpCompilerParameters)configuration.CompilationParameters ?? new CSharpCompilerParameters();
            var projectParameters  = (CSharpProjectParameters)configuration.ProjectParameters ?? new CSharpProjectParameters();

            FilePath outputName       = configuration.CompiledOutputName;
            string   responseFileName = Path.GetTempFileName();

            //make sure that the output file is writable
            if (File.Exists(outputName))
            {
                bool isWriteable = false;
                int  count       = 0;
                do
                {
                    try {
                        outputName.MakeWritable();
                        using (var stream = File.OpenWrite(outputName)) {
                            isWriteable = true;
                        }
                    } catch (Exception) {
                        Thread.Sleep(20);
                    }
                } while (count++ < 5 && !isWriteable);
                if (!isWriteable)
                {
                    MessageService.ShowError(string.Format(GettextCatalog.GetString("Can't lock file: {0}."), outputName));
                    return(null);
                }
            }

            //get the runtime
            TargetRuntime runtime = MonoDevelop.Core.Runtime.SystemAssemblyService.DefaultRuntime;
            DotNetProject project = configuration.ParentItem as DotNetProject;

            if (project != null)
            {
                runtime = project.TargetRuntime;
            }

            //get the compiler name
            string compilerName;

            try {
                compilerName = GetCompilerName(runtime, configuration.TargetFramework);
            } catch (Exception e) {
                string message = "Could not obtain a C# compiler";
                monitor.ReportError(message, e);
                return(null);
            }

            var sb = new StringBuilder();

            HashSet <string> alreadyAddedReference = new HashSet <string> ();

            var monoRuntime = runtime as MonoTargetRuntime;

            if (!compilerParameters.NoStdLib && (monoRuntime == null || monoRuntime.HasMultitargetingMcs))
            {
                string corlib = project.AssemblyContext.GetAssemblyFullName("mscorlib", project.TargetFramework);
                if (corlib != null)
                {
                    corlib = project.AssemblyContext.GetAssemblyLocation(corlib, project.TargetFramework);
                }
                if (corlib == null)
                {
                    var br = new BuildResult();
                    br.AddError(string.Format("Could not find mscorlib for framework {0}", project.TargetFramework.Id));
                    return(br);
                }
                AppendQuoted(sb, "/r:", corlib);
                sb.AppendLine("-nostdlib");
            }

            List <string> gacRoots = new List <string> ();

            sb.AppendFormat("\"/out:{0}\"", outputName);
            sb.AppendLine();

            foreach (ProjectReference lib in projectItems.GetAll <ProjectReference> ())
            {
                if (lib.ReferenceType == ReferenceType.Project)
                {
                    var ownerProject = lib.OwnerProject;
                    if (ownerProject != null)
                    {
                        var parentSolution = ownerProject.ParentSolution;
                        if (parentSolution != null && !(parentSolution.FindProjectByName(lib.Reference) is DotNetProject))
                        {
                            continue;
                        }
                    }
                }
                string refPrefix = string.IsNullOrEmpty(lib.Aliases) ? "" : lib.Aliases + "=";
                foreach (string fileName in lib.GetReferencedFileNames(configSelector))
                {
                    switch (lib.ReferenceType)
                    {
                    case ReferenceType.Package:
                        SystemPackage pkg = lib.Package;
                        if (pkg == null)
                        {
                            string msg = string.Format(GettextCatalog.GetString("{0} could not be found or is invalid."), lib.Reference);
                            monitor.ReportWarning(msg);
                            continue;
                        }

                        if (alreadyAddedReference.Add(fileName))
                        {
                            AppendQuoted(sb, "/r:", refPrefix + fileName);
                        }

                        if (pkg.GacRoot != null && !gacRoots.Contains(pkg.GacRoot))
                        {
                            gacRoots.Add(pkg.GacRoot);
                        }
                        if (!string.IsNullOrEmpty(pkg.Requires))
                        {
                            foreach (string requiredPackage in pkg.Requires.Split(' '))
                            {
                                SystemPackage rpkg = runtime.AssemblyContext.GetPackage(requiredPackage);
                                if (rpkg == null)
                                {
                                    continue;
                                }
                                foreach (SystemAssembly assembly in rpkg.Assemblies)
                                {
                                    if (alreadyAddedReference.Add(assembly.Location))
                                    {
                                        AppendQuoted(sb, "/r:", assembly.Location);
                                    }
                                }
                            }
                        }
                        break;

                    default:
                        if (alreadyAddedReference.Add(fileName))
                        {
                            AppendQuoted(sb, "/r:", refPrefix + fileName);
                        }
                        break;
                    }
                }
            }

            if (alreadyAddedReference.Any(reference => SystemAssemblyService.ContainsReferenceToSystemRuntime(reference)))
            {
                LoggingService.LogInfo("Found PCLv2 assembly.");
                var facades = runtime.FindFacadeAssembliesForPCL(project.TargetFramework);
                foreach (var facade in facades)
                {
                    AppendQuoted(sb, "/r:", facade);
                }
            }

            string sysCore = project.AssemblyContext.GetAssemblyFullName("System.Core", project.TargetFramework);

            if (sysCore != null && !alreadyAddedReference.Contains(sysCore))
            {
                var asm = project.AssemblyContext.GetAssemblyFromFullName(sysCore, null, project.TargetFramework);
                if (asm != null)
                {
                    AppendQuoted(sb, "/r:", asm.Location);
                }
            }

            sb.AppendLine("/nologo");
            sb.Append("/warn:"); sb.Append(compilerParameters.WarningLevel.ToString());
            sb.AppendLine();

            if (configuration.SignAssembly)
            {
                if (File.Exists(configuration.AssemblyKeyFile))
                {
                    AppendQuoted(sb, "/keyfile:", configuration.AssemblyKeyFile);
                }
                if (configuration.DelaySign)
                {
                    sb.AppendLine("/delaySign");
                }
            }

            var debugType = compilerParameters.DebugType;

            if (string.IsNullOrEmpty(debugType))
            {
                debugType = configuration.DebugMode ? "full" : "none";
            }
            else if (string.Equals(debugType, "pdbonly", StringComparison.OrdinalIgnoreCase))
            {
                //old Mono compilers don't support pdbonly
                if (monoRuntime != null && !monoRuntime.HasMultitargetingMcs)
                {
                    debugType = "full";
                }
            }
            if (!string.Equals(debugType, "none", StringComparison.OrdinalIgnoreCase))
            {
                sb.AppendLine("/debug:" + debugType);
            }

            if (compilerParameters.LangVersion != LangVersion.Default)
            {
                var langVersionString = CSharpCompilerParameters.TryLangVersionToString(compilerParameters.LangVersion);
                if (langVersionString == null)
                {
                    string message = "Invalid LangVersion enum value '" + compilerParameters.LangVersion.ToString() + "'";
                    monitor.ReportError(message, null);
                    LoggingService.LogError(message);
                    return(null);
                }
                sb.AppendLine("/langversion:" + langVersionString);
            }

            // mcs default is + but others might not be
            if (compilerParameters.Optimize)
            {
                sb.AppendLine("/optimize+");
            }
            else
            {
                sb.AppendLine("/optimize-");
            }

            bool hasWin32Res = !string.IsNullOrEmpty(projectParameters.Win32Resource) && File.Exists(projectParameters.Win32Resource);

            if (hasWin32Res)
            {
                AppendQuoted(sb, "/win32res:", projectParameters.Win32Resource);
            }

            if (!string.IsNullOrEmpty(projectParameters.Win32Icon) && File.Exists(projectParameters.Win32Icon))
            {
                if (hasWin32Res)
                {
                    monitor.ReportWarning("Both Win32 icon and Win32 resource cannot be specified. Ignoring the icon.");
                }
                else
                {
                    AppendQuoted(sb, "/win32icon:", projectParameters.Win32Icon);
                }
            }

            if (projectParameters.CodePage != 0)
            {
                sb.AppendLine("/codepage:" + projectParameters.CodePage);
            }
            else if (runtime is MonoTargetRuntime)
            {
                sb.AppendLine("/codepage:utf8");
            }

            if (compilerParameters.UnsafeCode)
            {
                sb.AppendLine("-unsafe");
            }
            if (compilerParameters.NoStdLib)
            {
                sb.AppendLine("-nostdlib");
            }

            if (!string.IsNullOrEmpty(compilerParameters.PlatformTarget) && compilerParameters.PlatformTarget.ToLower() != "anycpu")
            {
                //HACK: to ignore the platform flag for Mono <= 2.4, because gmcs didn't support it
                if (runtime.RuntimeId == "Mono" && runtime.AssemblyContext.GetAssemblyLocation("Mono.Debugger.Soft", null) == null)
                {
                    LoggingService.LogWarning("Mono runtime '" + runtime.DisplayName +
                                              "' appears to be too old to support the 'platform' C# compiler flag.");
                }
                else
                {
                    sb.AppendLine("/platform:" + compilerParameters.PlatformTarget);
                }
            }

            if (compilerParameters.TreatWarningsAsErrors)
            {
                sb.AppendLine("-warnaserror");
                if (!string.IsNullOrEmpty(compilerParameters.WarningsNotAsErrors))
                {
                    sb.AppendLine("-warnaserror-:" + compilerParameters.WarningsNotAsErrors);
                }
            }

            if (compilerParameters.DefineSymbols.Length > 0)
            {
                string define_str = string.Join(";", compilerParameters.DefineSymbols.Split(new char [] { ',', ' ', ';' }, StringSplitOptions.RemoveEmptyEntries));
                if (define_str.Length > 0)
                {
                    AppendQuoted(sb, "/define:", define_str);
                    sb.AppendLine();
                }
            }

            CompileTarget ctarget = configuration.CompileTarget;

            if (!string.IsNullOrEmpty(projectParameters.MainClass))
            {
                sb.AppendLine("/main:" + projectParameters.MainClass);
                // mcs does not allow providing a Main class when compiling a dll
                // As a workaround, we compile as WinExe (although the output will still
                // have a .dll extension).
                if (ctarget == CompileTarget.Library)
                {
                    ctarget = CompileTarget.WinExe;
                }
            }

            switch (ctarget)
            {
            case CompileTarget.Exe:
                sb.AppendLine("/t:exe");
                break;

            case CompileTarget.WinExe:
                sb.AppendLine("/t:winexe");
                break;

            case CompileTarget.Library:
                sb.AppendLine("/t:library");
                break;
            }

            foreach (ProjectFile finfo in projectItems.GetAll <ProjectFile> ())
            {
                if (finfo.Subtype == Subtype.Directory)
                {
                    continue;
                }

                switch (finfo.BuildAction)
                {
                case "Compile":
                    AppendQuoted(sb, "", finfo.Name);
                    break;

                case "EmbeddedResource":
                    string fname = finfo.Name;
                    if (string.Compare(Path.GetExtension(fname), ".resx", true) == 0)
                    {
                        fname = Path.ChangeExtension(fname, ".resources");
                    }
                    sb.Append('"'); sb.Append("/res:");
                    sb.Append(fname); sb.Append(','); sb.Append(finfo.ResourceId);
                    sb.Append('"'); sb.AppendLine();
                    break;

                default:
                    continue;
                }
            }
            if (compilerParameters.GenerateXmlDocumentation)
            {
                AppendQuoted(sb, "/doc:", Path.ChangeExtension(outputName, ".xml"));
            }

            if (!string.IsNullOrEmpty(compilerParameters.AdditionalArguments))
            {
                sb.AppendLine(compilerParameters.AdditionalArguments);
            }

            if (!string.IsNullOrEmpty(compilerParameters.NoWarnings))
            {
                AppendQuoted(sb, "/nowarn:", compilerParameters.NoWarnings);
            }

            if (runtime.RuntimeId == "MS.NET")
            {
                sb.AppendLine("/fullpaths");
                sb.AppendLine("/utf8output");
            }

            string output = "";
            string error  = "";

            File.WriteAllText(responseFileName, sb.ToString());



            monitor.Log.WriteLine(compilerName + " /noconfig " + sb.ToString().Replace('\n', ' '));

            string workingDir = ".";

            if (configuration.ParentItem != null)
            {
                workingDir = configuration.ParentItem.BaseDirectory;
                if (workingDir == null)
                {
                    // Dummy projects created for single files have no filename
                    // and so no BaseDirectory.
                    // This is a workaround for a bug in
                    // ProcessStartInfo.WorkingDirectory - not able to handle null
                    workingDir = ".";
                }
            }

            LoggingService.LogInfo(compilerName + " " + sb.ToString());

            ExecutionEnvironment envVars = runtime.GetToolsExecutionEnvironment(project.TargetFramework);
            string cargs = "/noconfig @\"" + responseFileName + "\"";

            int exitCode = DoCompilation(monitor, compilerName, cargs, workingDir, envVars, gacRoots, ref output, ref error);

            BuildResult result = ParseOutput(output, error);

            if (result.CompilerOutput.Trim().Length != 0)
            {
                monitor.Log.WriteLine(result.CompilerOutput);
            }

            //if compiler crashes, output entire error string
            if (result.ErrorCount == 0 && exitCode != 0)
            {
                try {
                    monitor.Log.Write(File.ReadAllText(error));
                } catch (IOException) {
                }
                result.AddError("The compiler appears to have crashed. Check the build output pad for details.");
                LoggingService.LogError("C# compiler crashed. Response file '{0}', stdout file '{1}', stderr file '{2}'",
                                        responseFileName, output, error);
            }
            else
            {
                FileService.DeleteFile(responseFileName);
                FileService.DeleteFile(output);
                FileService.DeleteFile(error);
            }
            return(result);
        }
示例#3
0
        public static void Initialize(bool updateAddinRegistry)
        {
            if (initialized)
            {
                return;
            }

            Counters.RuntimeInitialization.BeginTiming();
            SetupInstrumentation();

            Platform.Initialize();

            mainThread = Thread.CurrentThread;
            // Set a default sync context
            if (SynchronizationContext.Current == null)
            {
                defaultSynchronizationContext = new SynchronizationContext();
                SynchronizationContext.SetSynchronizationContext(defaultSynchronizationContext);
            }
            else
            {
                defaultSynchronizationContext = SynchronizationContext.Current;
            }


            // Hook up the SSL certificate validation codepath
            ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
                if (sslPolicyErrors == SslPolicyErrors.None)
                {
                    return(true);
                }

                if (sender is WebRequest)
                {
                    sender = ((WebRequest)sender).RequestUri.Host;
                }
                return(WebCertificateService.GetIsCertificateTrusted(sender as string, certificate.GetPublicKeyString()));
            };

            AddinManager.AddinLoadError += OnLoadError;
            AddinManager.AddinLoaded    += OnLoad;
            AddinManager.AddinUnloaded  += OnUnload;

            try {
                Counters.RuntimeInitialization.Trace("Initializing Addin Manager");

                string configDir, addinsDir, databaseDir;
                GetAddinRegistryLocation(out configDir, out addinsDir, out databaseDir);
                AddinManager.Initialize(configDir, addinsDir, databaseDir);
                AddinManager.InitializeDefaultLocalizer(new DefaultAddinLocalizer());

                if (updateAddinRegistry)
                {
                    AddinManager.Registry.Update(null);
                }
                setupService = new AddinSetupService(AddinManager.Registry);
                Counters.RuntimeInitialization.Trace("Initialized Addin Manager");

                PropertyService.Initialize();

                WebRequestHelper.Initialize();
                Mono.Addins.Setup.WebRequestHelper.SetRequestHandler(WebRequestHelper.GetResponse);

                //have to do this after the addin service and property service have initialized
                if (UserDataMigrationService.HasSource)
                {
                    Counters.RuntimeInitialization.Trace("Migrating User Data from MD " + UserDataMigrationService.SourceVersion);
                    UserDataMigrationService.StartMigration();
                }

                RegisterAddinRepositories();

                Counters.RuntimeInitialization.Trace("Initializing Assembly Service");
                systemAssemblyService = new SystemAssemblyService();
                systemAssemblyService.Initialize();
                LoadMSBuildLibraries();

                initialized = true;
            } catch (Exception ex) {
                Console.WriteLine(ex);
                AddinManager.AddinLoadError -= OnLoadError;
                AddinManager.AddinLoaded    -= OnLoad;
                AddinManager.AddinUnloaded  -= OnUnload;
            } finally {
                Counters.RuntimeInitialization.EndTiming();
            }
        }
        void ProcessProjectReferences(DotNetProject project, out string references, out string dllReferences, AutotoolsContext ctx)
        {
            StringWriter refWriter    = new StringWriter();
            StringWriter dllRefWriter = new StringWriter();

            pkgs = new Set <SystemPackage> ();

            // grab pkg-config references
            foreach (ProjectReference reference in project.References)
            {
                if (reference.ReferenceType == ReferenceType.Package)
                {
                    // Get pkg-config keys
                    SystemPackage pkg = reference.Package;
                    if (pkg != null && !pkg.IsCorePackage)
                    {
                        if (pkgs.Contains(pkg))
                        {
                            continue;
                        }
                        pkgs.Add(pkg);

                        refWriter.WriteLine(" \\");
                        if (generateAutotools)
                        {
                            refWriter.Write("\t$(");
                            refWriter.Write(AutotoolsContext.GetPkgConfigVariable(pkg.Name));
                            refWriter.Write("_LIBS)");
                        }
                        else
                        {
                            refWriter.Write("\t-pkg:{0}", pkg.Name);
                        }
                        pkgs.Add(pkg);
                    }
                    else
                    {
                        refWriter.WriteLine(" \\");                                             // store all refs for easy access
                        AssemblyName assembly = SystemAssemblyService.ParseAssemblyName(reference.Reference);
                        refWriter.Write("\t" + assembly.Name);
                        refWriter.Write("");
                    }
                }
                else if (reference.ReferenceType == ReferenceType.Assembly)
                {
                    string assemblyPath = Path.GetFullPath(reference.Reference);

                    dllRefWriter.WriteLine(" \\");
                    dllRefWriter.Write("\t");

                    ctx.AddGlobalReferencedFile(MakefileData.ToMakefilePath(FileService.AbsoluteToRelativePath(
                                                                                Path.GetFullPath(ctx.BaseDirectory), assemblyPath)));
                    dllRefWriter.Write(MakefileData.ToMakefilePath(FileService.AbsoluteToRelativePath(
                                                                       project.BaseDirectory, assemblyPath)));
                }
                else if (reference.ReferenceType == ReferenceType.Project)
                {
                    continue;                     // handled per-config
                }
                else
                {
                    throw new Exception(GettextCatalog.GetString("Project reference type '{0}' not supported yet",
                                                                 reference.ReferenceType.ToString()));
                }
            }

            references    = refWriter.ToString();
            dllReferences = dllRefWriter.ToString();
        }
示例#5
0
        public static void Initialize(bool updateAddinRegistry)
        {
            if (initialized)
            {
                return;
            }
            Counters.RuntimeInitialization.BeginTiming();
            SetupInstrumentation();

            Platform.Initialize();

            // Set a default sync context
            if (SynchronizationContext.Current == null)
            {
                SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
            }

            // Hook up the SSL certificate validation codepath
            System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
                if (sslPolicyErrors == SslPolicyErrors.None)
                {
                    return(true);
                }

                if (sender is WebRequest)
                {
                    sender = ((WebRequest)sender).RequestUri.Host;
                }
                return(WebCertificateService.GetIsCertificateTrusted(sender as string, certificate.GetPublicKeyString()));
            };

            AddinManager.AddinLoadError += OnLoadError;
            AddinManager.AddinLoaded    += OnLoad;
            AddinManager.AddinUnloaded  += OnUnload;

            //provides a development-time way to load addins that are being developed in a asperate solution
            var devAddinDir = Environment.GetEnvironmentVariable("MONODEVELOP_DEV_ADDINS");

            if (devAddinDir != null && devAddinDir.Length == 0)
            {
                devAddinDir = null;
            }

            try {
                Counters.RuntimeInitialization.Trace("Initializing Addin Manager");
                AddinManager.Initialize(
                    UserProfile.Current.ConfigDir,
                    devAddinDir ?? UserProfile.Current.LocalInstallDir.Combine("Addins"),
                    devAddinDir ?? UserProfile.Current.CacheDir);
                AddinManager.InitializeDefaultLocalizer(new DefaultAddinLocalizer());

                if (updateAddinRegistry)
                {
                    AddinManager.Registry.Update(null);
                }
                setupService = new AddinSetupService(AddinManager.Registry);
                Counters.RuntimeInitialization.Trace("Initialized Addin Manager");

                PropertyService.Initialize();

                //have to do this after the addin service and property service have initialized
                if (UserDataMigrationService.HasSource)
                {
                    Counters.RuntimeInitialization.Trace("Migrating User Data from MD " + UserDataMigrationService.SourceVersion);
                    UserDataMigrationService.StartMigration();
                }

                RegisterAddinRepositories();

                Counters.RuntimeInitialization.Trace("Initializing Assembly Service");
                systemAssemblyService = new SystemAssemblyService();
                systemAssemblyService.Initialize();

                initialized = true;
            } catch (Exception ex) {
                Console.WriteLine(ex);
                AddinManager.AddinLoadError -= OnLoadError;
                AddinManager.AddinLoaded    -= OnLoad;
                AddinManager.AddinUnloaded  -= OnUnload;
            } finally {
                Counters.RuntimeInitialization.EndTiming();
            }
        }
        public void Reset()
        {
            store.Clear();

            foreach (SystemAssembly systemAssembly in targetContext.GetAssemblies(targetVersion))
            {
                if (systemAssembly.Package.IsFrameworkPackage && systemAssembly.Name == "mscorlib")
                {
                    continue;
                }

                bool   selected = IsSelected(ReferenceType.Package, systemAssembly.FullName, systemAssembly.Package.Name);
                int    matchRank = 0;
                string name, version;

                if (stringMatcher != null)
                {
                    string txt = systemAssembly.Name + " " + systemAssembly.Version;
                    if (!stringMatcher.CalcMatchRank(txt, out matchRank))
                    {
                        continue;
                    }
                    int[] match = stringMatcher.GetMatch(txt);
                    name    = GetMatchMarkup(treeView, systemAssembly.Name, match, 0);
                    version = GetMatchMarkup(treeView, systemAssembly.Version, match, systemAssembly.Name.Length + 1);
                }
                else
                {
                    name    = GLib.Markup.EscapeText(systemAssembly.Name);
                    version = GLib.Markup.EscapeText(systemAssembly.Version);
                }
                string pkg = systemAssembly.Package.GetDisplayName();
                if (systemAssembly.Package.IsInternalPackage)
                {
                    pkg += " " + GettextCatalog.GetString("(Provided by MonoDevelop)");
                }

                store.AppendValues(name,
                                   version,
                                   systemAssembly,
                                   selected,
                                   systemAssembly.FullName,
                                   pkg,
                                   MonoDevelop.Ide.Gui.Stock.Package,
                                   matchRank,
                                   ReferenceType.Package);
            }

            if (showAll)
            {
                Solution openSolution = configureProject.ParentSolution;
                if (openSolution == null)
                {
                    return;
                }

                Dictionary <DotNetProject, bool> references = new Dictionary <DotNetProject, bool> ();

                foreach (Project projectEntry in openSolution.GetAllSolutionItems <Project>())
                {
                    if (projectEntry == configureProject)
                    {
                        continue;
                    }

                    bool   selected  = IsSelected(ReferenceType.Project, projectEntry.Name, "");
                    int    matchRank = 0;
                    string name;

                    if (stringMatcher != null)
                    {
                        if (!stringMatcher.CalcMatchRank(projectEntry.Name, out matchRank))
                        {
                            continue;
                        }
                        int[] match = stringMatcher.GetMatch(projectEntry.Name);
                        name = GetMatchMarkup(treeView, projectEntry.Name, match, 0);
                    }
                    else
                    {
                        name = GLib.Markup.EscapeText(projectEntry.Name);
                    }

                    DotNetProject netProject = projectEntry as DotNetProject;
                    if (netProject != null)
                    {
                        if (ProjectReferencePanel.ProjectReferencesProject(references, null, netProject, configureProject.Name))
                        {
                            continue;
                        }
                        else if (!configureProject.TargetFramework.IsCompatibleWithFramework(netProject.TargetFramework.Id))
                        {
                            continue;
                        }
                    }
                    store.AppendValues(name, "", null, selected, projectEntry.Name, "", projectEntry.StockIcon, matchRank, ReferenceType.Project);
                }

                foreach (FilePath file in selectDialog.GetRecentFileReferences())
                {
                    bool   selected  = IsSelected(ReferenceType.Assembly, file, "");
                    int    matchRank = 0;
                    string fname     = file.FileName;
                    string name;

                    string version = string.Empty;
                    try
                    {
                        string sname = SystemAssemblyService.GetAssemblyName(file);
                        var    aname = SystemAssemblyService.ParseAssemblyName(sname);
                        version = aname.Version.ToString();
                    }
                    catch
                    {
                        continue;
                    }

                    if (stringMatcher != null)
                    {
                        if (!stringMatcher.CalcMatchRank(fname, out matchRank))
                        {
                            continue;
                        }
                        int[] match = stringMatcher.GetMatch(fname);
                        name = GetMatchMarkup(treeView, fname, match, 0);
                    }
                    else
                    {
                        name = GLib.Markup.EscapeText(fname);
                    }
                    store.AppendValues(name, version, null, selected, (string)file, GLib.Markup.EscapeText(file), MonoDevelop.Ide.Gui.Stock.OpenFolder, matchRank, ReferenceType.Assembly);
                }
            }
        }