Skip to content

Commit

Permalink
Revert live reloading implementation. See PR for explanation.
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveSandersonMS committed Apr 4, 2018
1 parent 2afcb9c commit 1fde187
Show file tree
Hide file tree
Showing 25 changed files with 10 additions and 715 deletions.
11 changes: 0 additions & 11 deletions Blazor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Boot.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 <script> tag.
// In production, this should not be the case.
const reloadUri = thisScriptElem.getAttribute('reload');
if (reloadUri) {
enableLiveReloading(reloadUri);
}
}

function getRequiredBootScriptAttribute(elem: HTMLScriptElement, attributeName: string): string {
Expand Down
92 changes: 0 additions & 92 deletions src/Microsoft.AspNetCore.Blazor.Browser.JS/src/LiveReloading.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ public static void Command(CommandLineApplication command)
"Adds a <link rel=stylesheet> tag with the specified 'href' value",
CommandOptionType.MultipleValue);

var reloadUri = command.Option("--reload-uri",
"If specified, enables live reloading and specifies the URI of the notification endpoint.",
CommandOptionType.SingleValue);

var outputPath = command.Option("--output",
"Path to the output file",
CommandOptionType.SingleValue);
Expand Down Expand Up @@ -59,7 +55,6 @@ public static void Command(CommandLineApplication command)
jsReferences.Values.ToArray(),
cssReferences.Values.ToArray(),
linkerEnabledFlag.HasValue(),
reloadUri.Value(),
outputPath.Value());
return 0;
}
Expand Down
17 changes: 4 additions & 13 deletions src/Microsoft.AspNetCore.Blazor.Build/Core/IndexHtmlWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public static void UpdateIndex(
IEnumerable<string> jsReferences,
IEnumerable<string> cssReferences,
bool linkerEnabled,
string reloadUri,
string outputPath)
{
var template = GetTemplate(path);
Expand All @@ -32,7 +31,7 @@ public static void UpdateIndex(
}
var assemblyName = Path.GetFileNameWithoutExtension(assemblyPath);
var entryPoint = GetAssemblyEntryPoint(assemblyPath);
var updatedContent = GetIndexHtmlContents(template, assemblyName, entryPoint, assemblyReferences, jsReferences, cssReferences, linkerEnabled, reloadUri);
var updatedContent = GetIndexHtmlContents(template, assemblyName, entryPoint, assemblyReferences, jsReferences, cssReferences, linkerEnabled);
var normalizedOutputPath = Normalize(outputPath);
Console.WriteLine("Writing index to: " + normalizedOutputPath);
File.WriteAllText(normalizedOutputPath, updatedContent);
Expand Down Expand Up @@ -104,8 +103,7 @@ public static string GetIndexHtmlContents(
IEnumerable<string> assemblyReferences,
IEnumerable<string> jsReferences,
IEnumerable<string> cssReferences,
bool linkerEnabled,
string reloadUri)
bool linkerEnabled)
{
var resultBuilder = new StringBuilder();

Expand Down Expand Up @@ -146,8 +144,7 @@ public static string GetIndexHtmlContents(
assemblyEntryPoint,
assemblyReferences,
linkerEnabled,
tag.Attributes,
reloadUri);
tag.Attributes);

// Emit tags to reference any specified JS/CSS files
AppendReferenceTags(
Expand Down Expand Up @@ -209,8 +206,7 @@ private static void AppendScriptTagWithBootConfig(
string assemblyEntryPoint,
IEnumerable<string> binFiles,
bool linkerEnabled,
List<KeyValuePair<string, string>> attributes,
string reloadUri)
List<KeyValuePair<string, string>> attributes)
{
var assemblyNameWithExtension = $"{assemblyName}.dll";

Expand All @@ -232,11 +228,6 @@ private static void AppendScriptTagWithBootConfig(
attributesDict.Remove("linker-enabled");
}

if (!string.IsNullOrEmpty(reloadUri))
{
attributesDict["reload"] = reloadUri;
}

resultBuilder.Append("<script");
foreach (var attributePair in attributesDict)
{
Expand Down
9 changes: 0 additions & 9 deletions src/Microsoft.AspNetCore.Blazor.Build/targets/All.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,7 @@
<PropertyGroup>
<DefaultWebContentItemExcludes>$(DefaultWebContentItemExcludes);wwwroot\**</DefaultWebContentItemExcludes>

<!-- By default, live reloading is on for debug builds -->
<UseBlazorLiveReloading Condition="'$(Configuration)' == 'Debug'">true</UseBlazorLiveReloading>
<BlazorLiveReloadUri>/_reload</BlazorLiveReloadUri>

<!-- We can remove this after updating to newer Razor tooling, where it's enabled by default -->
<UseRazorBuildServer>true</UseRazorBuildServer>
</PropertyGroup>

<ItemGroup>
<!-- In case you're using 'dotnet watch', enable reloading when editing .cshtml files -->
<Watch Include="$(ProjectDir)**\*.cshtml" />
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion src/Microsoft.AspNetCore.Blazor.Build/targets/All.targets
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
</PropertyGroup>
<WriteLinesToFile File="$(BlazorMetadataFilePath)" Lines="$(MSBuildProjectFullPath)" Overwrite="true" Encoding="Unicode"/>
<WriteLinesToFile File="$(BlazorMetadataFilePath)" Lines="$(OutDir)$(AssemblyName).dll" Overwrite="false" Encoding="Unicode"/>
<WriteLinesToFile File="$(BlazorMetadataFilePath)" Condition="'$(UseBlazorLiveReloading)'=='true'" Lines="reload:$(BlazorLiveReloadUri)" Overwrite="false" Encoding="Unicode"/>
<ItemGroup>
<ContentWithTargetPath Include="$(BlazorMetadataFilePath)" TargetPath="$(BlazorMetadataFileName)" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<BlazorWebRootName>wwwroot/</BlazorWebRootName>
<BlazorIndexHtmlName>Index.html</BlazorIndexHtmlName>
<BlazorOutputIndexHtmlName>$(BlazorIndexHtmlName.ToLowerInvariant())</BlazorOutputIndexHtmlName>
<BlazorBuildCompletedSignalPath>$(BaseBlazorDistPath)__blazorBuildCompleted</BlazorBuildCompletedSignalPath>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
<ItemGroup>
<FileWrites Include="@(BlazorItemOutput->'%(TargetOutputPath)')" />
</ItemGroup>
<PropertyGroup>
<_BlazorDidCopyFilesToOutputDirectory>true</_BlazorDidCopyFilesToOutputDirectory>
</PropertyGroup>
</Target>

<Target Name="_BlazorTrackResolveReferencesDidRun" AfterTargets="ResolveReferences">
Expand All @@ -50,21 +47,6 @@
<Message Importance="$(_BlazorStatisticsReportImportance)" Text="%(_BlazorStatisticsOutput.Identity)" />
</Target>

<!--
We only issue the reload notification from here if you're *not* building inside VS.
If you are building inside VS, then it's possible you're building an arbitrary collection
of projects of which this is just one, and it's important to wait until all projects in
the build are completed before reloading, so the notification is instead triggered by the
VS extension that can see when a complete build process is finished.
-->
<Target Name="_BlazorIssueLiveReloadNotification"
AfterTargets="Build"
Condition="'$(UseBlazorLiveReloading)'=='true' AND '$(_BlazorDidCopyFilesToOutputDirectory)'=='true' AND '$(BuildingInsideVisualStudio)'!='true'">
<!-- Touch the signal file to trigger a reload -->
<WriteLinesToFile File="$(ProjectDir)$(OutputPath)$(BlazorBuildCompletedSignalPath)" Lines="_" />
<Delete Files="$(ProjectDir)$(OutputPath)$(BlazorBuildCompletedSignalPath)" />
</Target>

<!-- Preparing blazor files for output:
PrepareBlazorOutputs
_PrepareBlazorOutputConfiguration
Expand All @@ -83,7 +65,6 @@
_TouchBlazorApplicationAssemblies
_GenerateBlazorIndexHtml
_BlazorCopyFilesToOutputDirectory
_BlazorIssueLiveReloadNotification
The process for doing builds goes as follows:
Produce a hash file with the Hash SDK task and write that hash to a marker file.
Expand Down Expand Up @@ -590,7 +571,6 @@
<BlazorIndexHtmlInput Include="@(BlazorPackageJsRef->'%(FullPath)')" />
<BlazorIndexHtmlInput Include="@(BlazorPackageCssRef->'%(FullPath)')" />
<BlazorIndexHtmlInput Include="@(_BlazorLinkingOption)" />
<BlazorIndexHtmlInput Include="$(BlazorLiveReloadUri)" Condition="'$(UseBlazorLiveReloading)'=='true'" />
</ItemGroup>

<WriteLinesToFile
Expand All @@ -617,10 +597,9 @@
</ItemGroup>
<PropertyGroup>
<_LinkerEnabledFlag Condition="'$(_BlazorShouldLinkApplicationAssemblies)' != ''">--linker-enabled</_LinkerEnabledFlag>
<_LiveReloadArg Condition="'$(UseBlazorLiveReloading)' == 'true' AND '$(BlazorLiveReloadUri)' != ''">--reload-uri "$(BlazorLiveReloadUri)"</_LiveReloadArg>
</PropertyGroup>

<Exec Command="$(BlazorBuildExe) build @(IntermediateAssembly) --html-page &quot;$(BlazorIndexHtml)&quot; @(_AppReferences->'--reference &quot;%(Identity)&quot;', ' ') @(_JsReferences->'--js &quot;%(Identity)&quot;', ' ') @(_CssReferences->'--css &quot;%(Identity)&quot;', ' ') $(_LinkerEnabledFlag) $(_LiveReloadArg) --output &quot;$(BlazorIndexHtmlOutputPath)&quot;" />
<Exec Command="$(BlazorBuildExe) build @(IntermediateAssembly) --html-page &quot;$(BlazorIndexHtml)&quot; @(_AppReferences->'--reference &quot;%(Identity)&quot;', ' ') @(_JsReferences->'--js &quot;%(Identity)&quot;', ' ') @(_CssReferences->'--css &quot;%(Identity)&quot;', ' ') $(_LinkerEnabledFlag) --output &quot;$(BlazorIndexHtmlOutputPath)&quot;" />

<ItemGroup Condition="Exists('$(BlazorIndexHtmlOutputPath)')">
<_BlazorIndex Include="$(BlazorIndexHtmlOutputPath)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,6 @@ public static void UseBlazor(
});
}

// Definitely don't open a listener for live reloading in production, even if the
// client app was compiled with live reloading enabled
if (env.IsDevelopment())
{
// Whether or not live reloading is actually enabled depends on the client config
// For release builds, it won't be (by default)
applicationBuilder.UseBlazorLiveReloading(config);
}

// Finally, use SPA fallback routing (serve default page for anything else,
// excluding /_framework/*)
applicationBuilder.MapWhen(IsNotFrameworkDir, childAppBuilder =>
Expand Down
11 changes: 0 additions & 11 deletions src/Microsoft.AspNetCore.Blazor.Server/BlazorConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ internal class BlazorConfig
public string SourceMSBuildPath { get; }
public string SourceOutputAssemblyPath { get; }
public string WebRootPath { get; }
public string ReloadUri { get; }
public string DistPath
=> Path.Combine(Path.GetDirectoryName(SourceOutputAssemblyPath), "dist");

Expand Down Expand Up @@ -42,16 +41,6 @@ private BlazorConfig(string assemblyPath)
{
WebRootPath = webRootPath;
}

const string reloadMarker = "reload:";
var reloadUri = configLines
.Where(line => line.StartsWith(reloadMarker, StringComparison.Ordinal))
.Select(line => line.Substring(reloadMarker.Length))
.FirstOrDefault();
if (!string.IsNullOrEmpty(reloadUri))
{
ReloadUri = reloadUri;
}
}
}
}
Loading

0 comments on commit 1fde187

Please sign in to comment.