From 113a6ba30bad8d6d4c443d3bef5dd49e628c4cbc Mon Sep 17 00:00:00 2001 From: Renato Golia Date: Thu, 20 Jun 2024 11:49:10 +0200 Subject: [PATCH 1/2] Added .idea directory to .gitignore file --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9491a2f..dbe57a9 100644 --- a/.gitignore +++ b/.gitignore @@ -360,4 +360,7 @@ MigrationBackup/ .ionide/ # Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file +FodyWeavers.xsd + +# Resharper and Rider settings +.idea/ \ No newline at end of file From c18de01d77b6e5426e851604755887b979b2683e Mon Sep 17 00:00:00 2001 From: Renato Golia Date: Thu, 20 Jun 2024 11:49:23 +0200 Subject: [PATCH 2/2] Added IISExpress project --- Aspirant.sln | 7 ++++ .../Aspirant.Hosting.IISExpress.csproj | 16 ++++++++ .../IISExpressResource.cs | 18 +++++++++ .../IISExpressResourceExtensions.cs | 40 +++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 src/Aspirant.Hosting.IISExpress/Aspirant.Hosting.IISExpress.csproj create mode 100644 src/Aspirant.Hosting.IISExpress/IISExpressResource.cs create mode 100644 src/Aspirant.Hosting.IISExpress/IISExpressResourceExtensions.cs diff --git a/Aspirant.sln b/Aspirant.sln index 775f2aa..e11c6a7 100644 --- a/Aspirant.sln +++ b/Aspirant.sln @@ -48,6 +48,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspirant.Hosting.PostgreSQL EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspirant.Hosting.RabbitMQ", "src\Aspirant.Hosting.RabbitMQ\Aspirant.Hosting.RabbitMQ.csproj", "{45EC9DE1-B3E7-4EF4-A0AA-8CD7230EB7FB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspirant.Hosting.IISExpress", "src\Aspirant.Hosting.IISExpress\Aspirant.Hosting.IISExpress.csproj", "{A66C0A1E-B3F4-4C66-8873-024F09DB4002}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -110,6 +112,10 @@ Global {45EC9DE1-B3E7-4EF4-A0AA-8CD7230EB7FB}.Debug|Any CPU.Build.0 = Debug|Any CPU {45EC9DE1-B3E7-4EF4-A0AA-8CD7230EB7FB}.Release|Any CPU.ActiveCfg = Release|Any CPU {45EC9DE1-B3E7-4EF4-A0AA-8CD7230EB7FB}.Release|Any CPU.Build.0 = Release|Any CPU + {A66C0A1E-B3F4-4C66-8873-024F09DB4002}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A66C0A1E-B3F4-4C66-8873-024F09DB4002}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A66C0A1E-B3F4-4C66-8873-024F09DB4002}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A66C0A1E-B3F4-4C66-8873-024F09DB4002}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -130,6 +136,7 @@ Global {135004A9-F7E0-46D9-B3D0-3D64BA3C40B9} = {6E773CFD-9758-4C09-96F6-5EDCED0E3A34} {77D17495-C537-4446-8C2E-8B46560E0992} = {6E773CFD-9758-4C09-96F6-5EDCED0E3A34} {45EC9DE1-B3E7-4EF4-A0AA-8CD7230EB7FB} = {6E773CFD-9758-4C09-96F6-5EDCED0E3A34} + {A66C0A1E-B3F4-4C66-8873-024F09DB4002} = {6E773CFD-9758-4C09-96F6-5EDCED0E3A34} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {52627286-38AF-4E95-BDA0-B21166B2B18C} diff --git a/src/Aspirant.Hosting.IISExpress/Aspirant.Hosting.IISExpress.csproj b/src/Aspirant.Hosting.IISExpress/Aspirant.Hosting.IISExpress.csproj new file mode 100644 index 0000000..a7b9719 --- /dev/null +++ b/src/Aspirant.Hosting.IISExpress/Aspirant.Hosting.IISExpress.csproj @@ -0,0 +1,16 @@ + + + + net8.0 + enable + enable + A set of useful extensions and experiments for IIS Express for .NET Aspire App Host projects. + aspire hosting rabbitmq + + + + + + + + diff --git a/src/Aspirant.Hosting.IISExpress/IISExpressResource.cs b/src/Aspirant.Hosting.IISExpress/IISExpressResource.cs new file mode 100644 index 0000000..11ed46b --- /dev/null +++ b/src/Aspirant.Hosting.IISExpress/IISExpressResource.cs @@ -0,0 +1,18 @@ +using Aspire.Hosting; +using Aspire.Hosting.ApplicationModel; +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace + +namespace Aspirant.Hosting; + +/// +/// Represents a IIS Express resource. +/// +/// The name of the resource in the application model. +/// The path to the IIS Express executable. +/// The working directory of the executable. +public class IISExpressResource(string name, string path, string workingDirectory = ".") + : ExecutableResource(name, path, workingDirectory), IResourceWithServiceDiscovery +{ + +} \ No newline at end of file diff --git a/src/Aspirant.Hosting.IISExpress/IISExpressResourceExtensions.cs b/src/Aspirant.Hosting.IISExpress/IISExpressResourceExtensions.cs new file mode 100644 index 0000000..7965c84 --- /dev/null +++ b/src/Aspirant.Hosting.IISExpress/IISExpressResourceExtensions.cs @@ -0,0 +1,40 @@ +using Aspire.Hosting; +using Aspire.Hosting.ApplicationModel; +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace + +namespace Aspirant.Hosting; + +/// +/// Extensions for the +/// +public static class IISExpressResourceExtensions +{ + /// + /// + /// + /// The builder. + /// The name of the resource. + /// The path to the web application to host in IIS Express. + /// The architecture of IIS Express to be used. + /// The builder. + public static IResourceBuilder AddIISExpress(this IDistributedApplicationBuilder builder, string name, string applicationPath) + { + var iisExpressPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "IIS Express", "iisexpress.exe"); + + var appPath = Path.GetFullPath(applicationPath, builder.AppHostDirectory); + + var resource = new IISExpressResource(name, iisExpressPath); + + return builder.AddResource(resource) + .WithArgs($"/path:{appPath}", "/systray:false") + .WithArgs(context => + { + var http = resource.GetEndpoint("http"); + + var portExpression = ReferenceExpression.Create($"/port:{http.Property(EndpointProperty.TargetPort)}"); + context.Args.Add(portExpression); + }) + .WithHttpEndpoint(name: "http"); + } +}