microsoft / microsoft/aspire

DistributedApplicationTestingBuilder unable to load sqlproj when attempting to apply

Open
#13,842 2 comments 1 reaction 0 assignees View on GitHub
area-app-testing area-integrations
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

The DistributedApplicationTestingBuilder used in integration tests (https://aspire.dev/testing/overview/) fails to run due to it being unable to read .sqlproj files when starting the apphost.

The error occurred after the upgrade to dotnet 10 and aspire 13.1.0 from dotnet 9 and aspire 9.5.2.

Image

**Steps to reproduce.**
* Create a sql project
* Create an app host
* Reference the sql project
* Reference the aspire sql community tools
* Reference and apply the sql project to a database in the apphost
* Verify the apphost runs and applies the dacpac
* Create a new project and reference the apphost
* Run the apphost via the DistributedApplicationTestingBuilder and the following error is reproduced.

**Key code**
DistributedApplicationTestingBuilder does not like the following (in the apphost).
```csharp
var errorDatabaseProject = builder.AddSqlProject(Constants.DatabaseDefinition)
.WithReference(database);
```
It may be worked around with the following code.
```csharp
var errorDatabaseProject = builder.AddSqlProject(Constants.DatabaseDefinition)
.WithDacpac("../sql/bin/aspire-error.dacpac")
.WithReference(database);
```

### Expected Behavior

The project should be correctly loaded under the DistributedApplicationTestingBuilder and apply the database project to the database.

### Steps To Reproduce

https://github.com/garrickwelsh/aspire-sql-error-replication
Please run the ```bash dotnet --project aspire-error``` to replicate the error.

A devcontainer has been included so exact replication of the environment used that the error occurs in can be seen if it is not reproducible on your platform.

### Exceptions (if any)

fail: aspire-apphost.Resources.AspireDatabaseErrorProject[0]
1: 2026-01-12T02:58:33.4016027Z Failed to publish database project.
Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "/usr/share/dotnet/sdk/10.0.101/15.0/Microsoft.Common.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. /usr/share/dotnet/sdk/10.0.101/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.props
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Shared.ProjectErrorUtilities.VerifyThrowInvalidProject[T1](Boolean condition, String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, T1 arg0)
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1](IElementLocation elementLocation, String resourceName, T1 arg0)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpression(String directoryOfImportingFile, ProjectImportElement importElement, String unescapedExpression, Boolean throwOnFileNotExistsError, List`1& imports)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, SdkResult& sdkResult, Boolean throwOnFileNotExistsError)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(ILoggingService loggingService, BuildEventContext buildEventContext)
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(IEvaluatorData`4 data, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ILoggingService loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, ProjectCollection projectCollection)
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, String toolsVersion)
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName)
at Aspire.Hosting.ApplicationModel.SqlProjectResource.Aspire.Hosting.ApplicationModel.IResourceWithDacpac.GetDacpacPath() in /_/src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/SqlProjectResource.cs:line 24
at CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects.SqlProjectPublishService.PublishSqlProject(IResourceWithDacpac resource, IResourceWithConnectionString target, String targetDatabaseName, CancellationToken cancellationToken) in /_/src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/SqlProjectPublishService.cs:line 19

### .NET Version info

.NET SDK:
Version: 10.0.101
Commit: fad253f51b
Workload version: 10.0.101.1
MSBuild version: 18.0.6+fad253f51

Runtime Environment:
OS Name: ubuntu
OS Version: 24.04
OS Platform: Linux
RID: linux-x64
Base Path: /usr/share/dotnet/sdk/10.0.101/

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.

Host:
Version: 10.0.1
Architecture: x64
Commit: fad253f51b

.NET SDKs installed:
8.0.416 [/usr/share/dotnet/sdk]
9.0.308 [/usr/share/dotnet/sdk]
10.0.101 [/usr/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.22 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.11 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.22 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.11 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
DOTNET_ROOT [/usr/share/dotnet]
DOTNET_RUNNING_IN_CONTAINER [true]
DOTNET_USE_POLLING_FILE_WATCHER [true]

global.json file:
Not found

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

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

### Anything else?

Key versions for replication.

Asp.net core 10.0.1
.net sdk 10.0.101
Aspire.Hosting (AppHost, SqlServer and Testing) - 13.1.0
CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects - 13.0.0

Contributor guide

Open the contributing guide

Research direction

Start by running `dotnet --project aspire-error` from the linked reproduction and inspect the failure in `SqlProjectResource.cs` and `SqlProjectPublishService.cs`, especially the `Microsoft.Common.props` load reported in the stack trace. Done means `DistributedApplicationTestingBuilder` loads the referenced `.sqlproj` and applies its dacpac without requiring the `.WithDacpac` workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
backend, databases, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.