microsoft / microsoft/aspire

Project Resource fails to start if AppHost started with `--artifacts-path`

Open
#6,887 2 comments 1 reaction 0 assignees View on GitHub
area-app-testing
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

If you try to run an aspire app or a test app where you've passed `--artifacts-path` into dotnet, then Aspire will be unable to launch project resources as it'll try and fall back to the default artifact path.

### Expected Behavior

Project resources should start when the app host is started with `--artifacts-path`

### Steps To Reproduce

I reproed this using the Aspire starter template, although I believe this is reproduceable with any app host project or test project using `DistributedApplicationTestingBuilder`

```bash
# Clean out any non artifact path binaries
dotnet clean

dotnet run --project .\AspireApp2.AppHost\ --artifacts-path .artifacts
dotnet test .\AspireApp2.Tests\ --artifacts-path .artifacts
```

### Exceptions (if any)

```
Unhandled exception: System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'REDACTED\AspireApp2\AspireApp2.ApiService\bin\Debug\net8.0\AspireApp2.ApiService.exe' with working directory 'REDACTED\AspireApp2\AspireApp2.ApiService'. The system cannot find the file specified.
2024-12-06T18:09:23
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
2024-12-06T18:09:23
at Microsoft.DotNet.Cli.Utils.Command.Execute(Action`1 processStarted)
2024-12-06T18:09:23
at Microsoft.DotNet.Tools.Run.RunCommand.Execute()
2024-12-06T18:09:23
at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult)
2024-12-06T18:09:23
at System.CommandLine.ParseResult.Invoke()
2024-12-06T18:09:23
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)
```

The path it should be looking at is `REDACTED\AspireApp2\.artifacts\bin\AspireApp2.ApiService\debug\AspireApp2.ApiService.exe`, not `REDACTED\AspireApp2\AspireApp2.ApiService\bin\Debug\net8.0\AspireApp2.ApiService.exe`

### .NET Version info

```
.NET SDK:
Version: 9.0.100
Commit: 59db016f11
Workload version: 9.0.100-manifests.c6f19616
MSBuild version: 17.12.7+5b8665660

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.100\

.NET workloads installed:
[aspire]
Installation Source: VS 17.12.35514.174
Manifest Version: 8.2.2/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
Install Type: Msi

Configured to use loose manifests when installing new manifests.

Host:
Version: 9.0.0
Architecture: x64
Commit: 9d5a6a9aa4

.NET SDKs installed:
6.0.428 [C:\Program Files\dotnet\sdk]
8.0.404 [C:\Program Files\dotnet\sdk]
9.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download
```

### Anything else?

We've hit this on our standard build template. Our template template sets `--artifact-path` on all `dotnet` steps to make publishing easier at the end - this way we just generically push `$(ArtifactsPath)/package` to our internal nuget feed and publish everything under `$(ArtifactsPath)/publish` as an artifact.

Locally I have been able to work around this by setting the `ArtifactsPath`, although this doesn't seem to be working on the build server which I'll need to investigate more next week. I assume this work around works as Environment Variables are automatically inherited by child processes, but the `--artifacts-path` command line argument is not automatically propagated.

```pwsh
$env:ArtifactsPath = (Resolve-Path '.artifacts')
# Clean out any non artifact path binaries
dotnet clean

dotnet run --project .\AspireApp2.AppHost\ --artifacts-path .artifacts
dotnet test .\AspireApp2.Tests\ --artifacts-path .artifacts
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.