@@ -285,6 +285,30 @@ function getCachedBuildOutput(projectName) {
285285 return cacheEntry . output || ""
286286}
287287
288+ /**
289+ * Remove static-web-asset manifest and dswa caches under an obj/ root, leaving
290+ * NuGet restore state and compiled output intact so an active `dotnet watch`
291+ * session only has to redo its static-web-assets step.
292+ * @param {string } objRoot - Path to a project's obj/ directory
293+ */
294+ function clearStaticWebAssetCache ( objRoot ) {
295+ if ( ! fs . existsSync ( objRoot ) ) return
296+ for ( const config of fs . readdirSync ( objRoot ) ) {
297+ // Walk Debug/ and Release/ (skip files like project.assets.json at the root)
298+ const configDir = path . join ( objRoot , config )
299+ if ( ! fs . statSync ( configDir ) . isDirectory ( ) ) continue
300+ for ( const tfm of fs . readdirSync ( configDir ) ) {
301+ const tfmDir = path . join ( configDir , tfm )
302+ if ( ! fs . statSync ( tfmDir ) . isDirectory ( ) ) continue
303+ for ( const entry of fs . readdirSync ( tfmDir ) ) {
304+ if ( entry . startsWith ( "staticwebassets" ) || entry . endsWith ( ".dswa.cache.json" ) ) {
305+ fs . rmSync ( path . join ( tfmDir , entry ) , { recursive : true , force : true } )
306+ }
307+ }
308+ }
309+ }
310+ }
311+
288312/**
289313 * Clear the build cache for a specific project or all projects
290314 * @param {string } [projectName] - Optional project name to clear, or undefined to clear all
@@ -308,6 +332,11 @@ function clearBuildCache(projectName) {
308332 fs . rmSync ( artifactsDir , { recursive : true , force : true } )
309333 }
310334 }
335+ // Clear stale static-web-asset state in web/obj — survives across artifact-path
336+ // isolation and causes confusing "asset can not be found" errors when Vite bundle
337+ // hashes change. Narrowly scoped so a running `npm run dev` session doesn't have
338+ // to redo a full restore.
339+ clearStaticWebAssetCache ( path . join ( process . cwd ( ) , "web" , "obj" ) )
311340 // Clear ESLint cache
312341 const eslintCache = path . join ( process . cwd ( ) , "VueApp" , ".eslintcache" )
313342 if ( fs . existsSync ( eslintCache ) ) {
0 commit comments