8000 file-based program can't find versioned package-based SDK reference · Issue #48990 · dotnet/sdk · GitHub
[go: up one dir, main page]

Skip to content
file-based program can't find versioned package-based SDK reference #48990
Closed
@DamianEdwards

Description

@DamianEdwards

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!

Metadata

Metadata

Assignees

Labels

Area-run-fileItems related to the "dotnet run <file>" effort

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0