Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d1e59c7
Initial plan
Copilot Oct 27, 2025
c43ef5a
Remove AddViteApp and npm-specific functionality (moved to Aspire 13)
Copilot Oct 27, 2025
b683a1b
Update comments and tests to reflect npm removal
Copilot Oct 27, 2025
bc1c7d9
Update MONOREPO.md to remove npm references
Copilot Oct 27, 2025
4bd1ef5
Adding missing types
aaronpowell Oct 28, 2025
5c8b887
Bad copilot code
aaronpowell Oct 28, 2025
24b5986
Fixing missing namespace
aaronpowell Oct 28, 2025
e1a58b4
Handling port forwarding
aaronpowell Oct 28, 2025
4a1dbe9
removing more stuff that has been migrated to aspire core
aaronpowell Oct 28, 2025
9fbe7fd
Reworking how package installing is handled
aaronpowell Oct 28, 2025
5c63829
daily update
aaronpowell Oct 29, 2025
caeb29a
Adding back the annotation that is no longer moving to core
aaronpowell Oct 30, 2025
995fb1e
Forgot to install packages
aaronpowell Oct 30, 2025
9a14467
adding a bunch more annotations to provide enough metadata
aaronpowell Oct 30, 2025
21cec02
Removing old demo apps
aaronpowell Oct 30, 2025
e9e3f95
Disabling python tests
aaronpowell Oct 30, 2025
30b2855
Removing a testing change
aaronpowell Oct 30, 2025
6b90888
Updating to the latest nightly and dealing with type name changes
aaronpowell Nov 3, 2025
30e74a5
Removing type that was can repurpose from aspire core
aaronpowell Nov 3, 2025
d8b58f2
breaking the tests down so they are easier to read
aaronpowell Nov 3, 2025
90b9393
Removing legacy docs
aaronpowell Nov 3, 2025
4ad9ede
Fixing failing tests
aaronpowell Nov 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
var builder = DistributedApplication.CreateBuilder(args);

builder.AddViteApp("vite-demo")
.WithNpmPackageInstallation()
.WithHttpHealthCheck();

builder.AddViteApp("yarn-demo", packageManager: "yarn")
// Yarn and pnpm support examples
builder.AddYarnApp("yarn-demo", "../yarn-demo")
.WithYarnPackageInstallation()
.WithHttpEndpoint()
.WithHttpHealthCheck();

builder.AddViteApp("pnpm-demo", packageManager: "pnpm")
builder.AddPnpmApp("pnpm-demo", "../pnpm-demo")
.WithPnpmPackageInstallation()
.WithHttpEndpoint()
.WithHttpHealthCheck();

// Example of Nx monorepo support - uncomment if you have an Nx workspace
// Example of Nx monorepo support with yarn - uncomment if you have an Nx workspace
var nx = builder.AddNxApp("nx-demo")
.WithNpmPackageInstaller();
.WithYarnPackageInstaller();

nx.AddApp("blog-monorepo")
.WithHttpEndpoint()
.WithMappedEndpointPort()
.WithHttpHealthCheck();

// Example of Turborepo monorepo support - uncomment if you have a Turborepo workspace
// Example of Turborepo monorepo support with pnpm - uncomment if you have a Turborepo workspace
var turbo = builder.AddTurborepoApp("turborepo-demo")
.WithNpmPackageInstaller();
.WithPnpmPackageInstaller();

turbo.AddApp("turbo-web", filter: "web")
.WithHttpEndpoint()
Expand Down

This file was deleted.

This file was deleted.

20 changes: 10 additions & 10 deletions src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/MONOREPO.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Use the new monorepo-specific extension methods that create a shared package ins

```csharp
var nx = builder.AddNxApp("nx", workingDirectory: "../frontend")
.WithNpmPackageInstaller(); // Single shared installer
.WithYarnPackageInstaller(); // Single shared installer

var app1 = nx.AddApp("app1");
var app2 = nx.AddApp("app2", appName: "my-app-2"); // Custom app name for nx serve
Expand All @@ -37,7 +37,7 @@ var app3 = nx.AddApp("app3");

```csharp
var turbo = builder.AddTurborepoApp("turbo", workingDirectory: "../frontend")
.WithYarnPackageInstaller(); // Single shared installer
.WithPnpmPackageInstaller(); // Single shared installer

var app1 = turbo.AddApp("app1");
var app2 = turbo.AddApp("app2", filter: "custom-filter"); // Custom filter
Expand All @@ -46,12 +46,13 @@ var app3 = turbo.AddApp("app3");

## Package Managers

Both Nx and Turborepo support all three package managers:
Both Nx and Turborepo support yarn and pnpm package managers:

- `.WithNpmPackageInstaller()` - uses npm (supports `useCI` parameter)
- `.WithYarnPackageInstaller()` - uses yarn
- `.WithPnpmPackageInstaller()` - uses pnpm

> **Note**: npm support (`AddNpmApp`, `WithNpmPackageInstallation`) is now provided by [Aspire.Hosting.NodeJS](https://www.nuget.org/packages/Aspire.Hosting.NodeJS) starting with Aspire 13.

### Configuring Package Manager for App Execution

Use `RunWithPackageManager()` to configure which package manager command is used when running individual apps:
Expand All @@ -64,16 +65,15 @@ var nx = builder.AddNxApp("nx", workingDirectory: "../frontend")

// Explicitly specify package manager (independent of installer)
var turbo = builder.AddTurborepoApp("turbo", workingDirectory: "../frontend")
.WithNpmPackageInstaller()
.RunWithPackageManager("pnpm"); // Uses 'pnpm' despite npm installer
.WithPnpmPackageInstaller()
.RunWithPackageManager("yarn"); // Uses 'yarn' despite pnpm installer

// Without RunWithPackageManager - uses default commands
var nxDefault = builder.AddNxApp("nx-default", workingDirectory: "../frontend");
nxDefault.AddApp("app1"); // Runs: nx serve app1 (no package manager prefix)
```

**Command Generation Examples:**
- `RunWithPackageManager("npm")` → `npx nx serve app1` or `npx turbo run dev --filter app1`
- `RunWithPackageManager("yarn")` → `yarn nx serve app1` or `yarn turbo run dev --filter app1`
- `RunWithPackageManager("pnpm")` → `pnpm nx serve app1` or `pnpm turbo run dev --filter app1`
- No `RunWithPackageManager()` → `nx serve app1` or `turbo run dev --filter app1`
Expand Down Expand Up @@ -131,13 +131,13 @@ This provides cleaner syntax and automatic dependency management.

It's important to understand the difference between package installation and app execution:

- **Package Installer** (`.WithNpmPackageInstaller()`, etc.) - Controls how packages are installed in the workspace
- **Package Installer** (`.WithYarnPackageInstaller()`, `.WithPnpmPackageInstaller()`) - Controls how packages are installed in the workspace
- **Package Manager for Apps** (`.RunWithPackageManager()`) - Controls which command is used to run individual apps

```csharp
var nx = builder.AddNxApp("nx", workingDirectory: "../frontend")
.WithNpmPackageInstaller() // Install packages with: npm install
.WithPnpmPackageInstaller() // Install packages with: pnpm install
.RunWithPackageManager("yarn"); // Run apps with: yarn nx serve app1

// This is valid - you can install with npm but run apps with yarn
// This is valid - you can install with pnpm but run apps with yarn
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,7 @@ namespace Aspire.Hosting;
/// </summary>
public static partial class NodeJSHostingExtensions
{
/// <summary>
/// Ensures the Node.js packages are installed before the application starts using npm as the package manager.
/// </summary>
/// <param name="resource">The Node.js app resource.</param>
/// <param name="useCI">When true use <code>npm ci</code> otherwise use <code>npm install</code> when installing packages.</param>
/// <param name="configureInstaller">Configure the npm installer resource.</param>
/// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns>
public static IResourceBuilder<NodeAppResource> WithNpmPackageInstallation(this IResourceBuilder<NodeAppResource> resource, bool useCI = false, Action<IResourceBuilder<NpmInstallerResource>>? configureInstaller = null)
{
// Only install packages during development, not in publish mode
if (!resource.ApplicationBuilder.ExecutionContext.IsPublishMode)
{
var installerName = $"{resource.Resource.Name}-npm-install";
var installer = new NpmInstallerResource(installerName, resource.Resource.WorkingDirectory);

var installerBuilder = resource.ApplicationBuilder.AddResource(installer)
.WithArgs([useCI ? "ci" : "install"])
.WithParentRelationship(resource.Resource)
.ExcludeFromManifest();

// Make the parent resource wait for the installer to complete
resource.WaitForCompletion(installerBuilder);

configureInstaller?.Invoke(installerBuilder);

resource.WithAnnotation(new JavaScriptPackageInstallerAnnotation(installer));
}

return resource;
}

/// <summary>
/// Ensures the Node.js packages are installed before the application starts using yarn as the package manager.
Expand Down Expand Up @@ -99,33 +70,7 @@ public static IResourceBuilder<NodeAppResource> WithPnpmPackageInstallation(this
return resource;
}

/// <summary>
/// Ensures the Node.js packages are installed before the Nx workspace applications start using npm as the package manager.
/// </summary>
/// <param name="resource">The Nx workspace resource.</param>
/// <param name="useCI">When true use <code>npm ci</code> otherwise use <code>npm install</code> when installing packages.</param>
/// <param name="configureInstaller">Configure the npm installer resource.</param>
/// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns>
public static IResourceBuilder<NxResource> WithNpmPackageInstaller(this IResourceBuilder<NxResource> resource, bool useCI = false, Action<IResourceBuilder<NpmInstallerResource>>? configureInstaller = null)
{
// Only install packages during development, not in publish mode
if (!resource.ApplicationBuilder.ExecutionContext.IsPublishMode)
{
var installerName = $"{resource.Resource.Name}-npm-install";
var installer = new NpmInstallerResource(installerName, resource.Resource.WorkingDirectory);

var installerBuilder = resource.ApplicationBuilder.AddResource(installer)
.WithArgs([useCI ? "ci" : "install"])
.WithParentRelationship(resource.Resource)
.ExcludeFromManifest();

configureInstaller?.Invoke(installerBuilder);

resource.WithAnnotation(new JavaScriptPackageInstallerAnnotation(installer));
}

return resource;
}

/// <summary>
/// Ensures the Node.js packages are installed before the Nx workspace applications start using yarn as the package manager.
Expand Down Expand Up @@ -181,33 +126,7 @@ public static IResourceBuilder<NxResource> WithPnpmPackageInstaller(this IResour
return resource;
}

/// <summary>
/// Ensures the Node.js packages are installed before the Turborepo workspace applications start using npm as the package manager.
/// </summary>
/// <param name="resource">The Turborepo workspace resource.</param>
/// <param name="useCI">When true use <code>npm ci</code> otherwise use <code>npm install</code> when installing packages.</param>
/// <param name="configureInstaller">Configure the npm installer resource.</param>
/// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns>
public static IResourceBuilder<TurborepoResource> WithNpmPackageInstaller(this IResourceBuilder<TurborepoResource> resource, bool useCI = false, Action<IResourceBuilder<NpmInstallerResource>>? configureInstaller = null)
{
// Only install packages during development, not in publish mode
if (!resource.ApplicationBuilder.ExecutionContext.IsPublishMode)
{
var installerName = $"{resource.Resource.Name}-npm-install";
var installer = new NpmInstallerResource(installerName, resource.Resource.WorkingDirectory);

var installerBuilder = resource.ApplicationBuilder.AddResource(installer)
.WithArgs([useCI ? "ci" : "install"])
.WithParentRelationship(resource.Resource)
.ExcludeFromManifest();

configureInstaller?.Invoke(installerBuilder);

resource.WithAnnotation(new JavaScriptPackageInstallerAnnotation(installer));
}

return resource;
}

/// <summary>
/// Ensures the Node.js packages are installed before the Turborepo workspace applications start using yarn as the package manager.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,7 @@
/// </summary>
public static partial class NodeJSHostingExtensions
{
/// <summary>
/// Adds a Vite app to the distributed application builder.
/// </summary>
/// <param name="builder">The <see cref="IDistributedApplicationBuilder"/> to add the resource to.</param>
/// <param name="name">The name of the Vite app.</param>
/// <param name="workingDirectory">The working directory of the Vite app. If not specified, it will be set to a path that is a sibling of the AppHost directory using the <paramref name="name"/> as the folder.</param>
/// <param name="packageManager">The package manager to use. Default is npm.</param>
/// <param name="useHttps">When true use HTTPS for the endpoints, otherwise use HTTP.</param>
/// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns>
/// <remarks>This uses the specified package manager (default npm) method internally but sets defaults that would be expected to run a Vite app, such as the command to run the dev server and exposing the HTTP endpoints.</remarks>
public static IResourceBuilder<NodeAppResource> AddViteApp(this IDistributedApplicationBuilder builder, [ResourceName] string name, string? workingDirectory = null, string packageManager = "npm", bool useHttps = false)
{
ArgumentNullException.ThrowIfNull(builder);
ArgumentNullException.ThrowIfNull(name);
ArgumentNullException.ThrowIfNull(packageManager);

string wd = workingDirectory ?? Path.Combine("..", name);

var resource = packageManager switch
{
"yarn" => builder.AddYarnApp(name, wd, "dev"),
"pnpm" => builder.AddPnpmApp(name, wd, "dev"),
_ => builder.AddNpmApp(name, wd, "dev")
};

_ = useHttps
? resource.WithHttpsEndpoint(env: "PORT")
: resource.WithHttpEndpoint(env: "PORT");

return resource
.WithAnnotation(new JavaScriptPackageManagerAnnotation(packageManager))
.WithMappedEndpointPort();
}

/// <summary>
/// Adds a Node.js app to the distributed application builder using yarn as the package manager.
Expand Down Expand Up @@ -153,7 +121,7 @@
appName ??= name;

string command = "nx";
if (builder.Resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var packageManagerAnnotation))

Check failure on line 124 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-ubuntu-latest

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 124 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 124 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-windows-latest

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 124 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)
{
command = packageManagerAnnotation.PackageManager switch
{
Expand All @@ -169,7 +137,7 @@
.WithNodeDefaults()
.WithArgs((ctx) =>
{
if (builder.Resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var packageManager))

Check failure on line 140 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-ubuntu-latest

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 140 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 140 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-windows-latest

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 140 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)
{
ctx.Args.Add("nx");
}
Expand All @@ -179,7 +147,7 @@
})
.WithParentRelationship(builder.Resource);

if (builder.Resource.TryGetLastAnnotation<JavaScriptPackageInstallerAnnotation>(out var installerAnnotation))

Check failure on line 150 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-ubuntu-latest

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 150 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 150 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-windows-latest

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 150 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)
{
rb.WaitForCompletion(builder.ApplicationBuilder.CreateResourceBuilder(installerAnnotation.Resource));
}
Expand All @@ -205,7 +173,7 @@
filter ??= name;

string command = "turbo";
if (builder.Resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var packageManagerAnnotation))

Check failure on line 176 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-ubuntu-latest

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 176 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 176 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-windows-latest

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 176 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)
{
command = packageManagerAnnotation.PackageManager switch
{
Expand All @@ -221,7 +189,7 @@
.WithNodeDefaults()
.WithArgs((ctx) =>
{
if (builder.Resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var packageManager))

Check failure on line 192 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-ubuntu-latest

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 192 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 192 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-windows-latest

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 192 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)
{
ctx.Args.Add("turbo");
}
Expand All @@ -233,7 +201,7 @@
})
.WithParentRelationship(builder.Resource);

if (builder.Resource.TryGetLastAnnotation<JavaScriptPackageInstallerAnnotation>(out var installerAnnotation))

Check failure on line 204 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-ubuntu-latest

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 204 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 204 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-windows-latest

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 204 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)
{
rb.WaitForCompletion(builder.ApplicationBuilder.CreateResourceBuilder(installerAnnotation.Resource));
}
Expand All @@ -254,9 +222,9 @@
{
ArgumentNullException.ThrowIfNull(builder);

builder.Resource.TryGetLastAnnotation<JavaScriptPackageInstallerAnnotation>(out var installerAnnotation);

Check failure on line 225 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-ubuntu-latest

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 225 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 225 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-windows-latest

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 225 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

if (builder.Resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var existingAnnotation))

Check failure on line 227 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-ubuntu-latest

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 227 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 227 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-windows-latest

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 227 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)
{
if (installerAnnotation is null || existingAnnotation.PackageManager == installerAnnotation.Resource.Command)
{
Expand All @@ -273,7 +241,7 @@
throw new InvalidOperationException($"The Nx workspace '{builder.Resource.Name}' is not configured with a package manager. Please specify a package manager.");
}

return builder.WithAnnotation(new JavaScriptPackageManagerAnnotation(packageManager));

Check failure on line 244 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-ubuntu-latest

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 244 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 244 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-windows-latest

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 244 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The type or namespace name 'JavaScriptPackageManagerAnnotation' could not be found (are you missing a using directive or an assembly reference?)
}

/// <summary>
Expand All @@ -287,7 +255,7 @@
{
ArgumentNullException.ThrowIfNull(builder);

builder.Resource.TryGetLastAnnotation<JavaScriptPackageInstallerAnnotation>(out var installerAnnotation);

Check failure on line 258 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-ubuntu-latest

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 258 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 258 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / run-tests / Hosting.NodeJS.Extensions.Tests-windows-latest

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 258 in src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/NodeJSHostingExtensions.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The type or namespace name 'JavaScriptPackageInstallerAnnotation' could not be found (are you missing a using directive or an assembly reference?)

if (builder.Resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var existingAnnotation))
{
Expand Down Expand Up @@ -323,7 +291,7 @@
{
var resource = builder.Resource;

// monorepo tools will need `--`, as does npm
// monorepo tools and npm (from Aspire.Hosting.NodeJS) need `--`, but yarn and pnpm don't
if (!resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var packageManagerAnnotation) || packageManagerAnnotation.PackageManager == "npm")
{
ctx.Args.Add("--");
Expand Down

This file was deleted.

26 changes: 9 additions & 17 deletions src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CommunityToolkit.Aspire.Hosting.NodeJS.Extensions library

This integration contains extensions for the [Node.js hosting package](https://nuget.org/packages/Aspire.Hosting.NodeJs) for .NET Aspire, including support for alternative package managers (yarn and pnpm), frontend monorepos (Nx, Turborepo), as well as developer workflow improvements.
This integration contains extensions for the [Node.js hosting package](https://nuget.org/packages/Aspire.Hosting.NodeJs) for .NET Aspire, including support for alternative package managers (yarn and pnpm) and frontend monorepos (Nx, Turborepo).

## Getting Started

Expand All @@ -17,10 +17,10 @@ dotnet add package CommunityToolkit.Aspire.Hosting.NodeJS.Extensions
Then, in the _Program.cs_ file of `AppHost`, define a Node.js resource, then call `AddYarnApp` or `AddPnpmApp`:

```csharp
builder.AddYarnApp("yarn-demo")
builder.AddYarnApp("yarn-demo", "../yarn-demo")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to build AddYarnApp on top of AddJavaScriptApp?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's just legacy docs I have to clean up still, it's meant to be replaced by AddJavaScriptApp().WithYarn()

.WithExternalHttpEndpoints();

builder.AddPnpmApp("pnpm-demo")
builder.AddPnpmApp("pnpm-demo", "../pnpm-demo")
.WithExternalHttpEndpoints();
```

Expand All @@ -31,16 +31,16 @@ For Nx and Turborepo monorepos, use the dedicated monorepo methods to avoid pack
```csharp
// Nx workspace
var nx = builder.AddNxApp("nx", workingDirectory: "../frontend")
.WithNpmPackageInstaller()
.RunWithPackageManager(); // Automatically uses npm from installer
.WithYarnPackageInstaller()
.RunWithPackageManager(); // Automatically uses yarn from installer

var app1 = nx.AddApp("app1");
var app2 = nx.AddApp("app2", appName: "my-app-2");

// Turborepo workspace
var turbo = builder.AddTurborepoApp("turbo", workingDirectory: "../frontend")
.WithYarnPackageInstaller()
.RunWithPackageManager("yarn"); // Explicitly specify yarn
.WithPnpmPackageInstaller()
.RunWithPackageManager("pnpm"); // Explicitly specify pnpm

var turboApp1 = turbo.AddApp("app1");
var turboApp2 = turbo.AddApp("app2", filter: "custom-filter");
Expand All @@ -60,8 +60,8 @@ var nx = builder.AddNxApp("nx", workingDirectory: "../frontend")

// Explicitly specify package manager
var turbo = builder.AddTurborepoApp("turbo", workingDirectory: "../frontend")
.WithNpmPackageInstaller()
.RunWithPackageManager("pnpm"); // Uses 'pnpm' command despite npm installer
.WithPnpmPackageInstaller()
.RunWithPackageManager("pnpm"); // Uses 'pnpm' command

// Generated commands:
// Nx with yarn: yarn nx serve app1
Expand All @@ -73,14 +73,6 @@ var turbo = builder.AddTurborepoApp("turbo", workingDirectory: "../frontend")
You can pass additional flags to package managers during installation:

```csharp
// npm with legacy peer deps support
builder.AddNpmApp("npm-app", "./path/to/app")
.WithNpmPackageInstallation(useCI: false, configureInstaller =>
{
configureInstaller.WithArgs("--legacy-peer-deps");
})
.WithExternalHttpEndpoints();

// yarn with frozen lockfile
builder.AddYarnApp("yarn-app", "./path/to/app")
.WithYarnPackageInstallation(configureInstaller =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace CommunityToolkit.Aspire.Hosting.NodeJS.Extensions.Tests;
public class AppHostTests(AspireIntegrationTestFixture<Projects.CommunityToolkit_Aspire_Hosting_NodeJS_Extensions_AppHost> fixture) : IClassFixture<AspireIntegrationTestFixture<Projects.CommunityToolkit_Aspire_Hosting_NodeJS_Extensions_AppHost>>
{
[Theory]
[InlineData("vite-demo")]
[InlineData("yarn-demo")]
[InlineData("pnpm-demo")]
[InlineData("turbo-web")]
Expand Down
Loading
Loading