microsoft / microsoft/aspire

Unable to add package Aspire.Hosting.MongoDB to AppHost, dependencies don't support any target frameworks

Open
#7,281 5 comments 0 reactions 0 assignees View on GitHub
area-tooling
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

When attempting to add package `Aspire.Hosting.MongoDB` to my AppHost project [per the instructions](https://learn.microsoft.com/en-us/dotnet/aspire/database/mongodb-integration?tabs=dotnet-cli#hosting-integration), the installation is rolled back with the following errors:
```text
Restoring packages for e:\dev\AspireApp2\AspireApp2.AppHost\AspireApp2.AppHost.csproj...
CACHE https://api.nuget.org/v3/vulnerabilities/index.json
CACHE https://api.nuget.org/v3-vulnerabilities/2025.01.24.05.38.39/vulnerability.base.json
CACHE https://api.nuget.org/v3-vulnerabilities/2025.01.24.05.38.39/2025.01.27.11.38.48/vulnerability.update.json
NU1202: Package System.Runtime.CompilerServices.Unsafe 5.0.0 is not compatible with net9.0 (.NETCoreApp,Version=v9.0). Package System.Runtime.CompilerServices.Unsafe 5.0.0 does not support any target frameworks.
NU1202: Package System.Buffers 4.5.1 is not compatible with net9.0 (.NETCoreApp,Version=v9.0). Package System.Buffers 4.5.1 does not support any target frameworks.
Package restore failed. Rolling back package changes for 'AspireApp2.AppHost'.
```

This happens whether adding via the NuGet package manager in VS 2022 or via the command line using `dotnet add package Aspire.Hosting.MongoDB`

I tested this using a personal project as well as a new project created using the ".NET Aspire Starter App" template.

### Expected Behavior

Able to add the `Aspire.Hosting.MongoDB` package as described in the [MongoDB Aspire Integration docs](https://learn.microsoft.com/en-us/dotnet/aspire/database/mongodb-integration?tabs=dotnet-cli#hosting-integration).

### Steps To Reproduce

1. Create a new project using the ".NET Aspire Starter App" template.
2. Select Framework .NET 9.0 (selection for Redis caching does not matter, issue happens with this checked or unchecked)
3. Once the project is created, verify it runs using F5
4. Add `Aspire.Hosting.MongoDB` package using either "Manage Packages for Solution" in VS 2022 IDE or via command line
5. Observe errors in the output and Error List windows.

Example repo located at [TallBaldGeek/AspireMongoDBPackageIssue](https://github.com/TallBaldGeek/AspireMongoDBPackageIssue). (It's just the results of steps 1-3 above but including in case it helps)

### Exceptions (if any)

NA

### .NET Version info

.NET SDK:
Version: 9.0.102
Commit: cb83cd4923
Workload version: 9.0.100-manifests.4a54b1a6
MSBuild version: 17.12.18+ed8c6aec5

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.102\

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

[maui-windows]
Installation Source: VS 17.12.35707.178
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

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

[aspire]
Installation Source: VS 17.12.35707.178
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

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

Configured to use loose manifests when installing new manifests.

Host:
Version: 9.0.1
Architecture: x64
Commit: c8acea2262

.NET SDKs installed:
9.0.102 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.1 [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?

AppHost .csproj as generated by the template:
```csproj


Exe
net9.0
enable
enable
true
9f1bc317-378f-4e39-a33d-51719d58808a






```

VS 2022 info:
``` text
Microsoft Visual Studio Community 2022
Version 17.12.4
VisualStudio.17.Release/17.12.4+35707.178
Microsoft .NET Framework
Version 4.8.09032

Installed Version: Community

ADL Tools Service Provider 1.0
This package contains services used by Data Lake tools

ASA Service Provider 1.0

ASP.NET and Web Tools 17.12.178.10385
ASP.NET and Web Tools

Azure App Service Tools v3.0.0 17.12.178.10385
Azure App Service Tools v3.0.0

Azure Data Lake Tools for Visual Studio 2.6.5000.0
Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools 17.12.178.10385
Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio 2.6.5000.0
Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools 4.12.0-3.24631.1+da7c6c4257b2f661024b9a506773372a09023eee
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus 1.4.42 (main@840f8b3)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

GitHub Copilot 17.12.53.23981
GitHub Copilot is an AI pair programmer that helps you write code faster and with less work.

Microsoft Azure Hive Query Language Service 2.6.5000.0
Language service for Hive query

Microsoft Azure Stream Analytics Language Service 2.6.5000.0
Language service for Azure Stream Analytics

Microsoft Azure Tools for Visual Studio 2.9
Support for Azure Cloud Services projects

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio 17.12.5 (918dbb1)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 6.12.3
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Razor (ASP.NET Core) 17.12.3.2457601+b5256abf658352440e61aa1372bbc0798e9ceb7d
Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools 17.12.83.3
Microsoft SQL Server Data Tools

ToolWindowHostedEditor 1.0
Hosting json editor into a tool window

TypeScript Tools 17.0.30918.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 4.12.0-3.24631.1+da7c6c4257b2f661024b9a506773372a09023eee
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 17.12.0-beta.24501.1+19610c0b654766eec49d044cb97ca6eaa2a63d16
Microsoft Visual F# Tools

Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.

VisualStudio.DeviceLog 1.0
Information about my package

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

VSPackage Extension 1.0
VSPackage Visual Studio Extension Detailed Info

Xamarin 17.12.0.153 (d17-12@1d0906d)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 17.12.3.17 (remotes/origin/main@0912a005b9)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK 13.2.2.0 (d17-5/45b0e14)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: d9a6e87
Java.Interop: xamarin/java.interop/d17-5@149d70fe
SQLite: xamarin/sqlite/3.40.1@68c69d8
Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d

```

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.