localhive/build fails after cleaning artifacts: replace-text.cs script runner can't find cached exe
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
## Description
When building the repo after cleaning the `artifacts/` directory (or in a fresh worktree), the full solution build fails in `Aspire.ProjectTemplates.csproj` because the `replace-text.cs` file-based script can't find its cached compiled output.
## Error
```
Aspire.ProjectTemplates.csproj(135,5): error MSB3073: The command
"dotnet "tools/scripts/replace-text.cs" -- @"artifacts\obj\Aspire.ProjectTemplates\Release\net8.0\replace-text-args.rsp""
exited with code 1.
```
The underlying error when running the script directly:
```
Unhandled exception: An error occurred trying to start process
'C:\Code\aspire\artifacts\bin\replace-text\Debug\replace-text.exe'
with working directory 'C:\Code\aspire'. The system cannot find the file specified.
```
## Repro Steps
1. Create a worktree or clean the `artifacts/` directory: `Remove-Item -Recurse artifacts`
2. Run `.\restore.cmd` (succeeds)
3. Run `.\localhive.ps1` or `.\build.cmd -build -pack -c Release`
4. Build fails with the above error
## Root Cause
`tools/scripts/replace-text.cs` is a .NET 10 file-based C# script (using `#:package` directives). The dotnet runtime compiles it on first run and caches the output at `artifacts/bin/replace-text/Debug/replace-text.exe`. When `artifacts/` is cleaned, the cached exe is deleted but the script runner doesn't rebuild it — it just fails trying to start the missing exe.
`restore.cmd` does not rebuild this tool. The cached exe is only created on first successful run of the script, but the build process that needs it fails before it can run.
## Workaround
Copy the pre-built exe from another checkout that has it:
```powershell
$src = "C:\Code\aspire\artifacts\bin\replace-text\Debug"
$dst = "C:\Code\aspire-worktree\artifacts\bin\replace-text\Debug"
New-Item -ItemType Directory -Path $dst -Force | Out-Null
Copy-Item "$src\*" $dst -Recurse -Force
```
## Suggested Fix
Either:
- Have `restore.cmd`/`restore.sh` pre-build the `replace-text.cs` script so it's cached before the main build runs
- Or change the template project to invoke the script in a way that triggers compilation
- Or add the `replace-text` tool as a proper project in the solution so it's built as a dependency
Contributor guide
Assessment
This issue has not been assessed yet.