-
Notifications
You must be signed in to change notification settings - Fork 57
Add test project upgrade guidance to upgrade-aspire page #512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -72,6 +72,52 @@ Please remove the **aspire workload** with the following command: | |||||
| dotnet workload uninstall aspire | ||||||
| ``` | ||||||
|
|
||||||
| ## Upgrade test projects | ||||||
|
|
||||||
| If your solution includes an Aspire test project (one that references [📦 Aspire.Hosting.Testing](https://www.nuget.org/packages/Aspire.Hosting.Testing)), you'll need to update it alongside your AppHost. | ||||||
|
|
||||||
| <Steps> | ||||||
|
|
||||||
| 1. **Update the `Aspire.Hosting.Testing` package** to match the version of your updated AppHost: | ||||||
|
|
||||||
| ```bash title="Update the testing package" | ||||||
| dotnet add <your-test-project>.csproj package Aspire.Hosting.Testing | ||||||
| ``` | ||||||
|
|
||||||
| <Aside type="tip"> | ||||||
| If you're using Central Package Management (CPM), update the version in your _Directory.Packages.props_ file instead. | ||||||
| </Aside> | ||||||
|
|
||||||
| 2. **Verify the project reference to the AppHost** exists in your test project: | ||||||
|
|
||||||
| ```xml title="YourApp.Tests.csproj" | ||||||
| <ItemGroup> | ||||||
| <ProjectReference Include="..\YourApp.AppHost\YourApp.AppHost.csproj" /> | ||||||
| </ItemGroup> | ||||||
| ``` | ||||||
|
|
||||||
| This reference is required for the `Projects` namespace to be generated, which is how `DistributedApplicationTestingBuilder.CreateAsync<Projects.YourApp_AppHost>()` resolves your AppHost. | ||||||
|
|
||||||
| 3. **Run your tests** to verify everything still works: | ||||||
|
|
||||||
| ```bash title="Run tests" | ||||||
| dotnet test | ||||||
| ``` | ||||||
|
|
||||||
| </Steps> | ||||||
|
|
||||||
| <Aside type="caution" title="Projects namespace not found?"> | ||||||
| If your tests fail to compile with an error that the `Projects` namespace doesn't exist, ensure: | ||||||
|
|
||||||
| - Your AppHost project uses the [`Aspire.AppHost.Sdk`](/get-started/aspire-sdk/) (for example, `<Project Sdk="Aspire.AppHost.Sdk/13.1">`). | ||||||
|
||||||
| - Your AppHost project uses the [`Aspire.AppHost.Sdk`](/get-started/aspire-sdk/) (for example, `<Project Sdk="Aspire.AppHost.Sdk/13.1">`). | |
| - Your AppHost project uses the [`Aspire.AppHost.Sdk`](/get-started/aspire-sdk/) (for example, `<Project Sdk="Aspire.AppHost.Sdk/<version>">`, where `<version>` matches the SDK version used by your AppHost). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Step 1 says to update
Aspire.Hosting.Testingto match the AppHost version, but the command shown doesn't specify a version and will resolve whatever NuGet considers "latest" (which may not match the AppHost/SDK version, especially if users are upgrading to a specific version or using previews). Consider showing the command with an explicit--version(matchingAspire.AppHost.Sdk/ the package versions in the solution), or otherwise clarifying that it will update to the latest available.