.NET Aspire is renowned for its robust support for monolithic repositories, allowing developers to manage large codebases efficiently. However, when it comes to poly repos, where multiple repositories are involved, the process isn’t as straightforward. Enter Aspire.PolyRepo, a .NET Aspire package designed to bridge this gap and provide seamless poly repo support.
Introducing Aspire.PolyRepo
Aspire.PolyRepo simplifies the process of cloning and managing Git repositories within your .NET Aspire applications. This package allows you to configure and integrate Git repositories effortlessly, streamlining your cloud-native development workflow.
Key Features
Clone Git repositories directly into your .NET Aspire application.
Configure repository URL, name, target path, default branch, and project path.
Easy integration with .NET Aspire App Host.
Installation
To install the Aspire.PolyRepo package, use the .NET CLI. Run the following command in your terminal:
Usage
Here’s a step-by-step guide to using Aspire.PolyRepo in your .NET Aspire application:
Step 1: Add a Repository Resource
First, add the necessary configuration to your App Host project. Below is an example of how to configure a Git repository:
var repository = builder.AddRepository(
“repository”,
“https://github.com/Dutchskull/Aspire-Git.git”,
c => c.WithDefaultBranch(“feature/rename_and_new_api”)
.WithTargetPath(“../../repos”));
Step 2: Add Projects from the Repository
You can add various types of projects from the repository. Here’s how you can add a .NET project:
.AddProjectFromRepository(“dotnetProject”, repository,
“src/Dutchskull.Aspire.PolyRepo.Web/Dutchskull.Aspire.PolyRepo.Web.csproj”)
.WithReference(cache)
.WithReference(apiService);
Aspire.PolyRepo also supports adding npm and node applications. These methods share the initial parameters with AddProjectFromRepository, but their additional parameters are specific to npm and node configurations:
.AddNpmAppFromRepository(“reactProject”, repository, “src/Dutchskull.Aspire.PolyRepo.React”)
.WithReference(cache)
.WithReference(apiService)
.WithHttpEndpoint(3000);
var nodeProject = builder
.AddNodeAppFromRepository(“nodeProject”, repository, “src/Dutchskull.Aspire.PolyRepo.Node”)
.WithReference(cache)
.WithReference(apiService)
.WithHttpEndpoint(54622);
Step 3: Navigate to Your App Host Project Directory
Open your terminal and navigate to the directory of your App Host project.
Step 4: Run the Application
Use the .NET CLI or Visual Studio 2022 to run your application:
This configuration clones the specified Git repository into your application, enabling seamless integration and development across multiple projects.
Recap
Aspire.PolyRepo is the solution for those seeking to manage multiple repositories within their .NET Aspire applications easily. By following the simple steps outlined above, you can configure and run your applications, leveraging the power of poly repo support. With its straightforward setup and robust feature set, Aspire.PolyRepo ensures that managing multiple repositories becomes a hassle-free part of your development workflow.