Speed up website deploy: generate API docs from the Radzen.Blazor package

The Docker deploy compiled Radzen.Blazor from source (3 target frameworks
plus Sass and Terser) only to feed the API reference generator, even though
the deployed site ships the published Radzen.Blazor NuGet package. Generate
the API docs and llms.txt from that same package and drop the source build.

- Radzen.Blazor.Api: reference the Radzen.Blazor package in Release (source
  project in Debug), like RadzenBlazorDemos already does; the generator reads
  the package dll/xml.
- RadzenBlazorDemos: GenerateLlmsTxt reads the package XML in Release so the
  LLM docs keep their API descriptions.
- Dockerfile: restore for Release, drop the Radzen.Blazor source build,
  generate API pages from the restored package, set NUGET_XMLDOC_MODE=none so
  the package XML is extracted.
- Add .dockerignore to keep .git/bin/obj out of the build context.
- deploy.yml: shallow checkout (fetch-depth 1).
This commit is contained in:
Atanas Korchev
2026-06-24 20:24:42 +03:00
parent d0ca8c8911
commit cf4a3feded
5 changed files with 59 additions and 12 deletions

29
.dockerignore Normal file
View File

@@ -0,0 +1,29 @@
# Keep the Docker build context small. Without this, `COPY . .` ships the
# entire .git history (~115MB) and every bin/obj into the build context,
# bloating uploads and invalidating layer caches on every build.
# Version control
.git
.gitignore
.gitattributes
# .NET build outputs - rebuilt inside the image
**/bin/
**/obj/
**/.vs/
*.user
# Editor / OS cruft
.vscode/
.idea/
.DS_Store
# Node tooling (if any)
**/node_modules/
# CI config - never needed at build or runtime
.github/
# The Docker build files themselves
Dockerfile
.dockerignore

View File

@@ -23,7 +23,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 1
- name: Set up .NET - name: Set up .NET
uses: actions/setup-dotnet@v4 uses: actions/setup-dotnet@v4

View File

@@ -4,6 +4,10 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src WORKDIR /src
# The SDK image sets NUGET_XMLDOC_MODE=skip; the API page generator needs Radzen.Blazor.xml from the
# restored package, so re-enable XML doc extraction during restore.
ENV NUGET_XMLDOC_MODE=none
# Copy project files first for better caching # Copy project files first for better caching
COPY Radzen.Blazor/*.csproj Radzen.Blazor/ COPY Radzen.Blazor/*.csproj Radzen.Blazor/
COPY Radzen.Blazor.Api/*.csproj Radzen.Blazor.Api/ COPY Radzen.Blazor.Api/*.csproj Radzen.Blazor.Api/
@@ -12,19 +16,22 @@ COPY RadzenBlazorDemos/*.csproj RadzenBlazorDemos/
COPY RadzenBlazorDemos.Host/*.csproj RadzenBlazorDemos.Host/ COPY RadzenBlazorDemos.Host/*.csproj RadzenBlazorDemos.Host/
COPY RadzenBlazorDemos.Tools/*.csproj RadzenBlazorDemos.Tools/ COPY RadzenBlazorDemos.Tools/*.csproj RadzenBlazorDemos.Tools/
# Restore dependencies (Host + Tools + API page generator) # Restore for Release so the Radzen.Blazor NuGet package (referenced only in Release) is downloaded
RUN dotnet restore RadzenBlazorDemos.Host/RadzenBlazorDemos.Host.csproj \ # for both the publish below and the API page generator.
RUN dotnet restore RadzenBlazorDemos.Host/RadzenBlazorDemos.Host.csproj -p:Configuration=Release \
&& dotnet restore RadzenBlazorDemos.Tools/RadzenBlazorDemos.Tools.csproj \ && dotnet restore RadzenBlazorDemos.Tools/RadzenBlazorDemos.Tools.csproj \
&& dotnet restore Radzen.Blazor.Api.Generator/Radzen.Blazor.Api.Generator.csproj && dotnet restore Radzen.Blazor.Api.Generator/Radzen.Blazor.Api.Generator.csproj
# Copy full source after restore layer # Copy full source after restore layer
COPY . . COPY . .
# Pre-generate API reference pages (must exist on disk before publish evaluates globs) # Pre-generate API reference pages from the published Radzen.Blazor package - the deployed site uses that
RUN dotnet build Radzen.Blazor/Radzen.Blazor.csproj -c Release \ # same package, so there is no need to compile Radzen.Blazor (and its Sass/JS assets) from source.
# Pages must exist on disk before publish evaluates the Api project's Razor globs.
RUN RADZEN_DLL=$(find /root/.nuget/packages/radzen.blazor -path '*/lib/net10.0/Radzen.Blazor.dll' | sort -V | tail -1) \
&& test -n "$RADZEN_DLL" \
&& dotnet run --project Radzen.Blazor.Api.Generator -- \ && dotnet run --project Radzen.Blazor.Api.Generator -- \
Radzen.Blazor/bin/Release/net10.0/Radzen.Blazor.dll \ "$RADZEN_DLL" "${RADZEN_DLL%.dll}.xml" \
Radzen.Blazor/bin/Release/net10.0/Radzen.Blazor.xml \
Radzen.Blazor.Api/Generated/Pages Radzen.Blazor.Api/Generated/Pages
# Publish the Blazor host app (generated pages are now on disk for the SDK to discover) # Publish the Blazor host app (generated pages are now on disk for the SDK to discover)

View File

@@ -6,16 +6,25 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Radzen.Blazor\Radzen.Blazor.csproj" /> <PackageReference Include="Radzen.Blazor" Version="*" GeneratePathProperty="true" Condition="'$(Configuration)' == 'Release'" />
<ProjectReference Include="..\Radzen.Blazor\Radzen.Blazor.csproj" Condition="'$(Configuration)' != 'Release'" />
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<RadzenBlazorDll>$(MSBuildThisFileDirectory)..\Radzen.Blazor\bin\$(Configuration)\net10.0\Radzen.Blazor.dll</RadzenBlazorDll>
<RadzenBlazorXml>$(MSBuildThisFileDirectory)..\Radzen.Blazor\bin\$(Configuration)\net10.0\Radzen.Blazor.xml</RadzenBlazorXml>
<GeneratorProject>$(MSBuildThisFileDirectory)..\Radzen.Blazor.Api.Generator\Radzen.Blazor.Api.Generator.csproj</GeneratorProject> <GeneratorProject>$(MSBuildThisFileDirectory)..\Radzen.Blazor.Api.Generator\Radzen.Blazor.Api.Generator.csproj</GeneratorProject>
<GeneratedPagesDir>$(MSBuildThisFileDirectory)Generated\Pages</GeneratedPagesDir> <GeneratedPagesDir>$(MSBuildThisFileDirectory)Generated\Pages</GeneratedPagesDir>
</PropertyGroup> </PropertyGroup>
<!-- Release reflects over the published package (what the site ships); Debug over the source build. -->
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<RadzenBlazorDll>$(PkgRadzen_Blazor)/lib/net10.0/Radzen.Blazor.dll</RadzenBlazorDll>
<RadzenBlazorXml>$(PkgRadzen_Blazor)/lib/net10.0/Radzen.Blazor.xml</RadzenBlazorXml>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' != 'Release'">
<RadzenBlazorDll>$(MSBuildThisFileDirectory)..\Radzen.Blazor\bin\$(Configuration)\net10.0\Radzen.Blazor.dll</RadzenBlazorDll>
<RadzenBlazorXml>$(MSBuildThisFileDirectory)..\Radzen.Blazor\bin\$(Configuration)\net10.0\Radzen.Blazor.xml</RadzenBlazorXml>
</PropertyGroup>
<!-- Usage: dotnet build -p:GenerateApiPages=true --> <!-- Usage: dotnet build -p:GenerateApiPages=true -->
<Target Name="GenerateApiPages" BeforeTargets="ResolveProjectStaticWebAssets;AssignTargetPaths" <Target Name="GenerateApiPages" BeforeTargets="ResolveProjectStaticWebAssets;AssignTargetPaths"
Inputs="$(RadzenBlazorDll)" Inputs="$(RadzenBlazorDll)"

View File

@@ -4,7 +4,7 @@
<Nullable>disable</Nullable> <Nullable>disable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Radzen.Blazor" Version="*" Condition="'$(Configuration)' == 'Release'" /> <PackageReference Include="Radzen.Blazor" Version="*" GeneratePathProperty="true" Condition="'$(Configuration)' == 'Release'" />
<ProjectReference Include="..\Radzen.Blazor\Radzen.Blazor.csproj" Condition="'$(Configuration)' != 'Release'" /> <ProjectReference Include="..\Radzen.Blazor\Radzen.Blazor.csproj" Condition="'$(Configuration)' != 'Release'" />
<ProjectReference Include="..\Radzen.Blazor.Api\Radzen.Blazor.Api.csproj" /> <ProjectReference Include="..\Radzen.Blazor.Api\Radzen.Blazor.Api.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.*-*" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.*-*" />
@@ -72,7 +72,9 @@
<LlmsTxtToolDir>$(MSBuildThisFileDirectory)..\RadzenBlazorDemos.Tools\bin\$(Configuration)\net10.0\</LlmsTxtToolDir> <LlmsTxtToolDir>$(MSBuildThisFileDirectory)..\RadzenBlazorDemos.Tools\bin\$(Configuration)\net10.0\</LlmsTxtToolDir>
<LlmsTxtToolExe Condition="'$(OS)' == 'Windows_NT'">$(LlmsTxtToolDir)RadzenBlazorDemos.Tools.exe</LlmsTxtToolExe> <LlmsTxtToolExe Condition="'$(OS)' == 'Windows_NT'">$(LlmsTxtToolDir)RadzenBlazorDemos.Tools.exe</LlmsTxtToolExe>
<LlmsTxtToolExe Condition="'$(OS)' != 'Windows_NT'">$(LlmsTxtToolDir)RadzenBlazorDemos.Tools</LlmsTxtToolExe> <LlmsTxtToolExe Condition="'$(OS)' != 'Windows_NT'">$(LlmsTxtToolDir)RadzenBlazorDemos.Tools</LlmsTxtToolExe>
<RadzenBlazorXmlDoc>$(MSBuildThisFileDirectory)..\Radzen.Blazor\bin\$(Configuration)\net8.0\Radzen.Blazor.xml</RadzenBlazorXmlDoc> <!-- Release builds use the published package (no source build); reflect over its XML doc. -->
<RadzenBlazorXmlDoc Condition="'$(Configuration)' == 'Release'">$(PkgRadzen_Blazor)/lib/net10.0/Radzen.Blazor.xml</RadzenBlazorXmlDoc>
<RadzenBlazorXmlDoc Condition="'$(Configuration)' != 'Release'">$(MSBuildThisFileDirectory)..\Radzen.Blazor\bin\$(Configuration)\net8.0\Radzen.Blazor.xml</RadzenBlazorXmlDoc>
<RadzenBlazorSourceDir>$(MSBuildThisFileDirectory)..\Radzen.Blazor\</RadzenBlazorSourceDir> <RadzenBlazorSourceDir>$(MSBuildThisFileDirectory)..\Radzen.Blazor\</RadzenBlazorSourceDir>
</PropertyGroup> </PropertyGroup>