fix(template): dotnet scaffold passes its own checks and builds a non-root image #5
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/template-dotnet"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Scaffolding
repos/soginwithlanguage: dotnetshowed three gaps in the template. This fixes them.Gaps
mise run fmtrunsdotnet format, which errors with no project or solution present. An empty.slnxdoesn't help either:dotnet build -warnaserrorturns NuGet's "Unable to find a project to restore" warning into an error. Fix:fmt,lintandtestcheck for a.sln,.slnxor*.*projin the root. Without one they print "no .sln, .slnx or project file in the root yet, nothing to …" and exit 0; with one they run the real dotnet command unchanged. This is the honest option: it says nothing exists yet, rather than generating a solution that pretends to build.dotnet = "latest"could drift to a preview major while the Containerfile hardcodes the 10.0 images. Fix: pinned todotnet = "10".project_name. That gaveSögin.dllfor a non-ASCII name and assumed a single project. Fix: a requiredPROJECTbuild arg publishessrc/$PROJECTand runs$PROJECT.dll. The build fails with a clear message whenPROJECTis missing.compose.yamlpassesPROJECTas a build arg for dotnet. A dotnet-only.containerignorekeeps the host'sbin/andobj/out of the build. The image now setsUSER $APP_UID:aspnet:10.0ships theappuser (1654) but has noUSER, so it started as root.Proof (local, scratch dirs outside the repo)
copier copy --trust --defaults --vcs-ref HEAD --data language=dotnet --data project_name="Prófun":mise run fmt,lintandtestall exit 0 with the "nothing to …" message.git commitpasses the lefthookpre-commit(fmt, lint) andcommit-msghooks with no hand edits.use_podman=true, plussrc/Profun.Web(dotnet new web),tests/Profun.Tests(xunit) andProfun.slnx:mise run lintfail with CS0168, so the guard hides nothing.podman buildwithoutPROJECTfails with the message.podman build --build-arg PROJECT=Profun.Webbuilds; imageUser=1654. The container servesHello World!on 8080 andidgivesuid=1654(app).language=noneandlanguage=noderender identically tomain, apart from sops ciphertext. The none scaffold passes its tasks and a commit.Not in this PR
language: nodescaffold failsmise run lint(and so its pre-commit hook):npx eslint .finds no config. Same onmain.project_slugdefaults toproject_name | lower, so "Prófun" gives the slugprófun, and compose tags the imagelocalhost/prófun:dev, which is not a valid image reference.🤖 Generated with Claude Code