Skip to content

Aspire.Hosting.Testing fails to find .NET runtime when running tests in Release #7935

Open
@martincostello

Description

@martincostello

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Inspired by Building and Debugging .NET Lambda applications with .NET Aspire (Part 2) I added some integration tests to an AWS Lambda function app of mine today using Aspire.Hosting.Testing.

Towards of the end of completing the changes I found that the tests were failing using my CLI build script locally and in CI, but things were fine in Visual Studio.

The tests fail with errors like this:

Can_Invoke_Function_And_Get_Skill_Response(payloadName: "Launch") (30s 2ms): Error Message: Test execution timed o
      ut after 30000 milliseconds
      Stack Trace:
      --- End of stack trace from previous location ---
        Standard Output Messages:
       [2025-03-06 18:46:26Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             2: 2025-03-06T18:46:26.4860000Z You must install or update .NET to run this application.
       [2025-03-06 18:46:26Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             3: 2025-03-06T18:46:26.4860000Z
       [2025-03-06 18:46:26Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             4: 2025-03-06T18:46:26.4860000Z App: D:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTrave
      l.Skill\release\LondonTravel.Skill.exe
       [2025-03-06 18:46:26Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             5: 2025-03-06T18:46:26.4860000Z Architecture: x64
       [2025-03-06 18:46:26Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             6: 2025-03-06T18:46:26.4860000Z Framework: 'Microsoft.NETCore.App', version '9.0.0' (x64)
       [2025-03-06 18:46:26Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             7: 2025-03-06T18:46:26.4860000Z .NET location: D:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill\release\
       [2025-03-06 18:46:26Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             8: 2025-03-06T18:46:26.4860000Z
       [2025-03-06 18:46:26Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             9: 2025-03-06T18:46:26.4860000Z No frameworks were found.
       [2025-03-06 18:46:26Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             10: 2025-03-06T18:46:26.4860000Z
       [2025-03-06 18:46:26Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             11: 2025-03-06T18:46:26.4860000Z Learn more:
       [2025-03-06 18:46:26Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             12: 2025-03-06T18:46:26.4860000Z https://aka.ms/dotnet/app-launch-failed
       [2025-03-06 18:46:26Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             13: 2025-03-06T18:46:26.4860000Z
       [2025-03-06 18:46:26Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             14: 2025-03-06T18:46:26.4860000Z To install missing framework, download:
       [2025-03-06 18:46:26Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             15: 2025-03-06T18:46:26.4860000Z https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=9.0.0&arch=x64&rid=win-x64&os=win10

Some trial-and-error later, I narrowed the difference down to the tests running in Debug or Release.

In Debug:

Restore complete (0.7s)
  LondonTravel.Skill succeeded (1.3s) → D:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill\debug\LondonTravel.Skill.dll
  LondonTravel.Skill.AppHost succeeded (0.6s) → D:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill.AppHost\debug\LondonTravel.Skill.AppHost.dll
  LondonTravel.Skill.AppHostTests succeeded (0.5s) → D:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill.AppHostTests\debug\LondonTravel.Skill.AppHostTests.dll
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v3.0.2+dd36e86129 (64-bit .NET 9.0.2)
[xUnit.net 00:00:00.14]   Discovering: LondonTravel.Skill.AppHostTests
[xUnit.net 00:00:00.29]   Discovered:  LondonTravel.Skill.AppHostTests
[xUnit.net 00:00:00.44]   Starting:    LondonTravel.Skill.AppHostTests
[xUnit.net 00:00:38.18]   Finished:    LondonTravel.Skill.AppHostTests
  LondonTravel.Skill.AppHostTests test succeeded (38.7s)

Test summary: total: 9, failed: 0, succeeded: 9, skipped: 0, duration: 38.6s
Build succeeded in 42.6s

In Release:

Restore complete (0.3s)
  LondonTravel.Skill succeeded (0.4s) → D:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill\release\LondonTravel.Skill.dll
  LondonTravel.Skill.AppHost succeeded (0.4s) → D:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill.AppHost\release\LondonTravel.Skill.AppHost.dll
  LondonTravel.Skill.AppHostTests succeeded (0.1s) → D:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill.AppHostTests\release\LondonTravel.Skill.AppHostTests.dll
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v3.0.2+dd36e86129 (64-bit .NET 9.0.2)
[xUnit.net 00:00:00.14]   Discovering: LondonTravel.Skill.AppHostTests
[xUnit.net 00:00:00.28]   Discovered:  LondonTravel.Skill.AppHostTests
[xUnit.net 00:00:00.42]   Starting:    LondonTravel.Skill.AppHostTests
[xUnit.net 00:00:34.01]     Can_Invoke_Function_And_Get_Skill_Response(payloadName: "Launch") [FAIL]
[xUnit.net 00:00:34.01]       Test execution timed out after 30000 milliseconds
[xUnit.net 00:00:34.01]       Stack Trace:
[xUnit.net 00:00:34.01]         --- End of stack trace from previous location ---
[xUnit.net 00:00:34.01]       Output:
[xUnit.net 00:00:34.01]         [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
[xUnit.net 00:00:34.01]               2: 2025-03-06T19:04:47.1690000Z You must install or update .NET to run this application.
[xUnit.net 00:00:34.01]         [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
[xUnit.net 00:00:34.01]               3: 2025-03-06T19:04:47.1690000Z
[xUnit.net 00:00:34.01]         [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
[xUnit.net 00:00:34.01]               4: 2025-03-06T19:04:47.1690000Z App: D:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill\release\LondonTravel.Skill.exe
[xUnit.net 00:00:34.01]         [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
[xUnit.net 00:00:34.01]               5: 2025-03-06T19:04:47.1690000Z Architecture: x64
[xUnit.net 00:00:34.01]         [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
[xUnit.net 00:00:34.01]               6: 2025-03-06T19:04:47.1690000Z Framework: 'Microsoft.NETCore.App', version '9.0.0' (x64)
[xUnit.net 00:00:34.01]         [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
[xUnit.net 00:00:34.01]               7: 2025-03-06T19:04:47.1690000Z .NET location: D:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill\release\
[xUnit.net 00:00:34.01]         [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
[xUnit.net 00:00:34.01]               8: 2025-03-06T19:04:47.1690000Z
[xUnit.net 00:00:34.01]         [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
[xUnit.net 00:00:34.01]               9: 2025-03-06T19:04:47.1710000Z No frameworks were found.
[xUnit.net 00:00:34.01]         [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
[xUnit.net 00:00:34.01]               10: 2025-03-06T19:04:47.1710000Z
[xUnit.net 00:00:34.01]         [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
[xUnit.net 00:00:34.01]               11: 2025-03-06T19:04:47.1710000Z Learn more:
[xUnit.net 00:00:34.01]         [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
[xUnit.net 00:00:34.01]               12: 2025-03-06T19:04:47.1710000Z https://aka.ms/dotnet/app-launch-failed
[xUnit.net 00:00:34.01]         [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
[xUnit.net 00:00:34.01]               13: 2025-03-06T19:04:47.1710000Z
[xUnit.net 00:00:34.01]         [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
[xUnit.net 00:00:34.01]               14: 2025-03-06T19:04:47.1710000Z To install missing framework, download:
[xUnit.net 00:00:34.01]         [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
[xUnit.net 00:00:34.01]               15: 2025-03-06T19:04:47.1710000Z https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=9.0.0&arch=x64&rid=win-x64&os=win10
[xUnit.net 00:00:34.02]     [Test Cleanup Failure (<unknown test>)] System.Threading.Tasks.TaskCanceledException
[xUnit.net 00:00:34.02]       System.Threading.Tasks.TaskCanceledException : A task was canceled.
[xUnit.net 00:00:34.02]       Stack Trace:
[xUnit.net 00:00:34.02]            at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
[xUnit.net 00:00:34.02]            at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
[xUnit.net 00:00:34.02]            at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
[xUnit.net 00:00:34.02]            at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
[xUnit.net 00:00:34.02]            at Amazon.Runtime.Internal.MetricsHandler.InvokeAsync[T](IExecutionContext executionContext)
[xUnit.net 00:00:34.02]         D:\Coding\martincostello\alexa-london-travel\test\LondonTravel.Skill.AppHostTests\LambdaTests.cs(54,0): at MartinCostello.LondonTravel.Skill.AppHostTests.LambdaTests.Can_Invoke_Function_And_Get_Skill_Response(String payloadName)
[xUnit.net 00:00:34.02]         --- End of stack trace from previous location ---
  LondonTravel.Skill.AppHostTests test failed with 2 error(s) and 1 warning(s) (35.0s)
    D:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill.AppHostTests\release\LondonTravel.Skill.AppHostTests.dll : error TESTERROR:
      Can_Invoke_Function_And_Get_Skill_Response(payloadName: "Launch") (30s 6ms): Error Message: Test execution timed out after 30000 milliseconds
      Stack Trace:
      --- End of stack trace from previous location ---
        Standard Output Messages:
       [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             2: 2025-03-06T19:04:47.1690000Z You must install or update .NET to run this application.
       [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             3: 2025-03-06T19:04:47.1690000Z
       [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             4: 2025-03-06T19:04:47.1690000Z App: D:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill\release\LondonTravel.Skill.exe
       [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             5: 2025-03-06T19:04:47.1690000Z Architecture: x64
       [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             6: 2025-03-06T19:04:47.1690000Z Framework: 'Microsoft.NETCore.App', version '9.0.0' (x64)
       [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             7: 2025-03-06T19:04:47.1690000Z .NET location: D:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill\release\
       [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             8: 2025-03-06T19:04:47.1690000Z
       [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             9: 2025-03-06T19:04:47.1710000Z No frameworks were found.
       [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             10: 2025-03-06T19:04:47.1710000Z
       [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             11: 2025-03-06T19:04:47.1710000Z Learn more:
       [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             12: 2025-03-06T19:04:47.1710000Z https://aka.ms/dotnet/app-launch-failed
       [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             13: 2025-03-06T19:04:47.1710000Z
       [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             14: 2025-03-06T19:04:47.1710000Z To install missing framework, download:
       [2025-03-06 19:04:47Z] fail: LondonTravel.Skill.AppHost.Resources.LondonTravelSkill[0]
             15: 2025-03-06T19:04:47.1710000Z https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=9.0.0&arch=x64&rid=win-x64&os=win10
    D:\Coding\martincostello\alexa-london-travel\test\LondonTravel.Skill.AppHostTests\LambdaTests.cs(54): error TESTERROR:
      Can_Invoke_Function_And_Get_Skill_Response(payloadName: "Launch") (1ms): Error Message: [Test Cleanup Failure (<unknown test ID 12fdaffd57277845bcfa19fbe1b92c56f6
      2c392c0a50aa1cf2a89c43e49cdb9e>)]: System.Threading.Tasks.TaskCanceledException : A task was canceled.
      Stack Trace:
         at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
         at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
         at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
         at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
         at Amazon.Runtime.Internal.MetricsHandler.InvokeAsync[T](IExecutionContext executionContext)
         at MartinCostello.LondonTravel.Skill.AppHostTests.LambdaTests.Can_Invoke_Function_And_Get_Skill_Response(String payloadName) in D:\Coding\martincostello\alexa-
      london-travel\test\LondonTravel.Skill.AppHostTests\LambdaTests.cs:line 54
      --- End of stack trace from previous location ---

I can't see (or remember) any obvious Debug vs. Release stuff in the code or project setup, so I would expect it to behave in either configuration. It is of course possible I've done something stupid somewhere and just noticed it.

For now I've just forced my CI build to use Debug for the app host test projects.

Expected Behavior

Tests pass in Release as they do in Debug.

Steps To Reproduce

  1. Clone martincostello/alexa-london-travel@d9b5dc2
  2. Change the directory to test/LondonTravel.Skill.AppHostTests from the root of the repository
  3. Run dotnet test --configuration Release

Exceptions (if any)

No response

.NET Version info

.NET SDK:
 Version:           9.0.200
 Commit:            90e8b202f2
 Workload version:  9.0.200-manifests.69179adf
 MSBuild version:   17.13.8+cbc39bea8

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

.NET workloads installed:
 [wasm-tools]
   Installation Source: VS 17.14.35821.62, VS 17.13.35825.156
   Manifest Version:    9.0.2/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.current\9.0.2\WorkloadManifest.json
   Install Type:              Msi

 [aspire]
   Installation Source: VS 17.14.35821.62, VS 17.13.35825.156
   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:      10.0.0-preview.1.25080.5
  Architecture: x64
  Commit:       b98cabca12

.NET SDKs installed:
  6.0.428 [C:\Program Files\dotnet\sdk]
  8.0.406 [C:\Program Files\dotnet\sdk]
  9.0.200 [C:\Program Files\dotnet\sdk]
  10.0.100-preview.1.25120.13 [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 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 10.0.0-preview.1.25120.3 [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 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 10.0.0-preview.1.25080.5 [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 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 10.0.0-preview.1.25080.4 [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:
  D:\Coding\martincostello\alexa-london-travel\global.json

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

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

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-app-testingIssues pertaining to the APIs in Aspire.Hosting.Testing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions