DotnetProjectHostingExtensions Methods
Hosting.IDistributedApplicationBuilder. AddDotnetProject(IDistributedApplicationBuilder, string, string)Section titled AddDotnetProject(IDistributedApplicationBuilder, string, string)extensionIResourceBuilder<DotnetProjectResource>public static class DotnetProjectHostingExtensions{ public static IResourceBuilder<DotnetProjectResource> AddDotnetProject( this IDistributedApplicationBuilder builder, string name, string path) { // ... }}Parameters
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder.namestringThe name of the resource. This name will be used for service discovery when referenced in a dependency.pathstringThe path to the file-based app file, project file, or project directory.Returns
IResourceBuilder<DotnetProjectResource>A reference to the ApplicationModel.IResourceBuilder`1.Remarks
This overload of the DotnetProjectHostingExtensions.AddDotnetProject method adds a C# project or file-based app to the application model using a path to the file-based app .cs file, project file (.csproj), or project directory. If the path is not an absolute path then it will be computed relative to the AppHost directory.
var builder = DistributedApplication.CreateBuilder(args);
builder.AddDotnetProject("inventoryservice", @"..\InventoryService.cs");
builder.Build().Run();AddDotnetProject(IDistributedApplicationBuilder, string, string, Action<ProjectResourceOptions>)Section titled AddDotnetProject(IDistributedApplicationBuilder, string, string, Action<ProjectResourceOptions>)extensionIResourceBuilder<DotnetProjectResource>public static class DotnetProjectHostingExtensions{ public static IResourceBuilder<DotnetProjectResource> AddDotnetProject( this IDistributedApplicationBuilder builder, string name, string path, Action<ProjectResourceOptions> configure) { // ... }}Parameters
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder.namestringThe name of the resource. This name will be used for service discovery when referenced in a dependency.pathstringThe path to the file-based app file, project file, or project directory.configureAction<ProjectResourceOptions>An optional action to configure the C# app resource options.Returns
IResourceBuilder<DotnetProjectResource>A reference to the ApplicationModel.IResourceBuilder`1.Remarks
This overload of the DotnetProjectHostingExtensions.AddDotnetProject method adds a C# project or file-based app to the application model using a path to the file-based app .cs file, project file (.csproj), or project directory. If the path is not an absolute path then it will be computed relative to the AppHost directory.
var builder = DistributedApplication.CreateBuilder(args);
builder.AddDotnetProject( "inventoryservice", @"..\InventoryService.cs", o => o.LaunchProfileName = "https");
builder.Build().Run();