diff --git a/sampleapps/BlazorHostedSampleApp/.dockerignore b/sampleapps/BlazorHostedSampleApp/.dockerignore new file mode 100644 index 0000000..3729ff0 --- /dev/null +++ b/sampleapps/BlazorHostedSampleApp/.dockerignore @@ -0,0 +1,25 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md \ No newline at end of file diff --git a/sampleapps/BlazorHostedSampleApp/Client/BlazorHostedSampleApp.Client.csproj b/sampleapps/BlazorHostedSampleApp/Client/BlazorHostedSampleApp.Client.csproj index 183e33f..bacdfb1 100644 --- a/sampleapps/BlazorHostedSampleApp/Client/BlazorHostedSampleApp.Client.csproj +++ b/sampleapps/BlazorHostedSampleApp/Client/BlazorHostedSampleApp.Client.csproj @@ -21,7 +21,7 @@ - + diff --git a/sampleapps/BlazorHostedSampleApp/Server/BlazorHostedSampleApp.Server.csproj b/sampleapps/BlazorHostedSampleApp/Server/BlazorHostedSampleApp.Server.csproj index c313d4b..0b1c37a 100644 --- a/sampleapps/BlazorHostedSampleApp/Server/BlazorHostedSampleApp.Server.csproj +++ b/sampleapps/BlazorHostedSampleApp/Server/BlazorHostedSampleApp.Server.csproj @@ -8,6 +8,8 @@ $(RestoreAdditionalProjectSources); $(MSBuildThisFileDirectory)../../../artifacts/nuget + ab18ecad-eb5a-4dc2-bcd9-12a62054d7f0 + Linux @@ -15,6 +17,7 @@ + diff --git a/sampleapps/BlazorHostedSampleApp/Server/Dockerfile b/sampleapps/BlazorHostedSampleApp/Server/Dockerfile new file mode 100644 index 0000000..77045d2 --- /dev/null +++ b/sampleapps/BlazorHostedSampleApp/Server/Dockerfile @@ -0,0 +1,24 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +WORKDIR /src +COPY ["Server/BlazorHostedSampleApp.Server.csproj", "Server/"] +COPY ["Client/BlazorHostedSampleApp.Client.csproj", "Client/"] +COPY ["Shared/BlazorHostedSampleApp.Shared.csproj", "Shared/"] +RUN dotnet restore "Server/BlazorHostedSampleApp.Server.csproj" +COPY . . +WORKDIR "/src/Server" +RUN dotnet build "BlazorHostedSampleApp.Server.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "BlazorHostedSampleApp.Server.csproj" -c Release -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "BlazorHostedSampleApp.Server.dll"] \ No newline at end of file diff --git a/sampleapps/BlazorHostedSampleApp/Server/Properties/launchSettings.json b/sampleapps/BlazorHostedSampleApp/Server/Properties/launchSettings.json index e0f8a5c..1b1e8a7 100644 --- a/sampleapps/BlazorHostedSampleApp/Server/Properties/launchSettings.json +++ b/sampleapps/BlazorHostedSampleApp/Server/Properties/launchSettings.json @@ -1,30 +1,37 @@ { - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:55913", - "sslPort": 44338 - } + "profiles": { + "BlazorHostedSampleApp.Server": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "https://localhost:7107;http://localhost:5266" }, - "profiles": { - "BlazorHostedSampleApp.Server": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", - "applicationUrl": "https://localhost:7107;http://localhost:5266", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "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" - } - } + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}" + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "publishAllPorts": true, + "useSSL": true + } + }, + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:55913", + "sslPort": 44338 } } +} \ No newline at end of file diff --git a/src/BlazorWasmAntivirusProtection.Tasks/RenameDlls.cs b/src/BlazorWasmAntivirusProtection.Tasks/RenameDlls.cs index dd1db3e..fc13c11 100644 --- a/src/BlazorWasmAntivirusProtection.Tasks/RenameDlls.cs +++ b/src/BlazorWasmAntivirusProtection.Tasks/RenameDlls.cs @@ -81,12 +81,18 @@ public override bool Execute() if (File.Exists(bootJsonGzPath) && BlazorEnableCompression) { Log.LogMessage(MessageImportance.High, $"BlazorWasmAntivirusProtection: Recompressing \"{bootJsonGzPath}\""); - GZipCompress(bootJsonPath, bootJsonGzPath); + if(!GZipCompress(bootJsonPath, bootJsonGzPath)) + { + return false; + } } if (File.Exists(bootJsonBrPath) && BlazorEnableCompression) { Log.LogMessage(MessageImportance.High, $"BlazorWasmAntivirusProtection: Recompressing \"{bootJsonBrPath}\""); - BrotliCompress(bootJsonPath, bootJsonBrPath); + if(!BrotliCompress(bootJsonPath, bootJsonBrPath)) + { + return false; + } } } @@ -95,7 +101,7 @@ public override bool Execute() return true; } - private void GZipCompress(string bootJsonPath, string bootJsonGzPath) + private bool GZipCompress(string bootJsonPath, string bootJsonGzPath) { try { @@ -107,11 +113,17 @@ private void GZipCompress(string bootJsonPath, string bootJsonGzPath) } catch (Exception ex) { - Log.LogErrorFromException(ex); + if (File.Exists(bootJsonGzPath)) + { + File.Delete(bootJsonGzPath); + } + Log.LogErrorFromException(ex, true, true, null); + return false; } + return true; } - private void BrotliCompress(string bootJsonPath, string bootJsonBrPath) + private bool BrotliCompress(string bootJsonPath, string bootJsonBrPath) { try { @@ -128,8 +140,14 @@ private void BrotliCompress(string bootJsonPath, string bootJsonBrPath) } catch (Exception ex) { - Log.LogErrorFromException(ex); + if (File.Exists(bootJsonBrPath)) + { + File.Delete(bootJsonBrPath); + } + Log.LogErrorFromException(ex, true, true, null); + return false; } + return true; } string ComputeSha256Hash(string rawData) diff --git a/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj b/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj index c4a31f3..1917960 100644 --- a/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj +++ b/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj @@ -11,7 +11,7 @@ https://github.com/stavroskasidis/BlazorWasmAntivirusProtection This package attempts to guard against false positives from antiviruses that flag Blazor Wasm as malware $(VersionSuffix) - 2.2.1 + 2.2.2 $(Version)-$(VersionSuffix)