mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 14:04:12 +01:00
Make BTCPayServer insensitive to the working directory in which it is started (Fix #1894)
This commit is contained in:
parent
5a2a933b64
commit
20c8916610
2 changed files with 19 additions and 6 deletions
|
@ -35,7 +35,7 @@ namespace BTCPayServer.Hosting
|
|||
}
|
||||
else
|
||||
{
|
||||
_InnerProvider = new BundleProvider();
|
||||
_InnerProvider = new BundleProvider(hosting);
|
||||
}
|
||||
}
|
||||
public Bundle GetBundle(string name)
|
||||
|
|
|
@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Hosting;
|
|||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: InternalsVisibleTo("BTCPayServer.Tests")]
|
||||
namespace BTCPayServer
|
||||
|
@ -21,6 +22,7 @@ namespace BTCPayServer
|
|||
{
|
||||
if (args.Length > 0 && args[0] == "run")
|
||||
args = args.Skip(1).ToArray(); // Hack to make dotnet watch work
|
||||
|
||||
ServicePointManager.DefaultConnectionLimit = 100;
|
||||
IWebHost host = null;
|
||||
var processor = new ConsoleLoggerProcessor();
|
||||
|
@ -41,10 +43,8 @@ namespace BTCPayServer
|
|||
logs.Configure(null);
|
||||
/////
|
||||
|
||||
host = new WebHostBuilder()
|
||||
var builder = new WebHostBuilder()
|
||||
.UseKestrel()
|
||||
.UseIISIntegration()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseConfiguration(conf)
|
||||
.ConfigureLogging(l =>
|
||||
{
|
||||
|
@ -56,8 +56,21 @@ namespace BTCPayServer
|
|||
l.AddFilter("Fido2NetLib.DistributedCacheMetadataService", LogLevel.Error);
|
||||
l.AddProvider(new CustomConsoleLogProvider(processor));
|
||||
})
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
.UseStartup<Startup>();
|
||||
|
||||
// When we run the app with dotnet run (typically in dev env), the wwwroot isn't in the same directory
|
||||
// than this assembly.
|
||||
// But when we use dotnet publish, the wwwroot is published alongside the assembly!
|
||||
// This fix https://github.com/btcpayserver/btcpayserver/issues/1894
|
||||
var defaultContentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
var defaultWebRoot = Path.Combine(defaultContentPath, "wwwroot");
|
||||
var defaultWebRootExists = Directory.Exists(defaultWebRoot);
|
||||
if (!defaultWebRootExists)
|
||||
{
|
||||
// When we use dotnet run...
|
||||
builder.UseContentRoot(Directory.GetCurrentDirectory());
|
||||
}
|
||||
host = builder.Build();
|
||||
host.StartWithTasksAsync().GetAwaiter().GetResult();
|
||||
var urls = host.ServerFeatures.Get<IServerAddressesFeature>().Addresses;
|
||||
foreach (var url in urls)
|
||||
|
|
Loading…
Add table
Reference in a new issue