Skip to content

Commit

Permalink
Merge pull request #5 from stavroskasidis/release/1.3
Browse files Browse the repository at this point in the history
Release/1.3
  • Loading branch information
stavroskasidis authored Feb 9, 2022
2 parents d9e2fa9 + 223fcc0 commit 3433c01
Show file tree
Hide file tree
Showing 52 changed files with 1,715 additions and 19 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ This package injects some custom MSBuild tasks that do the following:
```
dotnet add package BlazorWasmAntivirusProtection
```
2. (Progressive Web Application Only): If you are using the Blazor Wasm PWA template, update the following line in your `service-worker.published.js` file to include `.bin` files:

2. Publish your app in Release mode and test it!
```js
const offlineAssetsInclude = [/\.bin$/, /\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/, /\.blat$/, /\.dat$/ ];
```

3. Publish your app in Release mode and test it!
```
dotnet publish Server\BlazorHostedSampleApp.Server.csproj -c Release
```
Expand Down Expand Up @@ -62,7 +67,13 @@ This work was inspired by the post in https://github.com/dotnet/aspnetcore/issue

## Release Notes

<details open="open"><summary>1.2</summary>
<details open="open"><summary>1.3</summary>

>- Added support for Blazor Wasm PWA apps
</details>

<details><summary>1.2</summary>

>- Fixed sequential publishing issue.
</details>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<!--<RunAOTCompilation>true</RunAOTCompilation>-->
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RestoreAdditionalProjectSources>
Expand All @@ -15,7 +16,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.1" PrivateAssets="all" />
<PackageReference Include="BlazorWasmAntivirusProtection" Version="1.2.0-beta" />
<PackageReference Include="BlazorWasmAntivirusProtection" Version="1.3.0-beta" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.1" />
<PackageReference Include="BlazorWasmAntivirusProtection" Version="1.2.0-beta" />
<PackageReference Include="BlazorWasmAntivirusProtection" Version="1.3.0-beta" />
</ItemGroup>

<ItemGroup>
Expand Down
64 changes: 64 additions & 0 deletions sampleapps/BlazorHostedSamplePwa/BlazorHostedSamplePwa.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.0.0
MinimumVisualStudioVersion = 16.0.0.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorHostedSamplePwa.Server", "Server\BlazorHostedSamplePwa.Server.csproj", "{5435B7A0-4ABC-4EFB-9AEA-B1857DD833E6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorHostedSamplePwa.Client", "Client\BlazorHostedSamplePwa.Client.csproj", "{B7F7E73A-DF74-4A2C-8ACF-B448D0FA4510}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorHostedSamplePwa.Shared", "Shared\BlazorHostedSamplePwa.Shared.csproj", "{8BC0E9D0-71BE-4CB8-A1E7-5A47C7A0C872}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B7F7E73A-DF74-4A2C-8ACF-B448D0FA4510}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7F7E73A-DF74-4A2C-8ACF-B448D0FA4510}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7F7E73A-DF74-4A2C-8ACF-B448D0FA4510}.Debug|x64.ActiveCfg = Debug|Any CPU
{B7F7E73A-DF74-4A2C-8ACF-B448D0FA4510}.Debug|x64.Build.0 = Debug|Any CPU
{B7F7E73A-DF74-4A2C-8ACF-B448D0FA4510}.Debug|x86.ActiveCfg = Debug|Any CPU
{B7F7E73A-DF74-4A2C-8ACF-B448D0FA4510}.Debug|x86.Build.0 = Debug|Any CPU
{B7F7E73A-DF74-4A2C-8ACF-B448D0FA4510}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7F7E73A-DF74-4A2C-8ACF-B448D0FA4510}.Release|Any CPU.Build.0 = Release|Any CPU
{B7F7E73A-DF74-4A2C-8ACF-B448D0FA4510}.Release|x64.ActiveCfg = Release|Any CPU
{B7F7E73A-DF74-4A2C-8ACF-B448D0FA4510}.Release|x64.Build.0 = Release|Any CPU
{B7F7E73A-DF74-4A2C-8ACF-B448D0FA4510}.Release|x86.ActiveCfg = Release|Any CPU
{B7F7E73A-DF74-4A2C-8ACF-B448D0FA4510}.Release|x86.Build.0 = Release|Any CPU
{5435B7A0-4ABC-4EFB-9AEA-B1857DD833E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5435B7A0-4ABC-4EFB-9AEA-B1857DD833E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5435B7A0-4ABC-4EFB-9AEA-B1857DD833E6}.Debug|x64.ActiveCfg = Debug|Any CPU
{5435B7A0-4ABC-4EFB-9AEA-B1857DD833E6}.Debug|x64.Build.0 = Debug|Any CPU
{5435B7A0-4ABC-4EFB-9AEA-B1857DD833E6}.Debug|x86.ActiveCfg = Debug|Any CPU
{5435B7A0-4ABC-4EFB-9AEA-B1857DD833E6}.Debug|x86.Build.0 = Debug|Any CPU
{5435B7A0-4ABC-4EFB-9AEA-B1857DD833E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5435B7A0-4ABC-4EFB-9AEA-B1857DD833E6}.Release|Any CPU.Build.0 = Release|Any CPU
{5435B7A0-4ABC-4EFB-9AEA-B1857DD833E6}.Release|x64.ActiveCfg = Release|Any CPU
{5435B7A0-4ABC-4EFB-9AEA-B1857DD833E6}.Release|x64.Build.0 = Release|Any CPU
{5435B7A0-4ABC-4EFB-9AEA-B1857DD833E6}.Release|x86.ActiveCfg = Release|Any CPU
{5435B7A0-4ABC-4EFB-9AEA-B1857DD833E6}.Release|x86.Build.0 = Release|Any CPU
{8BC0E9D0-71BE-4CB8-A1E7-5A47C7A0C872}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8BC0E9D0-71BE-4CB8-A1E7-5A47C7A0C872}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8BC0E9D0-71BE-4CB8-A1E7-5A47C7A0C872}.Debug|x64.ActiveCfg = Debug|Any CPU
{8BC0E9D0-71BE-4CB8-A1E7-5A47C7A0C872}.Debug|x64.Build.0 = Debug|Any CPU
{8BC0E9D0-71BE-4CB8-A1E7-5A47C7A0C872}.Debug|x86.ActiveCfg = Debug|Any CPU
{8BC0E9D0-71BE-4CB8-A1E7-5A47C7A0C872}.Debug|x86.Build.0 = Debug|Any CPU
{8BC0E9D0-71BE-4CB8-A1E7-5A47C7A0C872}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8BC0E9D0-71BE-4CB8-A1E7-5A47C7A0C872}.Release|Any CPU.Build.0 = Release|Any CPU
{8BC0E9D0-71BE-4CB8-A1E7-5A47C7A0C872}.Release|x64.ActiveCfg = Release|Any CPU
{8BC0E9D0-71BE-4CB8-A1E7-5A47C7A0C872}.Release|x64.Build.0 = Release|Any CPU
{8BC0E9D0-71BE-4CB8-A1E7-5A47C7A0C872}.Release|x86.ActiveCfg = Release|Any CPU
{8BC0E9D0-71BE-4CB8-A1E7-5A47C7A0C872}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4E845253-BA86-490C-A5FC-EF514B4DF5BA}
EndGlobalSection
EndGlobal
12 changes: 12 additions & 0 deletions sampleapps/BlazorHostedSamplePwa/Client/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RestoreAdditionalProjectSources>
$(RestoreAdditionalProjectSources);
$(MSBuildThisFileDirectory)../../../artifacts/nuget
</RestoreAdditionalProjectSources>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.2" PrivateAssets="all" />
<PackageReference Include="BlazorWasmAntivirusProtection" Version="1.3.0-beta" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Shared\BlazorHostedSamplePwa.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
</ItemGroup>

</Project>
18 changes: 18 additions & 0 deletions sampleapps/BlazorHostedSamplePwa/Client/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@page "/counter"

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p role="status">Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
}
47 changes: 47 additions & 0 deletions sampleapps/BlazorHostedSamplePwa/Client/Pages/FetchData.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@page "/fetchdata"
@using BlazorHostedSamplePwa.Shared
@inject HttpClient Http

<PageTitle>Weather forecast</PageTitle>

<h1>Weather forecast</h1>

<p>This component demonstrates fetching data from the server.</p>

@if (forecasts == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}

@code {
private WeatherForecast[]? forecasts;

protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("WeatherForecast");
}
}
9 changes: 9 additions & 0 deletions sampleapps/BlazorHostedSamplePwa/Client/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@page "/"

<PageTitle>Index</PageTitle>

<h1>Hello, world!</h1>

Welcome to your new app.

<SurveyPrompt Title="How is Blazor working for you?" />
11 changes: 11 additions & 0 deletions sampleapps/BlazorHostedSamplePwa/Client/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using BlazorHostedSamplePwa.Client;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

await builder.Build().RunAsync();
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:18019",
"sslPort": 44389
}
},
"profiles": {
"BlazorHostedSamplePwa": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:7042;http://localhost:5041",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
17 changes: 17 additions & 0 deletions sampleapps/BlazorHostedSamplePwa/Client/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@inherits LayoutComponentBase

<div class="page">
<div class="sidebar">
<NavMenu />
</div>

<main>
<div class="top-row px-4">
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
</div>

<article class="content px-4">
@Body
</article>
</main>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
.page {
position: relative;
display: flex;
flex-direction: column;
}

main {
flex: 1;
}

.sidebar {
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}

.top-row {
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
height: 3.5rem;
display: flex;
align-items: center;
}

.top-row ::deep a, .top-row ::deep .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
text-decoration: none;
}

.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
text-decoration: underline;
}

.top-row ::deep a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}

@media (max-width: 640.98px) {
.top-row:not(.auth) {
display: none;
}

.top-row.auth {
justify-content: space-between;
}

.top-row ::deep a, .top-row ::deep .btn-link {
margin-left: 0;
}
}

@media (min-width: 641px) {
.page {
flex-direction: row;
}

.sidebar {
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}

.top-row {
position: sticky;
top: 0;
z-index: 1;
}

.top-row.auth ::deep a:first-child {
flex: 1;
text-align: right;
width: 0;
}

.top-row, article {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}
Loading

0 comments on commit 3433c01

Please sign in to comment.