private static void ProcessPackages(ISetupInstance2 instance, VisualStudioInstance result) { ISetupPackageReference[] packages = instance.GetPackages(); foreach (var package in packages) { String packageType = package.GetType(); PackageReference refPackage = CreatePackageReference(package); switch (packageType.ToUpper(CultureInfo.InvariantCulture)) { case "PRODUCT": result.Products.Add(refPackage); break; case "WORKLOAD": result.Workloads.Add(refPackage); break; case "COMPONENT": result.Components.Add(refPackage); break; case "VSIX": result.Visx.Add(refPackage); break; case "EXE": result.Exe.Add(refPackage); break; case "MSI": result.Msi.Add(refPackage); break; case "MSU": result.Msu.Add(refPackage); break; case "GROUP": result.Group.Add(refPackage); break; case "WINDOWSFEATURE": result.WindowsFeature.Add(refPackage); break; default: Trace.WriteLine(packageType); result.OtherPackages.Add(refPackage); break; } } }
private static VisualStudioInstance FillInInstanceData(ISetupInstance2 instance, int lcid, Boolean includePackages) { VisualStudioInstance result = new VisualStudioInstance() { InstanceId = instance.GetInstanceId(), InstalledVersionNumber = instance.GetInstallationVersion(), Description = instance.GetDescription(lcid), DisplayName = instance.GetDisplayName(lcid) }; // Hides the non-CLS clompliant uint. var tempState = instance.GetState(); if (tempState == InstanceState.Complete) { result.Status = InstanceStatus.Complete; } else { result.Status = (InstanceStatus)tempState; } result.InstallationPath = instance.GetInstallationPath(); ISetupPackageReference prod = instance.GetProduct(); if (prod != null) { result.ProductName = prod.GetId(); } if ((result.Status & InstanceStatus.Local) == InstanceStatus.Local) { result.InstallationPath = instance.GetInstallationPath(); } if (includePackages) { ProcessPackages(instance, result); } return(result); }