From d3dc294d5e1f8dac2288f6997f4801ef1514f589 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 4 Apr 2018 17:45:56 +0100 Subject: [PATCH] Revert live reloading implementation. See PR for explanation. --- Blazor.sln | 11 -- .../src/Boot.ts | 8 - .../src/LiveReloading.ts | 92 ------------ .../Cli/Commands/BuildIndexHtmlCommand.cs | 5 - .../Core/IndexHtmlWriter.cs | 17 +-- .../targets/All.props | 9 -- .../targets/All.targets | 1 - .../targets/Blazor.MonoRuntime.props | 1 - .../targets/Blazor.MonoRuntime.targets | 23 +-- .../BlazorAppBuilderExtensions.cs | 9 -- .../BlazorConfig.cs | 11 -- .../LiveReloadingContext.cs | 140 ------------------ .../LiveReloadingExtensions.cs | 21 --- .../Microsoft.AspNetCore.Blazor.Server.csproj | 1 - .../IndexHtmlWriterTest.cs | 30 +--- ...Microsoft.AspNetCore.Blazor.E2ETest.csproj | 1 - .../Tests/LiveReloadingTest.cs | 118 --------------- test/testapps/LiveReloadTestApp/Home.cshtml | 1 - .../LiveReloadTestApp.csproj | 21 --- test/testapps/LiveReloadTestApp/Program.cs | 15 -- .../LiveReloadTestApp/wwwroot/index.html | 19 --- .../LiveReloadTestApp/wwwroot/someJsFile.js | 3 - .../BlazorPackage.cs | 17 --- .../LiveReloadBuildWatcher.cs | 119 --------------- ...rosoft.VisualStudio.BlazorExtension.csproj | 32 +--- 25 files changed, 10 insertions(+), 715 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Blazor.Browser.JS/src/LiveReloading.ts delete mode 100644 src/Microsoft.AspNetCore.Blazor.Server/LiveReloadingContext.cs delete mode 100644 src/Microsoft.AspNetCore.Blazor.Server/LiveReloadingExtensions.cs delete mode 100644 test/Microsoft.AspNetCore.Blazor.E2ETest/Tests/LiveReloadingTest.cs delete mode 100644 test/testapps/LiveReloadTestApp/Home.cshtml delete mode 100644 test/testapps/LiveReloadTestApp/LiveReloadTestApp.csproj delete mode 100644 test/testapps/LiveReloadTestApp/Program.cs delete mode 100644 test/testapps/LiveReloadTestApp/wwwroot/index.html delete mode 100644 test/testapps/LiveReloadTestApp/wwwroot/someJsFile.js delete mode 100644 tooling/Microsoft.VisualStudio.BlazorExtension/LiveReloadBuildWatcher.cs diff --git a/Blazor.sln b/Blazor.sln index dfffd765ed..dd676cd16c 100644 --- a/Blazor.sln +++ b/Blazor.sln @@ -90,8 +90,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.VisualStudio.Blaz EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestContentPackage", "test\testapps\TestContentPackage\TestContentPackage.csproj", "{C57382BC-EE93-49D5-BC40-5C98AF8AA048}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LiveReloadTestApp", "test\testapps\LiveReloadTestApp\LiveReloadTestApp.csproj", "{0246AA77-1A27-4A67-874B-6EF6F99E414E}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{36A7DEB7-5F88-4BFB-B57E-79EEC9950E25}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.Performance", "benchmarks\Microsoft.AspNetCore.Blazor.Performance\Microsoft.AspNetCore.Blazor.Performance.csproj", "{50F6820F-D058-4E68-9E15-801F893F514E}" @@ -319,14 +317,6 @@ Global {C57382BC-EE93-49D5-BC40-5C98AF8AA048}.Release|Any CPU.Build.0 = Release|Any CPU {C57382BC-EE93-49D5-BC40-5C98AF8AA048}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU {C57382BC-EE93-49D5-BC40-5C98AF8AA048}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU - {0246AA77-1A27-4A67-874B-6EF6F99E414E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0246AA77-1A27-4A67-874B-6EF6F99E414E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0246AA77-1A27-4A67-874B-6EF6F99E414E}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU - {0246AA77-1A27-4A67-874B-6EF6F99E414E}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU - {0246AA77-1A27-4A67-874B-6EF6F99E414E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0246AA77-1A27-4A67-874B-6EF6F99E414E}.Release|Any CPU.Build.0 = Release|Any CPU - {0246AA77-1A27-4A67-874B-6EF6F99E414E}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU - {0246AA77-1A27-4A67-874B-6EF6F99E414E}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU {50F6820F-D058-4E68-9E15-801F893F514E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {50F6820F-D058-4E68-9E15-801F893F514E}.Debug|Any CPU.Build.0 = Debug|Any CPU {50F6820F-D058-4E68-9E15-801F893F514E}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU @@ -375,7 +365,6 @@ Global {43E39257-7DC1-46BD-9BD9-2319A1313D07} = {F563ABB6-85FB-4CFC-B0D2-1D5130E8246D} {9088E4E4-B855-457F-AE9E-D86709A5E1F4} = {F563ABB6-85FB-4CFC-B0D2-1D5130E8246D} {C57382BC-EE93-49D5-BC40-5C98AF8AA048} = {4AE0D35B-D97A-44D0-8392-C9240377DCCE} - {0246AA77-1A27-4A67-874B-6EF6F99E414E} = {4AE0D35B-D97A-44D0-8392-C9240377DCCE} {50F6820F-D058-4E68-9E15-801F893F514E} = {36A7DEB7-5F88-4BFB-B57E-79EEC9950E25} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Boot.ts b/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Boot.ts index 7ddd84ff61..065c711523 100644 --- a/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Boot.ts +++ b/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Boot.ts @@ -1,6 +1,5 @@ import { platform } from './Environment'; import { getAssemblyNameFromUrl } from './Platform/DotNet'; -import { enableLiveReloading } from './LiveReloading'; import './Rendering/Renderer'; import './Services/Http'; import './Services/UriHelper'; @@ -37,13 +36,6 @@ async function boot() { // Start up the application platform.callEntryPoint(entryPointAssemblyName, entryPointMethod, []); - - // Enable live reloading only if there's a "reload" attribute on the - - - - diff --git a/test/testapps/LiveReloadTestApp/wwwroot/someJsFile.js b/test/testapps/LiveReloadTestApp/wwwroot/someJsFile.js deleted file mode 100644 index af61769b29..0000000000 --- a/test/testapps/LiveReloadTestApp/wwwroot/someJsFile.js +++ /dev/null @@ -1,3 +0,0 @@ -// We modify this on disk during E2E tests to verify it causes a reload -var valueToWrite = 'initial value'; -document.getElementById('some-js-file-output').textContent = valueToWrite; diff --git a/tooling/Microsoft.VisualStudio.BlazorExtension/BlazorPackage.cs b/tooling/Microsoft.VisualStudio.BlazorExtension/BlazorPackage.cs index aecd734a44..1d93fb5164 100644 --- a/tooling/Microsoft.VisualStudio.BlazorExtension/BlazorPackage.cs +++ b/tooling/Microsoft.VisualStudio.BlazorExtension/BlazorPackage.cs @@ -4,7 +4,6 @@ using System; using System.Runtime.InteropServices; using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; namespace Microsoft.VisualStudio.BlazorExtension { @@ -12,24 +11,8 @@ namespace Microsoft.VisualStudio.BlazorExtension [PackageRegistration(UseManagedResourcesOnly = true)] [AboutDialogInfo(PackageGuidString, "ASP.NET Core Blazor Language Services", "#110", "112")] [Guid(BlazorPackage.PackageGuidString)] - [ProvideAutoLoad(UIContextGuids80.SolutionExists)] public sealed class BlazorPackage : Package { public const string PackageGuidString = "d9fe04bc-57a7-4107-915e-3a5c2f9e19fb"; - - protected override void Initialize() - { - base.Initialize(); - RegisterLiveReloadBuildWatcher(); - } - - private void RegisterLiveReloadBuildWatcher() - { - // No need to unadvise, as this only happens once anyway - ThreadHelper.ThrowIfNotOnUIThread(); - var buildManager = (IVsSolutionBuildManager)GetService(typeof(SVsSolutionBuildManager)); - var hr = buildManager.AdviseUpdateSolutionEvents(new LiveReloadBuildWatcher(), out var cookie); - Marshal.ThrowExceptionForHR(hr); - } } } diff --git a/tooling/Microsoft.VisualStudio.BlazorExtension/LiveReloadBuildWatcher.cs b/tooling/Microsoft.VisualStudio.BlazorExtension/LiveReloadBuildWatcher.cs deleted file mode 100644 index da487b4ed7..0000000000 --- a/tooling/Microsoft.VisualStudio.BlazorExtension/LiveReloadBuildWatcher.cs +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.VisualStudio.ProjectSystem.Properties; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using System; -using System.Collections.Generic; -using System.IO; - -namespace Microsoft.VisualStudio.BlazorExtension -{ - internal class LiveReloadBuildWatcher : IVsUpdateSolutionEvents2 - { - const string BlazorProjectCapability = "Blazor"; - - private bool _isListeningForProjectBuilds = false; - private List _signalFilePathsToNotify = new List(); - - public int UpdateSolution_Begin(ref int pfCancelUpdate) - { - _signalFilePathsToNotify.Clear(); - _isListeningForProjectBuilds = true; - return VSConstants.S_OK; - } - - public int UpdateSolution_Done(int fSucceeded, int fModified, int fCancelCommand) - { - _isListeningForProjectBuilds = false; - - foreach (var fullPath in _signalFilePathsToNotify) - { - try - { - File.WriteAllText(fullPath, string.Empty); - File.Delete(fullPath); - } - catch (Exception ex) - { - AttemptLogError($"Blazor live reloading was unable to write to the signal " + - $"file at {fullPath}. To disable live reloading, set the property " + - $"'UseBlazorLiveReloading' to 'false' in your project file." + - $"\nThe exception was: {ex.Message}\n{ex.StackTrace}"); - } - } - - return VSConstants.S_OK; - } - - private void AttemptLogError(string message) - { - ThreadHelper.ThrowIfNotOnUIThread(); - var outputWindow = (IVsOutputWindow)Package.GetGlobalService(typeof(SVsOutputWindow)); - if (outputWindow != null) - { - outputWindow.GetPane(VSConstants.OutputWindowPaneGuid.BuildOutputPane_guid, out var pane); - if (pane != null) - { - pane.OutputString(message); - pane.Activate(); - } - } - } - - public int UpdateSolution_StartUpdate(ref int pfCancelUpdate) - => VSConstants.S_OK; - - public int UpdateSolution_Cancel() - => VSConstants.S_OK; - - public int OnActiveProjectCfgChange(IVsHierarchy pIVsHierarchy) - => VSConstants.S_OK; - - public int UpdateProjectCfg_Begin(IVsHierarchy pHierProj, IVsCfg pCfgProj, IVsCfg pCfgSln, uint dwAction, ref int pfCancel) - => VSConstants.S_OK; - - public int UpdateProjectCfg_Done(IVsHierarchy pHierProj, IVsCfg pCfgProj, IVsCfg pCfgSln, uint dwAction, int fSuccess, int fCancel) - { - if (_isListeningForProjectBuilds - && fSuccess == 1 // i.e., build succeeded - && pHierProj.IsCapabilityMatch(BlazorProjectCapability)) - { - var configuredProject = ((IVsBrowseObjectContext)pCfgProj).ConfiguredProject; - var projectLockService = configuredProject - .UnconfiguredProject - .ProjectService - .Services - .ProjectLockService; - - ThreadHelper.JoinableTaskFactory.Run(async delegate - { - using (var access = await projectLockService.ReadLockAsync()) - { - var project = await access.GetProjectAsync(configuredProject); - - // Now we can evaluate MSBuild properties - var useLiveReloading = project.GetPropertyValue("UseBlazorLiveReloading"); - var projectDir = project.GetPropertyValue("ProjectDir"); - var outputPath = project.GetPropertyValue("OutputPath"); - var signalFilePath = project.GetPropertyValue("BlazorBuildCompletedSignalPath"); - if (string.Equals(useLiveReloading, "true", StringComparison.Ordinal) - && !string.IsNullOrEmpty(projectDir) - && !string.IsNullOrEmpty(outputPath) - && !string.IsNullOrEmpty(signalFilePath)) - { - var fullPath = Path.Combine( - projectDir, - outputPath, - signalFilePath); - _signalFilePathsToNotify.Add(fullPath); - } - } - }); - } - - return VSConstants.S_OK; - } - } -} diff --git a/tooling/Microsoft.VisualStudio.BlazorExtension/Microsoft.VisualStudio.BlazorExtension.csproj b/tooling/Microsoft.VisualStudio.BlazorExtension/Microsoft.VisualStudio.BlazorExtension.csproj index db47e2e98a..5f9967ee0f 100644 --- a/tooling/Microsoft.VisualStudio.BlazorExtension/Microsoft.VisualStudio.BlazorExtension.csproj +++ b/tooling/Microsoft.VisualStudio.BlazorExtension/Microsoft.VisualStudio.BlazorExtension.csproj @@ -4,7 +4,6 @@ 15.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) true - false false @@ -164,7 +163,6 @@ false - - - - + - - - + false - - - - <_GeneratedVSIXAssemblyInfoInputsCacheFile>$(IntermediateOutputPath)$(MSBuildProjectName).VSIXAssemblyInfo.cache.txt