-
Notifications
You must be signed in to change notification settings - Fork 39
Document AspireProjectMetadataTypeName attribute for resolving project name conflicts #206
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
Conversation
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
|
Hey @copilot, please undo all formatting changes to the other files - only update the sdk article like requested. |
…pdate Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
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.
Pull request overview
This PR adds documentation for the AspireProjectMetadataTypeName attribute, which allows developers to customize generated project names in the Aspire SDK's Projects namespace. This addresses a gap in the documentation for handling scenarios where multiple projects have the same name.
Key Changes
- Documents the
AspireProjectMetadataTypeNameattribute and its purpose for resolving project name conflicts - Provides a practical example showing how to differentiate two projects with identical names using custom type names
- Includes both XML configuration and C# usage examples
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hey @copilot, please take a screenshot of the page, but before you do - please reject all cookies by clicking the Reject all button:
|
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Screenshot of the updated page showing the "Customizing generated project names" section: Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
|
||
| When you reference a project in the AppHost, the Aspire SDK generates a strongly-typed class in the `Projects` namespace. By default, the generated class name is based on the project's name. However, if you have multiple projects with the same name or want to customize the generated type name, you can use the `AspireProjectMetadataTypeName` attribute. | ||
|
|
||
| For example, if you have two microservices with the same project name (like `Presentation.Api`), you can differentiate them by setting custom names: |
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.
| For example, if you have two microservices with the same project name (like `Presentation.Api`), you can differentiate them by setting custom names: | |
| For example, if you have two services with the same project name (like `Presentation.Api`), you can differentiate them by setting custom names: |
| <ProjectReference Include="..\Microservice1\Presentation.Api\Presentation.Api.csproj" | ||
| AspireProjectMetadataTypeName="MicroService1" /> | ||
| <ProjectReference Include="..\Microservice2\Presentation.Api\Presentation.Api.csproj" | ||
| AspireProjectMetadataTypeName="MicroService2" /> |
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.
| <ProjectReference Include="..\Microservice1\Presentation.Api\Presentation.Api.csproj" | |
| AspireProjectMetadataTypeName="MicroService1" /> | |
| <ProjectReference Include="..\Microservice2\Presentation.Api\Presentation.Api.csproj" | |
| AspireProjectMetadataTypeName="MicroService2" /> | |
| <ProjectReference Include="..\Service1\Presentation.Api\Presentation.Api.csproj" | |
| AspireProjectMetadataTypeName="Service1" /> | |
| <ProjectReference Include="..\Service2\Presentation.Api\Presentation.Api.csproj" | |
| AspireProjectMetadataTypeName="Service2" /> |
| </ItemGroup> | ||
| ``` | ||
|
|
||
| This generates `Projects.MicroService1` and `Projects.MicroService2` classes, allowing you to reference each project distinctly in 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.
| This generates `Projects.MicroService1` and `Projects.MicroService2` classes, allowing you to reference each project distinctly in your AppHost: | |
| This generates `Projects.Service1` and `Projects.Service2` classes, allowing you to reference each project distinctly in your AppHost: |
| var microservice1 = builder.AddProject<Projects.MicroService1>("micro1"); | ||
| var microservice2 = builder.AddProject<Projects.MicroService2>("micro2"); |
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.
| var microservice1 = builder.AddProject<Projects.MicroService1>("micro1"); | |
| var microservice2 = builder.AddProject<Projects.MicroService2>("micro2"); | |
| var microservice1 = builder.AddProject<Projects.Service1>("service1"); | |
| var microservice2 = builder.AddProject<Projects.Service2>("service2"); |

Documentation update for AspireProjectMetadataTypeName attribute
Summary of Changes
Added a new subsection "Customizing generated project names" under the "Project references" section in
aspire-sdk.mdxthat documents theAspireProjectMetadataTypeNameattribute.The documentation explains:
ProjectsnamespaceUpdates:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.