Created
February 23, 2022 17:04
-
-
Save IvanJosipovic/ecb406afd172b40e4a3c8c42d43d8583 to your computer and use it in GitHub Desktop.
Blazor WASM Cache Bust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | |
| <title>MyApp</title> | |
| <base href="/" /> | |
| <link href="_content/MudBlazor/MudBlazor.min.css?t={{time}}" rel="stylesheet" /> | |
| <link href="css/app.css?t={{time}}" rel="stylesheet" /> | |
| <link href="MyApp.Client.styles.css?t={{time}}" rel="stylesheet" /> | |
| <link rel="icon" type="image/x-icon" href="images/heroic-T-favicon.png"> | |
| </head> | |
| <body> | |
| <div id="app"> | |
| </div> | |
| <div id="blazor-error-ui"> | |
| An unhandled error has occurred. | |
| <a href="" class="reload">Reload</a> | |
| <a class="dismiss">🗙</a> | |
| </div> | |
| <script src="_content/MudBlazor/MudBlazor.min.js?t={{time}}"></script> | |
| <script src="_framework/blazor.webassembly.js?t={{time}}"></script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Project Sdk="Microsoft.NET.Sdk.Web"> | |
| <PropertyGroup> | |
| <TargetFramework>net6.0</TargetFramework> | |
| </PropertyGroup> | |
| <ItemGroup> | |
| <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.2" /> | |
| </ItemGroup> | |
| <UsingTask TaskName="ReplaceFileText" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"> | |
| <ParameterGroup> | |
| <InputFilename ParameterType="System.String" Required="true" /> | |
| <MatchExpression ParameterType="System.String" Required="true" /> | |
| <ReplacementText ParameterType="System.String" Required="true" /> | |
| </ParameterGroup> | |
| <Task> | |
| <Code Type="Fragment" Language="cs"> | |
| <![CDATA[ | |
| System.IO.File.WriteAllText(InputFilename, System.Text.RegularExpressions.Regex.Replace(File.ReadAllText(InputFilename), MatchExpression, ReplacementText)); | |
| ]]> | |
| </Code> | |
| </Task> | |
| </UsingTask> | |
| <Target Name="AddTimeStamp" AfterTargets="Publish"> | |
| <ReplaceFileText | |
| InputFilename="$(PublishDir)wwwroot\index.html" | |
| MatchExpression="{{time}}" | |
| ReplacementText="$([System.DateTime]::Now.ToString(yyyy-MM-dd-hh-mm-ss))" /> | |
| </Target> | |
| </Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment