Skip to content

aspire publish not working with Vite app #15621

@Dan-Irl

Description

@Dan-Irl

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When trying to Publish / Deploy using the Aspire CLI for my project that has a ASP.Net API and a couple of Vite frontend applications

using Common.Enums;

var builder = DistributedApplication.CreateBuilder(args);

// Add Docker Compose environment for publishing
builder.AddDockerComposeEnvironment(AspireServiceEnum.Compose.ToServiceName());


var postgres = builder.AddPostgres(AspireServiceEnum.Postgres.ToServiceName())
	.WithImage("postgres:17.0")
	.WithDataVolume("Scarlett")
	.WithContainerName("ScarlettDatabase")
	.WithHostPort(5433);

postgresdb = postgres.AddDatabase(AspireServiceEnum.ScarlettDB.ToServiceName());

// Add migration service
builder.AddProject<Projects.MigrationService>(AspireServiceEnum.Migrations.ToServiceName())
	.WithReference(postgresdb)
	.WaitFor(postgresdb);


var api = builder.AddProject<Projects.API>(AspireServiceEnum.API.ToServiceName())
	.WithReference(postgresdb)
	.WithReference(volumeClustering)
	.WithReference(plateCaddyCalibration);

var frontend = builder.AddViteApp(AspireServiceEnum.Frontend.ToServiceName(), "../Frontend")
	.WithPnpm()
	.WithReference(api);

var debugger = builder.AddViteApp(AspireServiceEnum.Debugger.ToServiceName(), "../ScarlettDebugger")
	.WithPnpm()
	.WithReference(api);

var gateway = builder.AddYarp(AspireServiceEnum.Gateway.ToServiceName())
	.WithHostPort(80)
	.WithConfiguration(yarp =>
	{
		// Configure routes programmatically
		yarp.AddRoute(frontend);
		yarp.AddRoute("/debugger/{**catch-all}", debugger);
		yarp.AddRoute("/api/{**catch-all}", api);
		yarp.AddRoute("/dev/{**catch-all}", api);
		yarp.AddRoute("/hub/{**catch-all}", api);
		yarp.AddRoute("/openapi/{**catch-all}", api);
	});

builder.Build().Run();

Expected Behavior

With Aspire 13.2 i Expected publish to generate the Docker compose file, and deploy to generate the default docker file for a aspire app as stated in the JavaScript docs

Steps To Reproduce

No response

Exceptions (if any)

 scarlett  aspire publish
🔬 Checking project type...: Host\Host.csproj
🛠  Building apphost... Host\Host.csproj
13:05:03 (pipeline-execution) → Starting pipeline-execution...
13:05:03 (publish-Compose) → Starting publish-Compose...
13:05:03 (publish-Compose) i [INF] Generating Compose output
13:05:03 (publish-Compose) ✗ [ERR] Step 'publish-Compose' failed.
13:05:03 (publish-Compose) ✗ Step 'publish-Compose' failed: The given key 'Aspire.Hosting.JavaScript.ViteAppResource' was not present in the dictionary.
13:05:03 (pipeline-execution) ✗ [ERR] Step 'publish-Compose' failed: The given key 'Aspire.Hosting.JavaScript.ViteAppResource' was not present in the dictionary.
13:05:03 (pipeline-execution) ✗ Failed
------------------------------------------------------------
✓ 0/2 steps succeeded • ✗ 2 failed • Total time: 29.17ms

Steps Summary:
      6.70ms  ✗ pipeline-execution
      3.54ms  ✗ publish-Compose

✗ PIPELINE FAILED
For more details, add --log-level debug/trace to the command.
------------------------------------------------------------`

.NET Version info

dotnet --version                                                                                                                                                                                                                                                                             
10.0.100

Anything else?

Apphost .csproj

<Project Sdk="Aspire.AppHost.Sdk/13.2.0">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <UserSecretsId>16f6557c-4510-4afe-b8c7-2ece3d41f177</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Aspire.Hosting.Docker" Version="13.2.0" />
    <PackageReference Include="Aspire.Hosting.JavaScript" Version="13.2.0" />
    <PackageReference Include="Aspire.Hosting.PostgreSQL" Version="13.2.0" />
    <PackageReference Include="Aspire.Hosting.Python" Version="13.2.0" />
    <PackageReference Include="Aspire.Hosting.Yarp" Version="13.2.0" />
  </ItemGroup>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions