Skip to content

Commit

Permalink
Make BTCPayServer works with dotnet watch hot reload
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDorier committed Jan 1, 2022
1 parent fd2e55e commit ab3aab9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions BTCPayServer/BTCPayServer.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="../Build/Version.csproj" Condition="Exists('../Build/Version.csproj')" />
<Import Project="../Build/Common.csproj" />

Expand All @@ -8,7 +8,6 @@
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<ItemGroup>

<Compile Remove="Build\**" />
<Compile Remove="wwwroot\bundles\jqueryvalidate\**" />
<Compile Remove="wwwroot\vendor\jquery-nice-select\**" />
Expand Down Expand Up @@ -88,7 +87,7 @@
<PackageReference Include="TwentyTwenty.Storage.Google" Version="2.12.1" />
<PackageReference Include="TwentyTwenty.Storage.Local" Version="2.12.1" />
<PackageReference Include="YamlDotNet" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.1" Condition="'$(RazorCompileOnBuild)' != 'true'" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.1" />
</ItemGroup>

Expand Down Expand Up @@ -148,6 +147,7 @@
</ItemGroup>

<ItemGroup>
<Watch Include="Views\**\*.*"></Watch>
<Content Update="Views\Apps\_ViewImports.cshtml">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>
Expand Down
2 changes: 0 additions & 2 deletions BTCPayServer/Hosting/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ public void ConfigureServices(IServiceCollection services)
o.PageViewLocationFormats.Add("/{0}.cshtml");
})
.AddNewtonsoftJson()
#if RAZOR_RUNTIME_COMPILE
.AddRazorRuntimeCompilation()
#endif
.AddPlugins(services, Configuration, LoggerFactory)
.AddControllersAsServices();

Expand Down
6 changes: 5 additions & 1 deletion BTCPayServer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.IO;
using System.Net;
using System.Runtime.CompilerServices;
Expand All @@ -18,6 +19,8 @@ class Program
{
static void Main(string[] args)
{
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();
Expand Down Expand Up @@ -59,7 +62,8 @@ static void Main(string[] args)
var urls = host.ServerFeatures.Get<IServerAddressesFeature>().Addresses;
foreach (var url in urls)
{
logger.LogInformation("Listening on " + url);
// Some tools such as dotnet watch parse this exact log to open the browser
logger.LogInformation("Now listening on: " + url);
}
host.WaitForShutdown();
}
Expand Down
3 changes: 1 addition & 2 deletions Build/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
</PropertyGroup>
<!-- -->

<PropertyGroup Condition="( '$(Configuration)' == 'Debug' Or '$(Configuration)' == 'Altcoins-Debug') And '$(RazorCompileOnBuild)' != 'true'">
<PropertyGroup Condition="( '$(Configuration)' == 'Debug' Or '$(Configuration)' == 'Altcoins-Debug') And '$(RazorCompileOnBuild)' != 'true' And '$(DotNetWatchBuild)' != 'true' And '$(DesignTimeBuild)' != 'true'">
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<DefineConstants>$(DefineConstants);RAZOR_RUNTIME_COMPILE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Altcoins)' == 'true'">
Expand Down

0 comments on commit ab3aab9

Please sign in to comment.