-
Notifications
You must be signed in to change notification settings - Fork 736
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I have the following in my AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var db = builder.AddSqlite("db")
.WithSqliteWeb();
var apiService = builder.AddProject<Projects.TodojsAspire_ApiService>("todo-apiservice")
.WithReference(db)
.WithHttpHealthCheck("/health");
// use `aspire add javascript` for `AddViteApp`
var frontend = builder.AddViteApp("todofrontend", "../todo-frontend")
.WithReference(apiService)
.WaitFor(apiService);
apiService.PublishWithContainerFiles(frontend, "./wwwroot");
builder.Build().Run();The frontend references the apiservice named todo-apiservice. Aspire 13 creates an env vars named
TODO-APISERVICE_HTTPTODO-APISERVICE_HTTPSservices__todo-apiservice__http__0services__todo-apiservice__https__0.
The problem is that - is not allowed in env var names, from https://nodejs.org/api/environment_variables.html.
A valid variable name must contain only letters (uppercase or lowercase), digits and underscores (_) and it can't begin with a digit.
More specifically a valid variable name must match the following regular expression^[a-zA-Z_]+[a-zA-Z0-9_]*$
I also found this related discussion https://unix.stackexchange.com/questions/23659/can-shell-variable-name-include-a-hyphen-or-dash.
In the vite.config.js file you have to configure the connection with the env var. For example.
target:
process.env.TODO-APISERVICE_HTTPS ||
process.env.TODO-APISERVICE_HTTP,The frontend will fail to start because the vite.config.js file couldn't be loaded.
Expected Behavior
I was expecting the - to be converted to a _ for example TODO_APISERVICE_HTTPS.
Steps To Reproduce
You can clone my repo at https://github.com/[sayedihashimi/todojsaspire](https://github.com/sayedihashimi/todojsaspire) and change the name 'apiservice' to 'todo-apiservice' and update vite.config.js to match.
Exceptions (if any)
No response
.NET Version info
dotnet --info
.NET SDK:
Version: 10.0.100
Commit: b0f34d51fc
Workload version: 10.0.100-manifests.5fb86115
MSBuild version: 18.0.2+b0f34d51f
Runtime Environment:
OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.100\
.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.
Host:
Version: 10.0.0
Architecture: x64
Commit: b0f34d51fc
.NET SDKs installed:
5.0.416 [C:\Program Files\dotnet\sdk]
8.0.416 [C:\Program Files\dotnet\sdk]
9.0.307 [C:\Program Files\dotnet\sdk]
10.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.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?
No response