Пример #1
0
        /// <summary>
        /// run this method with a .net 3.5 and .net 4.0 project to generate the table above.
        /// </summary>
        void CreateReferenceToFrameworkTable()
        {
            LoggingService.Warn("Running CreateReferenceToFrameworkTable()");

            MSBuildBasedProject project = selectDialog.ConfigureProject as MSBuildBasedProject;

            if (project == null)
            {
                return;
            }

            var redistNameToRequiredFramework = new Dictionary <string, string> {
                { "Framework", null },
                { "Microsoft-Windows-CLRCoreComp", null },
                { "Microsoft.VisualStudio.Primary.Interop.Assemblies.8.0", null },
                { "Microsoft-WinFX-Runtime", "3.0" },
                { "Microsoft-Windows-CLRCoreComp.3.0", "3.0" },
                { "Microsoft-Windows-CLRCoreComp-v3.5", "3.5" },
                { "Microsoft-Windows-CLRCoreComp.4.0", "4.0" },
            };

            using (StreamWriter w = new StreamWriter("c:\\temp\\references.txt")) {
                List <ReferenceProjectItem> referenceItems = new List <ReferenceProjectItem>();
                WorkbenchSingleton.SafeThreadCall(
                    delegate {
                    foreach (ListViewItem item in fullItemList)
                    {
                        referenceItems.Add(new ReferenceProjectItem(project, item.Tag.ToString()));
                    }
                });

                MSBuildInternals.ResolveAssemblyReferences(project, referenceItems.ToArray());
                foreach (ReferenceProjectItem rpi in referenceItems)
                {
                    if (string.IsNullOrEmpty(rpi.Redist))
                    {
                        continue;
                    }
                    if (!redistNameToRequiredFramework.ContainsKey(rpi.Redist))
                    {
                        LoggingService.Error("unknown redist: " + rpi.Redist);
                    }
                    else if (redistNameToRequiredFramework[rpi.Redist] != null)
                    {
                        w.Write("\t\t\t{ \"");
                        w.Write(rpi.Include);
                        w.Write("\", \"");
                        w.Write(redistNameToRequiredFramework[rpi.Redist]);
                        w.WriteLine("\" },");
                    }
                }
            }
        }
Пример #2
0
        void ResolveVersionsWorker()
        {
            MSBuildBasedProject project = selectDialog.ConfigureProject as MSBuildBasedProject;

            if (project == null)
            {
                return;
            }

            List <ListViewItem>         itemsToResolveVersion = new List <ListViewItem>();
            List <ReferenceProjectItem> referenceItems        = new List <ReferenceProjectItem>();

            WorkbenchSingleton.SafeThreadCall(
                delegate {
                foreach (ListViewItem item in shortItemList)
                {
                    if (item.SubItems[1].Text.Contains("/"))
                    {
                        itemsToResolveVersion.Add(item);
                        referenceItems.Add(new ReferenceProjectItem(project, item.Text));
                    }
                }
            });

            MSBuildInternals.ResolveAssemblyReferences(project, referenceItems.ToArray());

            WorkbenchSingleton.SafeThreadAsyncCall(
                delegate {
                if (IsDisposed)
                {
                    return;
                }
                for (int i = 0; i < itemsToResolveVersion.Count; i++)
                {
                    if (referenceItems[i].Version != null)
                    {
                        itemsToResolveVersion[i].SubItems[1].Text = referenceItems[i].Version.ToString();
                    }
                }
            });
        }