Chorn.Aspire.ExternalProject 1.1.0

dotnet add package Chorn.Aspire.ExternalProject --version 1.1.0                
NuGet\Install-Package Chorn.Aspire.ExternalProject -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Chorn.Aspire.ExternalProject" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Chorn.Aspire.ExternalProject --version 1.1.0                
#r "nuget: Chorn.Aspire.ExternalProject, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Chorn.Aspire.ExternalProject as a Cake Addin
#addin nuget:?package=Chorn.Aspire.ExternalProject&version=1.1.0

// Install Chorn.Aspire.ExternalProject as a Cake Tool
#tool nuget:?package=Chorn.Aspire.ExternalProject&version=1.1.0                

Aspire.ExternalProject

Aspire.ExternalProject is a .NET Aspire package to add a .NET project that is external to the current solution.

NuGet version (Chorn.Aspire.ExternalProject)

Usage

Install the package from NuGet:

dotnet add package Chorn.Aspire.ExternalProject

You can now add an external project via its csproj file in your app host:

builder.AddExternalProject("resourcename", "path/to/external/project.csproj");

This will add the project as an executable resource and wire up all the magic that the normal Aspire AddProject method does. In addition it will use 'dotnet run' to start the external project so automatic build and run should work as expected.

To debug the external project, you can use the Debug command in the dashboard or just attach the debugger manually from your IDE.

It will also add two commands to the dashboard:

  • 'Debug' - Starts the debugger for the external project by starting the manual 'attach to VisualStudio' process.
  • 'Git Pull" - Pulls the latest changes from the git repository of the external project.

You can remove the GIT integration by setting the SkipGitSupport in the resource options.

builder.AddExternalProject("resourcename", "path/to/external/project.csproj", options => {
	options.SkipGitSupport = true;
});

You can add a GIT up-to-date health check to the external project by setting the EnableGitHealthCheck in the resource options.

builder.AddExternalProject("resourcename", "path/to/external/project.csproj", options => {
	options.EnableGitHealthCheck = true;
});

By default we use vsjitdebugger to attach the debugger to the external project. This does not seem to work reliably, as a viable alternative you can set the DebuggerUri in the resource options to call an endpoint in your external project to start the debugger via Debugger.Launch(). (See the sample for the external project code)

builder.AddExternalProject("resourcename", "path/to/external/project.csproj", options => {
	options.LaunchDebuggerUri = "/debugger";
});

Limitations and Known Issues

  • Currently the ExcludeLaunchProfile and ExcludeKestrelEndpoint properties on the resource options are ignored.
  • Publish operations probably won't work as expected.
  • Starting the debugger via the default 'Debug' command in the dashboard might not attach correctly via vsjitdebugger.
  • Running multiple external projects at the same time might lead to build problems if they have common dependencies. If you run into any issues try an explicit start for the external projects to avoid this issue. (see here for the code)

Motivation

Often it is not feasible to have a single solution for all projects, especially when working across multiple repositories. With this package you can temporarily add and remove external projects to your Aspire app host without having to add them to your solution while still being able to debug them.

Technical Details

We bascially replicate the work done in the AddProject method, but with a few tweaks to make it work with external projects.

Starting the debugger is done by starting the vsjitdebugger process with the pid of the external project.

Future Work

  • Add support for the ExcludeLaunchProfile and ExcludeKestrelEndpoint properties.
  • Replicate the publish functionality if possible.
  • Maybe switch to a custom resource type to make the external project more visible in the dashboard.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 71 2/17/2025
1.0.0 65 2/16/2025
1.0.0-rc4 58 2/15/2025
1.0.0-rc3 63 2/15/2025
1.0.0-rc2 59 2/15/2025

v.1.1.0
- Improved pid retrieval and added option to launch a debugger from inside the external project
v.1.0.0
- First release