Description
Trying to use the support for file-based programs in preview.4, I attempted to craft an Aspire app host program as a single-file by first running dotnet new aspire-starter
and then converting the output app host project into a file-based program:
#:sdk Microsoft.NET.Sdk
#:sdk Aspire.AppHost.Sdk 9.2.1
#:package Aspire.Hosting.AppHost@9.2.1
var builder = DistributedApplication.CreateBuilder(args);
var apiService = builder.AddProject("apiservice", "../AspireStarter.ApiService/AspireStarter.ApiService.csproj")
.WithHttpsHealthCheck("/health");
builder.AddProject<Projects.AspireStarter_Web>("webfrontend", "../AspireStarter.Web/AspireStarter.Web.csproj")
.WithExternalHttpEndpoints()
.WithHttpsHealthCheck("/health")
.WithReference(apiService)
.WaitFor(apiService);
builder.Build().Run();
When this is run though, the following error is output:
$ dotnet run AppHost.cs
Using launch settings from D:\src\scratch\AspireStarter\apphost\Properties\launchSettings.json...
Building...
The SDK 'Aspire.AppHost.Sdk/9.2.1' specified could not be found. D:\src\scratch\AspireStarter\apphost\AppHost.csproj
The build failed. Fix the build errors and run again.
Interestingly, if this file-based program is then converted into a project with dotnet project convert AppHost.cs
, the resultant project restores successfully!