microsoft / microsoft/aspire

AppHost secrets.json Gets reformatted/inconsistent formatting with duplicate keys breaking local dev

Open
#8,893 8 comments 4 reactions 0 assignees View on GitHub
area-app-model
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

Since Aspire 9.2 when running locally I've been hitting issues where it starts complaining of duplicate keys in secrets.json (for the AppHost).

e.g.

![Image](https://github.com/user-attachments/assets/f8cdd7b4-2183-4fd6-940a-b1d6fbdd29f4)

When I go to look at the file, both the formatting has been changed and duplicate keys created.

So if the json was previously:

Format 1:
```json
"Azure" : {
"Tenant": "somevalue"
etc...
}
```

This ends up as

Format 2:
```json
"Azure:Tenant": "somevalue"
```

Sometimes it generates a mixture of the two formats with the duplicate keys.

If I delete the contents of the file leaving just the connection string to an external SQL resource and press f5, it will regenerate the file again, reformatting my existing settings as 'Format 2' above, and generates new settings with 'Format 1'. But if you stop debugging and start again, it all gets regenerated as 'Format 2'. It's when you go to add new resources again after that, that it seems to get a mixture of formats and duplicate keys.

### Expected Behavior

secrets.json format should be consistent, and probably stay as 'Format 1' from the description above.

### Steps To Reproduce

Create an aspire project. Configure your Azure subscription id, resource group and location in appsettings.json of AppHost.

Connect to an existing sql resource with a connection string e.g. builder.AddConnectionString, and put this connection string in secrets.json.

Connect other Azure resources like storage, configuring them in apphost, e.g. builder.AddAzureStorage.

Run the project with F5 and see if secrets.json gets mangled or duplications with each step above.

### Exceptions (if any)

Duplicate key exception for secrets.json

### .NET Version info

.NET SDK:
Version: 9.0.300-preview.0.25177.5
Commit: 3d5b396331
Workload version: 9.0.300-manifests.1e5233e8
MSBuild version: 17.14.0-preview-25175-08+5880e1c75

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.300-preview.0.25177.5\

.NET workloads installed:
[aspire]
Installation Source: VS 17.14.36015.10
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

[wasm-tools]
Installation Source: VS 17.14.36015.10
Manifest Version: 9.0.4/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.current\9.0.4\WorkloadManifest.json
Install Type: Msi

[maccatalyst]
Installation Source: VS 17.14.36015.10
Manifest Version: 18.4.9288/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maccatalyst\18.4.9288\WorkloadManifest.json
Install Type: Msi

[maui-windows]
Installation Source: VS 17.14.36015.10
Manifest Version: 9.0.14/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maui\9.0.14\WorkloadManifest.json
Install Type: Msi

[android]
Installation Source: VS 17.14.36015.10
Manifest Version: 35.0.61/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.android\35.0.61\WorkloadManifest.json
Install Type: Msi

[ios]
Installation Source: VS 17.14.36015.10
Manifest Version: 18.4.9288/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.ios\18.4.9288\WorkloadManifest.json
Install Type: Msi

Configured to use loose manifests when installing new manifests.

Host:
Version: 9.0.4
Architecture: x64
Commit: f57e6dc747

.NET SDKs installed:
8.0.408 [C:\Program Files\dotnet\sdk]
9.0.203 [C:\Program Files\dotnet\sdk]
9.0.300-preview.0.25177.5 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.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:
Not found

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

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

### Anything else?

Aspire 9.2
VS 2022 Version 17.14.0 Preview 3.0
.NET Core 9.0.4

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.