mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 14:22:40 +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
|
else
|
||||||
{
|
{
|
||||||
_InnerProvider = new BundleProvider();
|
_InnerProvider = new BundleProvider(hosting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Bundle GetBundle(string name)
|
public Bundle GetBundle(string name)
|
||||||
|
|
|
@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("BTCPayServer.Tests")]
|
[assembly: InternalsVisibleTo("BTCPayServer.Tests")]
|
||||||
namespace BTCPayServer
|
namespace BTCPayServer
|
||||||
|
@ -21,6 +22,7 @@ namespace BTCPayServer
|
||||||
{
|
{
|
||||||
if (args.Length > 0 && args[0] == "run")
|
if (args.Length > 0 && args[0] == "run")
|
||||||
args = args.Skip(1).ToArray(); // Hack to make dotnet watch work
|
args = args.Skip(1).ToArray(); // Hack to make dotnet watch work
|
||||||
|
|
||||||
ServicePointManager.DefaultConnectionLimit = 100;
|
ServicePointManager.DefaultConnectionLimit = 100;
|
||||||
IWebHost host = null;
|
IWebHost host = null;
|
||||||
var processor = new ConsoleLoggerProcessor();
|
var processor = new ConsoleLoggerProcessor();
|
||||||
|
@ -41,10 +43,8 @@ namespace BTCPayServer
|
||||||
logs.Configure(null);
|
logs.Configure(null);
|
||||||
/////
|
/////
|
||||||
|
|
||||||
host = new WebHostBuilder()
|
var builder = new WebHostBuilder()
|
||||||
.UseKestrel()
|
.UseKestrel()
|
||||||
.UseIISIntegration()
|
|
||||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
|
||||||
.UseConfiguration(conf)
|
.UseConfiguration(conf)
|
||||||
.ConfigureLogging(l =>
|
.ConfigureLogging(l =>
|
||||||
{
|
{
|
||||||
|
@ -56,8 +56,21 @@ namespace BTCPayServer
|
||||||
l.AddFilter("Fido2NetLib.DistributedCacheMetadataService", LogLevel.Error);
|
l.AddFilter("Fido2NetLib.DistributedCacheMetadataService", LogLevel.Error);
|
||||||
l.AddProvider(new CustomConsoleLogProvider(processor));
|
l.AddProvider(new CustomConsoleLogProvider(processor));
|
||||||
})
|
})
|
||||||
.UseStartup<Startup>()
|
.UseStartup<Startup>();
|
||||||
.Build();
|
|
||||||
|
// 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();
|
host.StartWithTasksAsync().GetAwaiter().GetResult();
|
||||||
var urls = host.ServerFeatures.Get<IServerAddressesFeature>().Addresses;
|
var urls = host.ServerFeatures.Get<IServerAddressesFeature>().Addresses;
|
||||||
foreach (var url in urls)
|
foreach (var url in urls)
|
||||||
|
|
Loading…
Add table
Reference in a new issue