Beispiel #1
0
        public static async Task Prepare(VsHive hive, IEnumerable <string> extensionsToInstall, bool resetSettings, IDiagnostics diagnostics)
        {
            await diagnostics.RunAsync("Preparing Instance", async output =>
            {
                var installResult   = default((int InstallCount, bool HasSettingsFile, string Output));
                var invokerAssembly = Assembly.GetExecutingAssembly();

                using (var invoker = new TempFile(EmbeddedResourceUtil.ExtractResource(invokerAssembly, "VsixTesting.Invoker.vsix")))
                {
                    EmbeddedResourceUtil.ApplyDateTime(invoker.Path, invokerAssembly, "VsixTesting.Invoker.vsix");

                    installResult = await VisualStudioUtil.InstallExtensionsAsync(
                        hive,
                        extensionsToInstall.Concat(new[] { invoker.Path }));

                    output.WriteLine(installResult.Output);

                    if (installResult.InstallCount > 0)
                    {
                        output.WriteLine("Clearing cache");
                        await VisualStudioUtil.ClearCacheAsync(hive);
                        output.WriteLine("Updating configuration");
                        await VisualStudioUtil.UpdateConfigurationAsync(hive);
                    }
                }

                if (!installResult.HasSettingsFile || resetSettings)
                {
                    output.WriteLine("Resetting settings");
                    await VisualStudioUtil.ResetSettingsAsync(hive);
                }
            });
        }
Beispiel #2
0
        public static async Task Prepare(VsHive hive, IEnumerable <string> extensionsToInstall, bool resetSettings, IDiagnostics diagnostics, bool installInvoker = true)
        {
            await diagnostics.RunAsync("Preparing Instance", async output =>
            {
                var invokerAssembly = Assembly.GetExecutingAssembly();
                var resourceName    = $"VsixTesting.Invoker{(hive.Version.Major >= 17 ? ".17" : string.Empty)}.vsix";

                using (var invoker = new TempFile(EmbeddedResourceUtil.ExtractResource(invokerAssembly, resourceName)))
                {
                    EmbeddedResourceUtil.ApplyDateTime(invoker.Path, invokerAssembly, resourceName);

                    if (installInvoker)
                    {
                        extensionsToInstall = extensionsToInstall.Concat(new[] { invoker.Path });
                    }

                    var installResult = await VisualStudioUtil.InstallExtensionsAsync(hive, extensionsToInstall);

                    output.WriteLine(installResult.Output);

                    if (installResult.InstallCount > 0)
                    {
                        output.WriteLine("Clearing cache");
                        await VisualStudioUtil.ClearCacheAsync(hive);
                        output.WriteLine("Updating configuration");
                        await VisualStudioUtil.UpdateConfigurationAsync(hive);
                    }
                }

                if (resetSettings)
                {
                    output.WriteLine("Resetting settings");
                    await VisualStudioUtil.ResetSettingsAsync(hive);
                }
            });
        }