Skip to content

Upgrading Blazor to new AspNetCore requires aggressive project bin/obj folders deletion #109166

Description

@Sean4572435243

The following is not a criticism, just an experience, and not blaming Microsoft at all. It's a complex product with lots of gotchas, and this one probably will get a few, so hoping to help.

Spent 3 days in a rabbit hole (#1 and #2) trying to understand why after updating my Blazor project AspNetCore modules (8.0.10 in this case), it would no longer compile successfully with AOT:true, with virtually no logging or output to work with. Tried many code modifications that wasted much time, but in the end it wasn't my code at all, I discovered the problems were due to zombie compile processes and lingering deprecated cached compiled files in my project directories that for some reason weren't being properly destroyed/updated by the new version of the compiler.

A simple 'clean solution' was insufficient. I eventually scripted the hard deletion of my ~30 project bin and obj folders, and likewise preceded the build with a task kill of potentially-orphaned build-related processes that remained zombied, locking files from future build attempts.

The AOT:true compiler does work, but there can't be any trace of prior builds from prior compiler versions residing on disk. I consider this a bug because it's not obvious what the problem is, with many misdirections that leads to days of hunting rabbits. At the very least there should be meaningful error messages when compilation fails, but ideally during package upgrading, an informational popup explaining that all these obj/bin folders need to be deleted, or maybe actually perform that action.

For the workaround (hopefully future-proof), here's my new pre-cleansing script that is executed every time before any AOT:true build is attempted

taskkill /IM mono-aot-cross.exe /F
taskkill /IM dotnet.exe /F
rmdir /s /q "C:\Dev\MyProject1\bin"
rmdir /s /q "C:\Dev\MyProject1\obj"
rmdir /s /q "C:\Dev\MyProject2\bin"
rmdir /s /q "C:\Dev\MyProject2\obj"
..etc
rmdir /S /Q "C:\inetpub\myPublishTarget\wwwroot"

and then the build is like

msbuild /t:restore;build "c:\Dev\MySolution.sln" /t:Clean /p:Configuration=Release

and the publish

dotnet publish /p:NoBuild=true /p:PublishDir="c:\myPublishTarget" "c:\Dev\MyBlazorProjectFolder" -p:RunAOTCompilation=true -p:BlazorEnableCompression=false (or true)

and for posterity, at the end of the build script, I repeat

taskkill /IM mono-aot-cross.exe /F
taskkill /IM dotnet.exe /F

Precleansing for AOT:true builds typically only applies to either production or staging releases, so the loss of pre-cached items shouldn't impact development cycle times at all.

Activity

  1. dotnet-policy-service commented on Oct 23, 2024

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
    See info in area-owners.md if you want to be subscribed.

  2. steveisok commented on Jun 30, 2025

    @steveisok
    Member
  3. added this to the 11.0.0 milestone on Jun 30, 2025
  4. removed
    untriagedNew issue has not been triaged by the area owner
    on Jun 30, 2025
  5. Seabizkit commented on Sep 29, 2025

    @Seabizkit

    I'm also experienced this many time in latest version of vs 2022, it's highly annoying as you keep trying different things mean well it's due to old caches.. Or left behind things in the bin. Clean is not enough and rebuilding isn't.. U havnt something close vs and also manually delete bin folders

    When making refactoring... Renaming/moving things

  6. modified the milestones: 11.0.0, 12.0.0 on Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions