Minimal repro for a Razor Tag Helper compilation bug on Linux publish
builds using .NET SDK 10.0.400.
When a @section block (rendered via @RenderSection in _Layout.cshtml)
contains more than one element that needs Tag Helper processing (e.g.
~/-prefixed href values, asp-append-version), only the first
element is processed correctly. Every element after it is emitted as literal,
unprocessed markup — no build error or warning.
@section head {
<link rel="stylesheet" href="~/css/one.css" asp-append-version="true">
<link rel="stylesheet" href="~/css/two.css" asp-append-version="true">
}Expected (both resolved):
<link rel="stylesheet" href="/css/one.css?v=xxxxx">
<link rel="stylesheet" href="/css/two.css?v=yyyyy">Actual on affected SDK (second element untouched):
<link rel="stylesheet" href="/css/one.css?v=xxxxx">
<link rel="stylesheet" href="~/css/two.css" asp-append-version="true">| SDK version | Feature band | Result |
|---|---|---|
10.0.302 |
3xx | ✅ works |
10.0.303 |
3xx | ✅ works |
10.0.400 |
4xx | ❌ broken |
All three share runtime 10.0.11. Only reproduces on Linux builds —
not reproducible building/running the same source on Windows.
global.json at the repo root pins the SDK version tested. Edit the
version field to switch between a known-good and known-bad SDK, e.g.:
{
"sdk": {
"version": "10.0.302",
"rollForward": "disable"
}
}Then, on a Linux machine/agent/container with that SDK installed:
dotnet publish -c Release -o out
cd out
ASPNETCORE_URLS=http://localhost:5000 dotnet RazorTagHelperRepro.dllIn another terminal:
curl -s http://localhost:5000/ | grep -A1 "css/one.css"Or open http://localhost:5000 in a browser and view source.
# Known-good (edit global.json to 10.0.302 first)
docker run --rm -v "$PWD":/src -w /src mcr.microsoft.com/dotnet/sdk:10.0 \
sh -c "dotnet publish -c Release -o /tmp/out && cd /tmp/out && \
ASPNETCORE_URLS=http://0.0.0.0:8080 dotnet RazorTagHelperRepro.dll & \
sleep 3 && curl -s http://localhost:8080/ | grep -A1 'css/one.css'"Repeat with global.json set to 10.0.400 to see the second <link>
tag fail to resolve.
- Azure DevOps, Microsoft-hosted
ubuntu-latestagent UseDotNet@2task with a floating10.xversion specifier, which silently picked up10.0.400after previously resolving10.0.302- ASP.NET Core MVC, multi-project solution, view rendered through
_Layout.cshtmlvia@RenderSection("head", required: false)
This minimal repro strips away the multi-project/shared-static-file
specifics of the original app — the bug reproduces with plain files in
wwwroot and no custom MSBuild targets involved.