Search code examples
.netazure-devopsblazor.net-9.0

Azure DevOps publish is 20x slower on .NET 9


I have a build pipeline created on AzureDevops for Blazor solution. The build agent is running on my server. About a month ago I updated all my projects to .NET 9 and ran a build. The build time went up from about 10 minutes to 30+ minutes. The delay was caused by "Publish" step that now takes over 20 minutes.

No other changes other then updating to .NET 9 have been made.

Why does publish step take about 20 minutes when targeting .NET 9 as opposed to 1 minute when targeting .NET 8 and how to fix it?

Step detail

enter image description here

There is nothing unusual in the logs

Starting: Publish
==============================================================================
Task         : .NET Core
Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version      : 2.247.3
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
C:\Windows\system32\chcp.com 65001
Active code page: 65001
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
"C:\Program Files\dotnet\dotnet.exe" publish C:\BuildAgent\_work\38\s\Api.csproj --configuration Release --output C:\BuildAgent\_work\38\a\Api --no-restore --no-build
  Api -> C:\BuildAgent\_work\38\a\Api\
"C:\Program Files\dotnet\dotnet.exe" publish C:\BuildAgent\_work\38\s\BlazorClient\BlazorClientServerEntryPoint\BlazorClientServerEntryPoint.csproj --configuration Release --output C:\BuildAgent\_work\38\a\BlazorClientServerEntryPoint --no-restore --no-build
  Adding WebOptimizer cache files to publish output
  BlazorClientServerEntryPoint -> C:\BuildAgent\_work\38\a\BlazorClientServerEntryPoint\
"C:\Program Files\dotnet\dotnet.exe" publish C:\BuildAgent\_work\38\s\BlazorClient\BlazorClientStyles\BlazorClientStyles.csproj --configuration Release --output C:\BuildAgent\_work\38\a\BlazorClientStyles --no-restore --no-build
  BlazorClientStyles -> C:\BuildAgent\_work\38\a\BlazorClientStyles\
"C:\Program Files\dotnet\dotnet.exe" publish C:\BuildAgent\_work\38\s\BlazorClient\BlazorClientComponents\BlazorClientComponents.csproj --configuration Release --output C:\BuildAgent\_work\38\a\BlazorClientComponents --no-restore --no-build
  BlazorClientComponents -> C:\BuildAgent\_work\38\a\BlazorClientComponents\
"C:\Program Files\dotnet\dotnet.exe" publish C:\BuildAgent\_work\38\s\BlazorClient\BlazorClientInfrastructure\BlazorClientInfrastructure.csproj --configuration Release --output C:\BuildAgent\_work\38\a\BlazorClientInfrastructure --no-restore --no-build
  BlazorClientInfrastructure -> C:\BuildAgent\_work\38\a\BlazorClientInfrastructure\
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
Finishing: Publish

I'm using .NET Core task version 2.* and have added --no-restore and --no-build arguments. It had no impact. I have also tried the Azure Pipelines agent with the same result


Solution

  • Microsoft recognized this is a known issue caused by recent changes in .NET 9 SDK,

    https://github.com/dotnet/sdk/issues/43470.

    Please wait for the updates to address such, or apply the workarounds listed in the GitHub thread to see if they help.

    Note that the slowness might happen in .NET project types (such as MAUI) other than ASP.NET Core/Blazor due to other .NET 9 introduced changes, so their specific workarounds are in related GitHub issues under dotnet/sdk repo. Please search for them on GitHub instead of posting duplicate threads on Stack Overflow.