diff --git a/.github/workflows/GithubActionsRelease.yml b/.github/workflows/GithubActionsRelease.yml
index ac9d8a8..bfd7821 100644
--- a/.github/workflows/GithubActionsRelease.yml
+++ b/.github/workflows/GithubActionsRelease.yml
@@ -59,7 +59,7 @@ jobs:
- name: Use prelease dotnet
uses: actions/setup-dotnet@v2
with:
- dotnet-version: '7.0.x'
+ dotnet-version: '8.x'
include-prerelease: true
- name: Get the version
diff --git a/.github/workflows/GithubActionsWIP.yml b/.github/workflows/GithubActionsWIP.yml
index 20c44da..fdbe25d 100644
--- a/.github/workflows/GithubActionsWIP.yml
+++ b/.github/workflows/GithubActionsWIP.yml
@@ -38,7 +38,7 @@ jobs:
- name: Use prelease dotnet
uses: actions/setup-dotnet@v2
with:
- dotnet-version: '7.0.x'
+ dotnet-version: '8.x'
include-prerelease: true
- name: Build CompressedStaticFiles.AspNetCore 🔧
diff --git a/.gitignore b/.gitignore
index d91ff1c..abad702 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,8 @@
bld/
[Bb]in/
[Oo]bj/
+.artifacts/
+PublishedExample/
# Visual Studio 2015 cache/options directory
.vs/
diff --git a/CompressedStaticFiles.AspNet.Tests/CompressedStaticFiles.AspNet.Tests.csproj b/CompressedStaticFiles.AspNet.Tests/CompressedStaticFiles.AspNet.Tests.csproj
index b1b1f41..1ed723f 100644
--- a/CompressedStaticFiles.AspNet.Tests/CompressedStaticFiles.AspNet.Tests.csproj
+++ b/CompressedStaticFiles.AspNet.Tests/CompressedStaticFiles.AspNet.Tests.csproj
@@ -1,22 +1,21 @@

+ To demonstrate the compressed files execute the 'LocalBuild.cmd' at the root of this repository and follow + the instructions to browse to the demonstration. +
Press F12 to enter your browser's development tools and select the network tab (we did this on Edge here). Click any css or js file (except for blazor.server.js, which as an ASP.NET framework file isn't compressed) @@ -43,71 +47,12 @@
- <PropertyGroup>
- <!--Paths to tools, tasks, and extensions are calculated relative to the BlazorWebAssemblySdkDirectoryRoot.
- But there does not seem to be a property for that, so after much trial and error, using the property
- ILLinkTasksAssembly seems most reliable as it contains the same value whether the build is run from VS
- or the command line, unlike many others such as MSBuildSDKsPath.
- If a better property is identified, this can be changed.
- -->
-
- <!-- First, we strip the property value back to the root SDKs level and then down into the WebAssembly SDK -->
- <_SDKRoot>$(ILLinkTasksAssembly.Substring(0,$(ILLinkTasksAssembly.LastIndexOf('Microsoft.NET.ILLink.Tasks'))))</_SDKRoot>
- <BlazorWebAssemblySdkDirectoryRoot>$(_SDKRoot)\Microsoft.NET.Sdk.BlazorWebAssembly\</BlazorWebAssemblySdkDirectoryRoot>
-
- <!-- The next four lines are Copyright (c) .NET Foundation. All rights reserved. -->
- <_BlazorWebAssemblySdkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core'">net6.0</_BlazorWebAssemblySdkTasksTFM>
- <_BlazorWebAssemblySdkTasksTFM Condition=" '$(MSBuildRuntimeType)' != 'Core'">net472</_BlazorWebAssemblySdkTasksTFM>
- <_BlazorWebAssemblySdkTasksAssembly>$(BlazorWebAssemblySdkDirectoryRoot)tools\$(_BlazorWebAssemblySdkTasksTFM)\Microsoft.NET.Sdk.BlazorWebAssembly.Tasks.dll</_BlazorWebAssemblySdkTasksAssembly>
- <_BlazorWebAssemblySdkToolAssembly>$(BlazorWebAssemblySdkDirectoryRoot)tools\net6.0\Microsoft.NET.Sdk.BlazorWebAssembly.Tool.dll</_BlazorWebAssemblySdkToolAssembly>
- </PropertyGroup>
-
- <!-- The next two lines are Copyright (c) .NET Foundation. All rights reserved. -->
- <UsingTask TaskName="Microsoft.NET.Sdk.BlazorWebAssembly.BrotliCompress" AssemblyFile="$(_BlazorWebAssemblySdkTasksAssembly)" />
- <UsingTask TaskName="Microsoft.NET.Sdk.BlazorWebAssembly.GzipCompress" AssemblyFile="$(_BlazorWebAssemblySdkTasksAssembly)" />
-
-
-
-
- <!--
- This target runs after build. If you want to run after Publish, change:
- - AfterTargets should be set to "Build"
- - "ProjectDir" in MyStaticFiles should be changed to "PublishDir"
- -->
- <Target Name="CustomGZipAndBrotliCompression" AfterTargets="Build">
-
- <!--************* THIS IS WHERE YOU CHOOSE WHAT TO COMPRESS *****************
- you probably don't want to change anything else - just this ItemGroup-->
-
- <ItemGroup>
- <MyStaticFiles Include="$(ProjectDir)/wwwroot/**/*.css" />
- <MyStaticFiles Include="$(ProjectDir)/wwwroot/**/*.js" />
- </ItemGroup>
-
- <!--Call the BlazorWebAssembly Task GZipCompress and store the results in MyCompressedFiles-->
- <GZipCompress FilesToCompress="@@(MyStaticFiles)" OutputDirectory="$(IntermediateOutputPath)compress\">
- <Output TaskParameter="CompressedFiles" ItemName="MyCompressedFiles" />
- </GZipCompress>
-
- <!--Call the BlazorWebAssembly Task BrotliCompress and store the results in MyCompressedFiles-->
- <BrotliCompress OutputDirectory="$(IntermediateOutputPath)compress\" FilesToCompress="@@(MyStaticFiles)" ToolAssembly="$(_BlazorWebAssemblySdkToolAssembly)" ToolExe="$(_RazorSdkDotNetHostFileName)" ToolPath="$(_RazorSdkDotNetHostDirectory)">
- <Output TaskParameter="CompressedFiles" ItemName="MyCompressedFiles" />
- </BrotliCompress>
-
- <!--Log what we have done-->
- <Message Importance="High" Text="======= Brotli/GZip Compression For @@(MyCompressedFiles->Count()) Static Files =======" />
- <Message Importance="High" Text=" Compressed: %(MyCompressedFiles.OriginalItemSpec)%(MyCompressedFiles.Extension)" />
-
- <!--Rename/move the compressed files back to to the correct place/names as they have "hashed" names at this stage.-->
- <Move SourceFiles="%(MyCompressedFiles.FullPath)" DestinationFiles="%(MyCompressedFiles.OriginalItemSpec)%(MyCompressedFiles.Extension)" />
-
- </Target>
- <ItemGroup>
- <ProjectReference Include="..\CompressedStaticFiles.AspNetCore\CompressedStaticFiles.AspNetCore.csproj" />
- </ItemGroup>
- <ItemGroup>
- <Folder Include="wwwroot\images\" />
- </ItemGroup>
+
+ <PropertyGroup>
+ <CompressionIncludePatterns>$(CompressionIncludePatterns);**/*.css;**/*.js</CompressionIncludePatterns>
+ <BuildCompressionFormats>gzip;brotli</BuildCompressionFormats>
+ <PublishCompressionFormats>gzip;brotli</<PublishCompressionFormats>
+ </PropertyGroup>
Thanks to the following: