Make BTCPayServer works with dotnet watch hot reload

This commit is contained in:
nicolas.dorier 2022-01-01 22:05:24 +09:00
parent fd2e55e444
commit ab3aab9c22
No known key found for this signature in database
GPG Key ID: 6618763EF09186FE
4 changed files with 9 additions and 8 deletions

View File

@ -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" />
@ -8,7 +8,6 @@
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Build\**" />
<Compile Remove="wwwroot\bundles\jqueryvalidate\**" />
<Compile Remove="wwwroot\vendor\jquery-nice-select\**" />
@ -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>
@ -148,6 +147,7 @@
</ItemGroup>
<ItemGroup>
<Watch Include="Views\**\*.*"></Watch>
<Content Update="Views\Apps\_ViewImports.cshtml">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<Pack>$(IncludeRazorContentInPack)</Pack>

View File

@ -135,9 +135,7 @@ namespace BTCPayServer.Hosting
o.PageViewLocationFormats.Add("/{0}.cshtml");
})
.AddNewtonsoftJson()
#if RAZOR_RUNTIME_COMPILE
.AddRazorRuntimeCompilation()
#endif
.AddPlugins(services, Configuration, LoggerFactory)
.AddControllersAsServices();

View File

@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.IO;
using System.Net;
using System.Runtime.CompilerServices;
@ -18,6 +19,8 @@ namespace BTCPayServer
{
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();
@ -59,7 +62,8 @@ namespace BTCPayServer
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();
}

View File

@ -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'">