diff --git a/docs/en/Getting-Started-AspNetCore-Application.md b/docs/en/Getting-Started-AspNetCore-Application.md index 8d3c898787..9f06897895 100644 --- a/docs/en/Getting-Started-AspNetCore-Application.md +++ b/docs/en/Getting-Started-AspNetCore-Application.md @@ -159,6 +159,13 @@ public class Program { public static void Main(string[] args) { + /* + https://github.com/aspnet/AspNetCore/issues/4206#issuecomment-445612167 + CurrentDirectoryHelpers exists in: \framework\src\Volo.Abp.AspNetCore.Mvc\Microsoft\AspNetCore\InProcess\CurrentDirectoryHelpers.cs + Will remove CurrentDirectoryHelpers.cs when upgrade to ASP.NET Core 3.0. + */ + CurrentDirectoryHelpers.SetCurrentDirectory(); + BuildWebHostInternal(args).Run(); } @@ -166,6 +173,7 @@ public class Program new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .Build(); diff --git a/docs/zh-Hans/Getting-Started-AspNetCore-Application.md b/docs/zh-Hans/Getting-Started-AspNetCore-Application.md index db6e73f35c..12aa1a3a6b 100644 --- a/docs/zh-Hans/Getting-Started-AspNetCore-Application.md +++ b/docs/zh-Hans/Getting-Started-AspNetCore-Application.md @@ -163,12 +163,20 @@ public class Program { public static void Main(string[] args) { + /* + https://github.com/aspnet/AspNetCore/issues/4206#issuecomment-445612167 + CurrentDirectoryHelpers 文件位于: \framework\src\Volo.Abp.AspNetCore.Mvc\Microsoft\AspNetCore\InProcess\CurrentDirectoryHelpers.cs + 当升级到ASP.NET Core 3.0的时候将会删除这个类. + */ + CurrentDirectoryHelpers.SetCurrentDirectory(); + BuildWebHostInternal(args).Run(); } public static IWebHost BuildWebHostInternal(string[] args) => new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .Build(); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/InProcess/CurrentDirectoryHelpers.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/InProcess/CurrentDirectoryHelpers.cs new file mode 100644 index 0000000000..80e608a315 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/InProcess/CurrentDirectoryHelpers.cs @@ -0,0 +1,63 @@ +using System; + +namespace Microsoft.AspNetCore.InProcess +{ + /// + /// https://github.com/aspnet/AspNetCore.Docs/blob/master/aspnetcore/host-and-deploy/aspnet-core-module/samples_snapshot/2.x/CurrentDirectoryHelpers.cs + /// TODO: Remove CurrentDirectoryHelpers.cs when upgrade to ASP.NET Core 3.0. + /// + public class CurrentDirectoryHelpers + { + internal const string AspNetCoreModuleDll = "aspnetcorev2_inprocess.dll"; + + [System.Runtime.InteropServices.DllImport("kernel32.dll")] + private static extern IntPtr GetModuleHandle(string lpModuleName); + + [System.Runtime.InteropServices.DllImport(AspNetCoreModuleDll)] + private static extern int http_get_application_properties(ref IISConfigurationData iiConfigData); + + [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)] + private struct IISConfigurationData + { + public IntPtr pNativeApplication; + [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.BStr)] + public string pwzFullApplicationPath; + [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.BStr)] + public string pwzVirtualApplicationPath; + public bool fWindowsAuthEnabled; + public bool fBasicAuthEnabled; + public bool fAnonymousAuthEnable; + } + + public static void SetCurrentDirectory() + { + try + { + // Check if physical path was provided by ANCM + var sitePhysicalPath = Environment.GetEnvironmentVariable("ASPNETCORE_IIS_PHYSICAL_PATH"); + if (string.IsNullOrEmpty(sitePhysicalPath)) + { + // Skip if not running ANCM InProcess + if (GetModuleHandle(AspNetCoreModuleDll) == IntPtr.Zero) + { + return; + } + + IISConfigurationData configurationData = default(IISConfigurationData); + if (http_get_application_properties(ref configurationData) != 0) + { + return; + } + + sitePhysicalPath = configurationData.pwzFullApplicationPath; + } + + Environment.CurrentDirectory = sitePhysicalPath; + } + catch + { + // ignore + } + } + } +} diff --git a/modules/blogging/app/Volo.BloggingTestApp/Program.cs b/modules/blogging/app/Volo.BloggingTestApp/Program.cs index b8bcab9d1c..66cca7ab18 100644 --- a/modules/blogging/app/Volo.BloggingTestApp/Program.cs +++ b/modules/blogging/app/Volo.BloggingTestApp/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Serilog; using Serilog.Events; @@ -10,6 +11,8 @@ namespace Volo.BloggingTestApp { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() //TODO: Should be configurable! .MinimumLevel.Override("Microsoft", LogEventLevel.Information) @@ -38,6 +41,7 @@ namespace Volo.BloggingTestApp new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/modules/blogging/app/Volo.BloggingTestApp/Volo.BloggingTestApp.csproj b/modules/blogging/app/Volo.BloggingTestApp/Volo.BloggingTestApp.csproj index dd796956bd..8eaef4b2b6 100644 --- a/modules/blogging/app/Volo.BloggingTestApp/Volo.BloggingTestApp.csproj +++ b/modules/blogging/app/Volo.BloggingTestApp/Volo.BloggingTestApp.csproj @@ -2,6 +2,7 @@ netcoreapp2.2 + InProcess diff --git a/modules/client-simulation/demo/Volo.ClientSimulation.Demo/Program.cs b/modules/client-simulation/demo/Volo.ClientSimulation.Demo/Program.cs index b35dd13ca4..478db71b8e 100644 --- a/modules/client-simulation/demo/Volo.ClientSimulation.Demo/Program.cs +++ b/modules/client-simulation/demo/Volo.ClientSimulation.Demo/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Serilog; using Serilog.Events; @@ -10,6 +11,8 @@ namespace Volo.ClientSimulation.Demo { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .MinimumLevel.Override("Microsoft", LogEventLevel.Information) @@ -38,6 +41,7 @@ namespace Volo.ClientSimulation.Demo new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/modules/client-simulation/demo/Volo.ClientSimulation.Demo/Volo.ClientSimulation.Demo.csproj b/modules/client-simulation/demo/Volo.ClientSimulation.Demo/Volo.ClientSimulation.Demo.csproj index 0a4fdebc1b..65aadd08eb 100644 --- a/modules/client-simulation/demo/Volo.ClientSimulation.Demo/Volo.ClientSimulation.Demo.csproj +++ b/modules/client-simulation/demo/Volo.ClientSimulation.Demo/Volo.ClientSimulation.Demo.csproj @@ -4,6 +4,7 @@ netcoreapp2.2 + InProcess diff --git a/modules/docs/app/VoloDocs.Web/Program.cs b/modules/docs/app/VoloDocs.Web/Program.cs index 90c41c061d..6dd673f797 100644 --- a/modules/docs/app/VoloDocs.Web/Program.cs +++ b/modules/docs/app/VoloDocs.Web/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Serilog; using Serilog.Events; @@ -10,6 +11,8 @@ namespace VoloDocs.Web { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() //TODO: Should be configurable! .MinimumLevel.Override("Microsoft", LogEventLevel.Information) @@ -38,6 +41,7 @@ namespace VoloDocs.Web new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/modules/docs/app/VoloDocs.Web/VoloDocs.Web.csproj b/modules/docs/app/VoloDocs.Web/VoloDocs.Web.csproj index 83d7ffd457..2dfb07ec80 100644 --- a/modules/docs/app/VoloDocs.Web/VoloDocs.Web.csproj +++ b/modules/docs/app/VoloDocs.Web/VoloDocs.Web.csproj @@ -2,6 +2,7 @@ netcoreapp2.2 + InProcess true true false diff --git a/samples/DashboardDemo/src/DashboardDemo.Web/DashboardDemo.Web.csproj b/samples/DashboardDemo/src/DashboardDemo.Web/DashboardDemo.Web.csproj index 550630fe7e..cc51eb3ade 100644 --- a/samples/DashboardDemo/src/DashboardDemo.Web/DashboardDemo.Web.csproj +++ b/samples/DashboardDemo/src/DashboardDemo.Web/DashboardDemo.Web.csproj @@ -4,6 +4,7 @@ netcoreapp2.2 + InProcess DashboardDemo $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; true diff --git a/samples/DashboardDemo/src/DashboardDemo.Web/Program.cs b/samples/DashboardDemo/src/DashboardDemo.Web/Program.cs index 8a6c828ce1..663f1c9262 100644 --- a/samples/DashboardDemo/src/DashboardDemo.Web/Program.cs +++ b/samples/DashboardDemo/src/DashboardDemo.Web/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Serilog; using Serilog.Events; @@ -10,6 +11,8 @@ namespace DashboardDemo { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() //TODO: Should be configurable! .MinimumLevel.Override("Microsoft", LogEventLevel.Information) @@ -38,6 +41,7 @@ namespace DashboardDemo new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServer.Host.csproj b/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServer.Host.csproj index 3fb01d55d7..7374e02b6e 100644 --- a/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServer.Host.csproj +++ b/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServer.Host.csproj @@ -2,6 +2,7 @@ netcoreapp2.2 + InProcess $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; true true diff --git a/samples/MicroserviceDemo/applications/AuthServer.Host/Program.cs b/samples/MicroserviceDemo/applications/AuthServer.Host/Program.cs index 80de0a0d64..cdd15af3c0 100644 --- a/samples/MicroserviceDemo/applications/AuthServer.Host/Program.cs +++ b/samples/MicroserviceDemo/applications/AuthServer.Host/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Microsoft.Extensions.Configuration; using Serilog; using Serilog.Events; @@ -12,6 +13,8 @@ namespace AuthServer.Host { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + //TODO: Temporary: it's not good to read appsettings.json here just to configure logging var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) @@ -55,6 +58,7 @@ namespace AuthServer.Host new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminApp.Host.csproj b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminApp.Host.csproj index d2f0d16257..aa13705aee 100644 --- a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminApp.Host.csproj +++ b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminApp.Host.csproj @@ -2,6 +2,7 @@ netcoreapp2.2 + InProcess $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; true true diff --git a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/Program.cs b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/Program.cs index e0736fb529..e07b19c922 100644 --- a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/Program.cs +++ b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Microsoft.Extensions.Configuration; using Serilog; using Serilog.Events; @@ -12,6 +13,8 @@ namespace BackendAdminApp.Host { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + //TODO: Temporary: it's not good to read appsettings.json here just to configure logging var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) @@ -55,6 +58,7 @@ namespace BackendAdminApp.Host new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/Program.cs b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Program.cs index d6a396ecf4..291b2247ce 100644 --- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/Program.cs +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Microsoft.Extensions.Configuration; using Serilog; using Serilog.Events; @@ -12,6 +13,8 @@ namespace PublicWebSite.Host { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + //TODO: Temporary: it's not good to read appsettings.json here just to configure logging var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) @@ -55,6 +58,7 @@ namespace PublicWebSite.Host new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj index b97bc35b68..153ac7e633 100644 --- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj @@ -2,6 +2,7 @@ netcoreapp2.2 + InProcess $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; true true diff --git a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGateway.Host.csproj b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGateway.Host.csproj index 3ae6528058..3450f6914a 100644 --- a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGateway.Host.csproj +++ b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGateway.Host.csproj @@ -2,6 +2,7 @@ netcoreapp2.2 + InProcess $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; true true diff --git a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/Program.cs b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/Program.cs index 22f634eadd..ef2062a7e0 100644 --- a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/Program.cs +++ b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Microsoft.Extensions.Configuration; using Serilog; using Serilog.Events; @@ -12,6 +13,8 @@ namespace BackendAdminAppGateway.Host { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + //TODO: Temporary: it's not good to read appsettings.json here just to configure logging var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) @@ -55,6 +58,7 @@ namespace BackendAdminAppGateway.Host new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGateway.Host.csproj b/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGateway.Host.csproj index 7aa8f1eab1..104d054c93 100644 --- a/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGateway.Host.csproj +++ b/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGateway.Host.csproj @@ -2,6 +2,7 @@ netcoreapp2.2 + InProcess $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; true true diff --git a/samples/MicroserviceDemo/gateways/InternalGateway.Host/Program.cs b/samples/MicroserviceDemo/gateways/InternalGateway.Host/Program.cs index 1d53275ed7..5a2c568f3f 100644 --- a/samples/MicroserviceDemo/gateways/InternalGateway.Host/Program.cs +++ b/samples/MicroserviceDemo/gateways/InternalGateway.Host/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Microsoft.Extensions.Configuration; using Serilog; using Serilog.Events; @@ -12,6 +13,8 @@ namespace InternalGateway.Host { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + //TODO: Temporary: it's not good to read appsettings.json here just to configure logging var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) @@ -55,6 +58,7 @@ namespace InternalGateway.Host new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/Program.cs b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/Program.cs index e609e48821..c17e6c27fc 100644 --- a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/Program.cs +++ b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Microsoft.Extensions.Configuration; using Serilog; using Serilog.Events; @@ -12,6 +13,8 @@ namespace PublicWebSiteGateway.Host { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + //TODO: Temporary: it's not good to read appsettings.json here just to configure logging var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) @@ -55,6 +58,7 @@ namespace PublicWebSiteGateway.Host new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGateway.Host.csproj b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGateway.Host.csproj index ecc2bcdfe5..c1ee258bfa 100644 --- a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGateway.Host.csproj +++ b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGateway.Host.csproj @@ -2,6 +2,7 @@ netcoreapp2.2 + InProcess $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; true true diff --git a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj index 972fbd9d31..de495c1bde 100644 --- a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj +++ b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj @@ -2,6 +2,7 @@ netcoreapp2.2 + InProcess $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; true true diff --git a/samples/MicroserviceDemo/microservices/BloggingService.Host/Program.cs b/samples/MicroserviceDemo/microservices/BloggingService.Host/Program.cs index cf6767226e..2cac132029 100644 --- a/samples/MicroserviceDemo/microservices/BloggingService.Host/Program.cs +++ b/samples/MicroserviceDemo/microservices/BloggingService.Host/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Microsoft.Extensions.Configuration; using Serilog; using Serilog.Events; @@ -12,6 +13,8 @@ namespace BloggingService.Host { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + //TODO: Temporary: it's not good to read appsettings.json here just to configure logging var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) @@ -55,6 +58,7 @@ namespace BloggingService.Host new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj index bc11e9759f..55f7ae938a 100644 --- a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj +++ b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj @@ -1,7 +1,8 @@ - + netcoreapp2.2 + InProcess $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; true true diff --git a/samples/MicroserviceDemo/microservices/IdentityService.Host/Program.cs b/samples/MicroserviceDemo/microservices/IdentityService.Host/Program.cs index 86dc91ab2a..3379404ed1 100644 --- a/samples/MicroserviceDemo/microservices/IdentityService.Host/Program.cs +++ b/samples/MicroserviceDemo/microservices/IdentityService.Host/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Microsoft.Extensions.Configuration; using Serilog; using Serilog.Events; @@ -12,6 +13,8 @@ namespace IdentityService.Host { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + //TODO: Temporary: it's not good to read appsettings.json here just to configure logging var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) @@ -55,6 +58,7 @@ namespace IdentityService.Host new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductService.Host.csproj b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductService.Host.csproj index 4cfac32df9..b27ef74805 100644 --- a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductService.Host.csproj +++ b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductService.Host.csproj @@ -2,6 +2,7 @@ netcoreapp2.2 + InProcess $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; true true diff --git a/samples/MicroserviceDemo/microservices/ProductService.Host/Program.cs b/samples/MicroserviceDemo/microservices/ProductService.Host/Program.cs index 40a6f7b5c6..44787ecf83 100644 --- a/samples/MicroserviceDemo/microservices/ProductService.Host/Program.cs +++ b/samples/MicroserviceDemo/microservices/ProductService.Host/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Microsoft.Extensions.Configuration; using Serilog; using Serilog.Events; @@ -12,6 +13,8 @@ namespace ProductService.Host { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + //TODO: Temporary: it's not good to read appsettings.json here just to configure logging var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) @@ -55,6 +58,7 @@ namespace ProductService.Host new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/templates/mvc-module/host/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj b/templates/mvc-module/host/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj index d6436852b6..8d2716570c 100644 --- a/templates/mvc-module/host/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj +++ b/templates/mvc-module/host/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj @@ -4,6 +4,7 @@ netcoreapp2.2 + InProcess MyCompanyName.MyProjectName diff --git a/templates/mvc-module/host/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs b/templates/mvc-module/host/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs index 22b560f34f..6043a28f6b 100644 --- a/templates/mvc-module/host/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs +++ b/templates/mvc-module/host/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Serilog; using Serilog.Events; @@ -10,6 +11,8 @@ namespace MyCompanyName.MyProjectName { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() @@ -42,6 +45,7 @@ namespace MyCompanyName.MyProjectName new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/templates/mvc-module/host/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj b/templates/mvc-module/host/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj index cdf7bcb65e..e32b62a452 100644 --- a/templates/mvc-module/host/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj +++ b/templates/mvc-module/host/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj @@ -2,6 +2,7 @@ netcoreapp2.2 + InProcess MyCompanyName.MyProjectName diff --git a/templates/mvc-module/host/MyCompanyName.MyProjectName.IdentityServer/Program.cs b/templates/mvc-module/host/MyCompanyName.MyProjectName.IdentityServer/Program.cs index 22b560f34f..6043a28f6b 100644 --- a/templates/mvc-module/host/MyCompanyName.MyProjectName.IdentityServer/Program.cs +++ b/templates/mvc-module/host/MyCompanyName.MyProjectName.IdentityServer/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Serilog; using Serilog.Events; @@ -10,6 +11,8 @@ namespace MyCompanyName.MyProjectName { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() @@ -42,6 +45,7 @@ namespace MyCompanyName.MyProjectName new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj b/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj index dd7ba84dbd..07c519c1bf 100644 --- a/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj +++ b/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj @@ -4,6 +4,7 @@ netcoreapp2.2 + InProcess MyCompanyName.MyProjectName diff --git a/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Host/Program.cs b/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Host/Program.cs index 22b560f34f..6043a28f6b 100644 --- a/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Host/Program.cs +++ b/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Host/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Serilog; using Serilog.Events; @@ -10,6 +11,8 @@ namespace MyCompanyName.MyProjectName { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() @@ -42,6 +45,7 @@ namespace MyCompanyName.MyProjectName new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Unified/MyCompanyName.MyProjectName.Web.Unified.csproj b/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Unified/MyCompanyName.MyProjectName.Web.Unified.csproj index 1e71f857eb..ecb7521615 100644 --- a/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Unified/MyCompanyName.MyProjectName.Web.Unified.csproj +++ b/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Unified/MyCompanyName.MyProjectName.Web.Unified.csproj @@ -4,6 +4,7 @@ netcoreapp2.2 + InProcess MyCompanyName.MyProjectName diff --git a/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Unified/Program.cs b/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Unified/Program.cs index ce1cc20806..bcd4742424 100644 --- a/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Unified/Program.cs +++ b/templates/mvc-module/host/MyCompanyName.MyProjectName.Web.Unified/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Serilog; using Serilog.Events; @@ -10,6 +11,8 @@ namespace MyCompanyName.MyProjectName { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .MinimumLevel.Override("Microsoft", LogEventLevel.Information) @@ -38,6 +41,7 @@ namespace MyCompanyName.MyProjectName new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj b/templates/mvc/src/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj index d68c13bc6b..9b911fac85 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj +++ b/templates/mvc/src/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj @@ -4,6 +4,7 @@ netcoreapp2.2 + InProcess MyCompanyName.MyProjectName diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs b/templates/mvc/src/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs index 1532c8f02b..22269af68f 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Serilog; using Serilog.Events; @@ -10,6 +11,8 @@ namespace MyCompanyName.MyProjectName { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() @@ -42,6 +45,7 @@ namespace MyCompanyName.MyProjectName new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj b/templates/mvc/src/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj index 8c18d8a43e..c00953e009 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj +++ b/templates/mvc/src/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj @@ -4,6 +4,7 @@ netcoreapp2.2 + InProcess MyCompanyName.MyProjectName $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; true diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.IdentityServer/Program.cs b/templates/mvc/src/MyCompanyName.MyProjectName.IdentityServer/Program.cs index 8c6afb6fe1..651b29835a 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.IdentityServer/Program.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.IdentityServer/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Serilog; using Serilog.Events; @@ -10,6 +11,8 @@ namespace MyCompanyName.MyProjectName { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() @@ -42,6 +45,7 @@ namespace MyCompanyName.MyProjectName new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj b/templates/mvc/src/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj index 4d9d970ace..76428a1c55 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj @@ -4,6 +4,7 @@ netcoreapp2.2 + InProcess MyCompanyName.MyProjectName.Web $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; true diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Web.Host/Program.cs b/templates/mvc/src/MyCompanyName.MyProjectName.Web.Host/Program.cs index ca7eeab845..e1d6933f9a 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.Web.Host/Program.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Web.Host/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Serilog; using Serilog.Events; @@ -10,6 +11,8 @@ namespace MyCompanyName.MyProjectName.Web { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() @@ -42,6 +45,7 @@ namespace MyCompanyName.MyProjectName.Web new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog() diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj b/templates/mvc/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj index 84ba69f73e..6cc67d21e7 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj @@ -4,6 +4,7 @@ netcoreapp2.2 + InProcess MyCompanyName.MyProjectName.Web $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; true diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Web/Program.cs b/templates/mvc/src/MyCompanyName.MyProjectName.Web/Program.cs index ca7eeab845..e1d6933f9a 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.Web/Program.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Web/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.InProcess; using Serilog; using Serilog.Events; @@ -10,6 +11,8 @@ namespace MyCompanyName.MyProjectName.Web { public static int Main(string[] args) { + CurrentDirectoryHelpers.SetCurrentDirectory(); + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() @@ -42,6 +45,7 @@ namespace MyCompanyName.MyProjectName.Web new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIIS() .UseIISIntegration() .UseStartup() .UseSerilog()