Skip to content

Commit f2c05fd

Browse files
authored
2023-11-10 EoD Prep for 2.0 release (#37)
* 2023-11-10 EoD Prep for 2.0 release * 2023-11-14 2.0.0
1 parent 18e921e commit f2c05fd

File tree

12 files changed

+81
-142
lines changed

12 files changed

+81
-142
lines changed

.github/workflows/GithubActionsRelease.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- name: Use prelease dotnet
6060
uses: actions/setup-dotnet@v2
6161
with:
62-
dotnet-version: '7.0.x'
62+
dotnet-version: '8.x'
6363
include-prerelease: true
6464

6565
- name: Get the version

.github/workflows/GithubActionsWIP.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Use prelease dotnet
3939
uses: actions/setup-dotnet@v2
4040
with:
41-
dotnet-version: '7.0.x'
41+
dotnet-version: '8.x'
4242
include-prerelease: true
4343

4444
- name: Build CompressedStaticFiles.AspNetCore 🔧

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
bld/
2626
[Bb]in/
2727
[Oo]bj/
28+
.artifacts/
29+
PublishedExample/
2830

2931
# Visual Studio 2015 cache/options directory
3032
.vs/

CompressedStaticFiles.AspNet.Tests/CompressedStaticFiles.AspNet.Tests.csproj

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net7.0;</TargetFrameworks>
54
<IsTestProject>true</IsTestProject>
65
<IsPackable>false</IsPackable>
76
</PropertyGroup>
87

98
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.0.2" />
11-
<PackageReference Include="coverlet.collector" Version="3.2.0">
9+
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.0" />
10+
<PackageReference Include="coverlet.collector" Version="6.0.0">
1211
<PrivateAssets>all</PrivateAssets>
1312
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1413
</PackageReference>
15-
<PackageReference Include="FluentAssertions" Version="6.9.0" />
16-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
17-
<PackageReference Include="NSubstitute" Version="4.4.0" />
18-
<PackageReference Include="xunit" Version="2.4.2" />
19-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
14+
<PackageReference Include="FluentAssertions" Version="6.12.0" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23531-01" />
16+
<PackageReference Include="NSubstitute" Version="5.1.0" />
17+
<PackageReference Include="xunit" Version="2.6.1" />
18+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
2019
<PrivateAssets>all</PrivateAssets>
2120
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2221
</PackageReference>

CompressedStaticFiles.AspNet.sln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
99
.gitignore = .gitignore
1010
.github\ISSUE_TEMPLATE\bug_report.md = .github\ISSUE_TEMPLATE\bug_report.md
1111
.github\dependabot.yml = .github\dependabot.yml
12+
Directory.Build.props = Directory.Build.props
1213
.github\workflows\GithubActionsRelease.yml = .github\workflows\GithubActionsRelease.yml
1314
.github\workflows\GithubActionsWIP.yml = .github\workflows\GithubActionsWIP.yml
1415
LICENSE = LICENSE
16+
LocalBuild.cmd = LocalBuild.cmd
1517
README.md = README.md
1618
ReleaseNotes.md = ReleaseNotes.md
1719
EndProjectSection

CompressedStaticFiles.AspNet/CompressedStaticFiles.AspNet.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net7.0;</TargetFrameworks>
5-
<Version>1.0.0</Version>
4+
<Version>2.0.0</Version>
65
<Authors>Simon Ziegler;Mark Stega;Peter Andersson;Andrey Kudashkin;Mathias Raacke,Arian Kadkhoda</Authors>
76
<Company>Simon Ziegler;Mark Stega;Peter Andersson;Andrey Kudashkin;Mathias Raacke,Arian Kadkhoda</Company>
87
<Description>
Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
54
<Nullable>enable</Nullable>
65
<ImplicitUsings>enable</ImplicitUsings>
76
</PropertyGroup>
@@ -10,67 +9,11 @@
109
<ProjectReference Include="..\CompressedStaticFiles.AspNet\CompressedStaticFiles.AspNet.csproj" />
1110
</ItemGroup>
1211

13-
14-
<!--All subsequent code contributed by https://github.com/SQL-MisterMagoo-->
15-
12+
<!--Compression directives (Note that the patterns are relative to wwwroot)-->
1613
<PropertyGroup>
17-
<!--Paths to tools, tasks, and extensions are calculated relative to the BlazorWebAssemblySdkDirectoryRoot.
18-
But there does not seem to be a property for that, so after much trial and error, using the property
19-
ILLinkTasksAssembly seems most reliable as it contains the same value whether the build is run from VS
20-
or the command line, unlike many others such as MSBuildSDKsPath.
21-
If a better property is identified, this can be changed.
22-
-->
23-
24-
<!-- First, we strip the property value back to the root SDKs level and then down into the WebAssembly SDK -->
25-
<_SDKRoot>$(ILLinkTasksAssembly.Substring(0,$(ILLinkTasksAssembly.LastIndexOf('Microsoft.NET.ILLink.Tasks'))))</_SDKRoot>
26-
<BlazorWebAssemblySdkDirectoryRoot>$(_SDKRoot)Microsoft.NET.Sdk.BlazorWebAssembly\</BlazorWebAssemblySdkDirectoryRoot>
27-
28-
<!-- The next two lines are derived from examples posted by the .NET Foundation. -->
29-
<_BlazorWebAssemblySdkTasksAssembly>$(BlazorWebAssemblySdkDirectoryRoot)tools\net472\Microsoft.NET.Sdk.BlazorWebAssembly.Tasks.dll</_BlazorWebAssemblySdkTasksAssembly>
30-
<_BlazorWebAssemblySdkToolAssembly>$(BlazorWebAssemblySdkDirectoryRoot)tools\$(TargetFramework)\Microsoft.NET.Sdk.BlazorWebAssembly.Tool.dll</_BlazorWebAssemblySdkToolAssembly>
14+
<CompressionIncludePatterns>$(CompressionIncludePatterns);**/*.css;**/*.js</CompressionIncludePatterns>
15+
<BuildCompressionFormats>gzip;brotli</BuildCompressionFormats>
16+
<PublishCompressionFormats>gzip;brotli</PublishCompressionFormats>
3117
</PropertyGroup>
3218

33-
<!-- The next two lines are Copyright (c) .NET Foundation. All rights reserved. -->
34-
<UsingTask TaskName="Microsoft.NET.Sdk.BlazorWebAssembly.BrotliCompress" AssemblyFile="$(_BlazorWebAssemblySdkTasksAssembly)" />
35-
<UsingTask TaskName="Microsoft.NET.Sdk.BlazorWebAssembly.GzipCompress" AssemblyFile="$(_BlazorWebAssemblySdkTasksAssembly)" />
36-
37-
<!--
38-
This target runs after build. If you want to run after Publish, change:
39-
- AfterTargets should be set to "Build"
40-
- "ProjectDir" in MyStaticFiles should be changed to "PublishDir"
41-
-->
42-
<Target Name="CustomGZipAndBrotliCompression" AfterTargets="Build">
43-
44-
<Message Importance="High" Text="======= Gzip/Brotli task assembly details=$(_BlazorWebAssemblySdkTasksAssembly)" />
45-
<Message Importance="High" Text="======= Brotli tool assembly details=$(_BlazorWebAssemblySdkToolAssembly)" />
46-
<Message Importance="High" Text="======= Brotli tool executable details=$(_RazorSdkDotNetHostFileName)" />
47-
<Message Importance="High" Text="======= Brotli tool path details=$(_RazorSdkDotNetHostDirectory)" />
48-
49-
<!--************* THIS IS WHERE YOU CHOOSE WHAT TO COMPRESS *****************
50-
you probably don't want to change anything else - just this ItemGroup-->
51-
52-
<ItemGroup>
53-
<MyStaticFiles Include="$(ProjectDir)/wwwroot/**/*.css" />
54-
<MyStaticFiles Include="$(ProjectDir)/wwwroot/**/*.js" />
55-
</ItemGroup>
56-
57-
<!--Call the BlazorWebAssembly Task GZipCompress and store the results in MyCompressedFiles-->
58-
<GZipCompress FilesToCompress="@(MyStaticFiles)" OutputDirectory="$(IntermediateOutputPath)compress\">
59-
<Output TaskParameter="CompressedFiles" ItemName="MyCompressedFiles" />
60-
</GZipCompress>
61-
62-
<!--Call the BlazorWebAssembly Task BrotliCompress and store the results in MyCompressedFiles-->
63-
<BrotliCompress FilesToCompress="@(MyStaticFiles)" OutputDirectory="$(IntermediateOutputPath)compress\" ToolAssembly="$(_BlazorWebAssemblySdkToolAssembly)" ToolExe="$(_RazorSdkDotNetHostFileName)" ToolPath="$(_RazorSdkDotNetHostDirectory)">
64-
<Output TaskParameter="CompressedFiles" ItemName="MyCompressedFiles" />
65-
</BrotliCompress>
66-
67-
<!--Log what we have done-->
68-
<Message Importance="High" Text="======= Brotli/GZip Compression For @(MyCompressedFiles-&gt;Count()) Static Files =======" />
69-
<Message Importance="High" Text=" Compressed: %(MyCompressedFiles.OriginalItemSpec)%(MyCompressedFiles.Extension)" />
70-
71-
<!--Rename/move the compressed files back to to the correct place/names as they have "hashed" names at this stage.-->
72-
<Move SourceFiles="%(MyCompressedFiles.FullPath)" DestinationFiles="%(MyCompressedFiles.OriginalItemSpec)%(MyCompressedFiles.Extension)" />
73-
74-
</Target>
75-
7619
</Project>

CompressedStaticFiles.Example/Pages/Index.razor

Lines changed: 10 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626

2727
<h1 style="margin-top: 48px;">How to detect file compression</h1>
2828

29+
<p>
30+
To demonstrate the compressed files execute the 'LocalBuild.cmd' at the root of this repository and follow
31+
the instructions to browse to the demonstration.
32+
</p>
2933
<p>
3034
Press F12 to enter your browser's development tools and select the network tab (we did this on Edge here).
3135
Click any css or js file (except for blazor.server.js, which as an ASP.NET framework file isn't compressed)
@@ -43,77 +47,17 @@
4347
</p>
4448

4549
<pre><code>
46-
&lt;PropertyGroup&gt;
47-
&lt;!--Paths to tools, tasks, and extensions are calculated relative to the BlazorWebAssemblySdkDirectoryRoot.
48-
But there does not seem to be a property for that, so after much trial and error, using the property
49-
ILLinkTasksAssembly seems most reliable as it contains the same value whether the build is run from VS
50-
or the command line, unlike many others such as MSBuildSDKsPath.
51-
If a better property is identified, this can be changed.
52-
--&gt;
53-
54-
&lt;!-- First, we strip the property value back to the root SDKs level and then down into the WebAssembly SDK --&gt;
55-
&lt;_SDKRoot&gt;$(ILLinkTasksAssembly.Substring(0,$(ILLinkTasksAssembly.LastIndexOf('Microsoft.NET.ILLink.Tasks'))))&lt;/_SDKRoot&gt;
56-
&lt;BlazorWebAssemblySdkDirectoryRoot&gt;$(_SDKRoot)\Microsoft.NET.Sdk.BlazorWebAssembly\&lt;/BlazorWebAssemblySdkDirectoryRoot&gt;
57-
58-
&lt;!-- The next four lines are Copyright (c) .NET Foundation. All rights reserved. --&gt;
59-
&lt;_BlazorWebAssemblySdkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core'"&gt;net6.0&lt;/_BlazorWebAssemblySdkTasksTFM&gt;
60-
&lt;_BlazorWebAssemblySdkTasksTFM Condition=" '$(MSBuildRuntimeType)' != 'Core'"&gt;net472&lt;/_BlazorWebAssemblySdkTasksTFM&gt;
61-
&lt;_BlazorWebAssemblySdkTasksAssembly&gt;$(BlazorWebAssemblySdkDirectoryRoot)tools\$(_BlazorWebAssemblySdkTasksTFM)\Microsoft.NET.Sdk.BlazorWebAssembly.Tasks.dll&lt;/_BlazorWebAssemblySdkTasksAssembly&gt;
62-
&lt;_BlazorWebAssemblySdkToolAssembly&gt;$(BlazorWebAssemblySdkDirectoryRoot)tools\net6.0\Microsoft.NET.Sdk.BlazorWebAssembly.Tool.dll&lt;/_BlazorWebAssemblySdkToolAssembly&gt;
63-
&lt;/PropertyGroup&gt;
64-
65-
&lt;!-- The next two lines are Copyright (c) .NET Foundation. All rights reserved. --&gt;
66-
&lt;UsingTask TaskName="Microsoft.NET.Sdk.BlazorWebAssembly.BrotliCompress" AssemblyFile="$(_BlazorWebAssemblySdkTasksAssembly)" /&gt;
67-
&lt;UsingTask TaskName="Microsoft.NET.Sdk.BlazorWebAssembly.GzipCompress" AssemblyFile="$(_BlazorWebAssemblySdkTasksAssembly)" /&gt;
68-
69-
70-
71-
72-
&lt;!--
73-
This target runs after build. If you want to run after Publish, change:
74-
- AfterTargets should be set to "Build"
75-
- "ProjectDir" in MyStaticFiles should be changed to "PublishDir"
76-
--&gt;
77-
&lt;Target Name="CustomGZipAndBrotliCompression" AfterTargets="Build"&gt;
78-
79-
&lt;!--************* THIS IS WHERE YOU CHOOSE WHAT TO COMPRESS *****************
80-
you probably don't want to change anything else - just this ItemGroup--&gt;
81-
82-
&lt;ItemGroup&gt;
83-
&lt;MyStaticFiles Include="$(ProjectDir)/wwwroot/**/*.css" /&gt;
84-
&lt;MyStaticFiles Include="$(ProjectDir)/wwwroot/**/*.js" /&gt;
85-
&lt;/ItemGroup&gt;
86-
87-
&lt;!--Call the BlazorWebAssembly Task GZipCompress and store the results in MyCompressedFiles--&gt;
88-
&lt;GZipCompress FilesToCompress="@@(MyStaticFiles)" OutputDirectory="$(IntermediateOutputPath)compress\"&gt;
89-
&lt;Output TaskParameter="CompressedFiles" ItemName="MyCompressedFiles" /&gt;
90-
&lt;/GZipCompress&gt;
91-
92-
&lt;!--Call the BlazorWebAssembly Task BrotliCompress and store the results in MyCompressedFiles--&gt;
93-
&lt;BrotliCompress OutputDirectory="$(IntermediateOutputPath)compress\" FilesToCompress="@@(MyStaticFiles)" ToolAssembly="$(_BlazorWebAssemblySdkToolAssembly)" ToolExe="$(_RazorSdkDotNetHostFileName)" ToolPath="$(_RazorSdkDotNetHostDirectory)"&gt;
94-
&lt;Output TaskParameter="CompressedFiles" ItemName="MyCompressedFiles" /&gt;
95-
&lt;/BrotliCompress&gt;
96-
97-
&lt;!--Log what we have done--&gt;
98-
&lt;Message Importance="High" Text="======= Brotli/GZip Compression For @@(MyCompressedFiles-&gt;Count()) Static Files =======" /&gt;
99-
&lt;Message Importance="High" Text=" Compressed: %(MyCompressedFiles.OriginalItemSpec)%(MyCompressedFiles.Extension)" /&gt;
100-
101-
&lt;!--Rename/move the compressed files back to to the correct place/names as they have "hashed" names at this stage.--&gt;
102-
&lt;Move SourceFiles="%(MyCompressedFiles.FullPath)" DestinationFiles="%(MyCompressedFiles.OriginalItemSpec)%(MyCompressedFiles.Extension)" /&gt;
103-
104-
&lt;/Target&gt;
105-
&lt;ItemGroup&gt;
106-
&lt;ProjectReference Include="..\CompressedStaticFiles.AspNetCore\CompressedStaticFiles.AspNetCore.csproj" /&gt;
107-
&lt;/ItemGroup&gt;
108-
&lt;ItemGroup&gt;
109-
&lt;Folder Include="wwwroot\images\" /&gt;
110-
&lt;/ItemGroup&gt;
50+
<!--Compression directives (Note that the patterns are relative to wwwroot)-->
51+
&lt;PropertyGroup&gt;
52+
&lt;CompressionIncludePatterns&gt;$(CompressionIncludePatterns);**/*.css;**/*.js&lt;/CompressionIncludePatterns&gt;
53+
&lt;BuildCompressionFormats&gt;gzip;brotli&lt;/BuildCompressionFormats&gt;
54+
&lt;PublishCompressionFormats&gt;gzip;brotli&lt;/&lt;PublishCompressionFormats&gt;
55+
&lt;/PropertyGroup&gt;
11156
</code></pre>
11257

11358
<h1 style="margin-top: 48px;">Attribution</h1>
11459

11560
<p>Thanks to the following:</p>
11661
<ul>
11762
<li>This project is a fork of Peter Andersson's from whose original <a href="https://github.com/AnderssonPeter/CompressedStaticFiles" target="_blank">CompressedStaticFiles repo</a>; and</li>
118-
<li><a href="https://github.com/SQL-MisterMagoo" target="_blank">SQL-MisterMagoo</a> for providing the MSBUILD code that performs Brotli and GZIP static file compression.</li>
11963
</ul>

Directory.Build.props

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project>
2+
<PropertyGroup>
3+
<ArtifactsPath>$(MSBuildThisFileDirectory).artifacts</ArtifactsPath>
4+
</PropertyGroup>
5+
6+
<PropertyGroup>
7+
<TargetFramework>net8.0</TargetFramework>
8+
<ImplicitUsings>disable</ImplicitUsings>
9+
<Nullable>disable</Nullable>
10+
</PropertyGroup>
11+
12+
<PropertyGroup>
13+
<AccelerateBuildsInVisualStudio>false</AccelerateBuildsInVisualStudio>
14+
</PropertyGroup>
15+
16+
</Project>

LocalBuild.cmd

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@echo off
2+
set argDestination=%1
3+
if "%1" == "" set argDestination=PublishedExample
4+
5+
echo Destination is %argDestination%
6+
echo ...
7+
echo Beginning publish
8+
echo ...
9+
dotnet publish CompressedStaticFiles.Example/CompressedStaticFiles.Example.csproj --configuration Debug --output %argDestination%
10+
echo ...
11+
echo Build results
12+
echo ...
13+
dir "%argDestination%" /s
14+
echo ...
15+
echo Executing published example
16+
echo ...
17+
cd %argDestination%
18+
compressedstaticfiles.example.exe"
19+
cd ..
20+
rd %argDestination% /s /q
21+
pause

0 commit comments

Comments
 (0)