Skip to content

Commit ead4375

Browse files
authored
Merge pull request #204 from ucdavis/chore/build-hardening
chore(build): harden dotnet build scripts and drop deprecated baseUrl
2 parents 6939484 + 3954b48 commit ead4375

3 files changed

Lines changed: 34 additions & 1 deletion

File tree

VueApp/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
}
1313
],
1414
"compilerOptions": {
15-
"baseUrl": ".",
1615
"paths": {
1716
"@/*": ["./src/*"]
1817
}

scripts/build-dotnet.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ const logger = createLogger("BUILD")
2121

2222
const artifactsPath = ".artifacts-precommit"
2323

24+
// Default execFileSync maxBuffer is 1 MB; full build output with all warnings can exceed
25+
// that, which would surface as a false "build failed" instead of the real result.
26+
const MAX_BUILD_OUTPUT = 10_485_760
27+
2428
// Check if either project needs rebuild
2529
const webNeedsBuild = needsBuild("web", "Viper.csproj")
2630
const testNeedsBuild = needsBuild("test", "Viper.test.csproj")
@@ -52,6 +56,7 @@ try {
5256
{
5357
encoding: "utf8",
5458
timeout: 120_000,
59+
maxBuffer: MAX_BUILD_OUTPUT,
5560
stdio: ["inherit", "pipe", "pipe"],
5661
env: { ...env, DOTNET_USE_COMPILER_SERVER: "1" },
5762
},

scripts/lib/build-cache.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)