Fix dotnet-blazor serve
This wasn't properly forwarding the base path to the configuration. Basically nothing was setting RemainingArguments. We have a test project that sets the base path, but it was never used when debugging locally. I also cleaned this up a bit and changed it to use dotnet exec. This allow you to debug the CLI and related server pipeline, but has the tradeoff of not rebuilding.
This commit is contained in:
parent
8cfa8ea64a
commit
688ab7fc49
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
|
||||
<!-- Local alternative to <RunArguments>blazor serve</RunArguments> -->
|
||||
<RunCommand>dotnet</RunCommand>
|
||||
<RunArguments>run --project ../../../blazor/src/Microsoft.AspNetCore.Blazor.Cli serve</RunArguments>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
|
||||
<!-- Local alternative to <RunArguments>blazor serve</RunArguments> -->
|
||||
<RunCommand>dotnet</RunCommand>
|
||||
<RunArguments>run --project ../../src/Microsoft.AspNetCore.Blazor.Cli serve</RunArguments>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -3,19 +3,30 @@
|
|||
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.CommandLineUtils;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Microsoft.AspNetCore.Blazor.Cli.Commands
|
||||
{
|
||||
class ServeCommand
|
||||
internal class ServeCommand : CommandLineApplication
|
||||
{
|
||||
public static void Command(CommandLineApplication command)
|
||||
{
|
||||
var remainingArgs = command.RemainingArguments.ToArray();
|
||||
public ServeCommand(CommandLineApplication parent)
|
||||
|
||||
Server.Program.BuildWebHost(remainingArgs).Run();
|
||||
// We pass arbitrary arguments through to the ASP.NET Core configuration
|
||||
: base(throwOnUnexpectedArg: false)
|
||||
{
|
||||
Parent = parent;
|
||||
|
||||
Name = "serve";
|
||||
Description = "Serve requests to a Blazor application";
|
||||
|
||||
HelpOption("-?|-h|--help");
|
||||
|
||||
OnExecute(Execute);
|
||||
}
|
||||
|
||||
private int Execute()
|
||||
{
|
||||
Server.Program.BuildWebHost(RemainingArguments.ToArray()).Run();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.CommandLineUtils;
|
||||
using Microsoft.AspNetCore.Blazor.Cli.Commands;
|
||||
using Microsoft.Extensions.CommandLineUtils;
|
||||
|
||||
namespace Microsoft.AspNetCore.Blazor.Cli
|
||||
{
|
||||
|
|
@ -13,22 +10,30 @@ namespace Microsoft.AspNetCore.Blazor.Cli
|
|||
{
|
||||
static int Main(string[] args)
|
||||
{
|
||||
var app = new CommandLineApplication
|
||||
var app = new CommandLineApplication(throwOnUnexpectedArg: false)
|
||||
{
|
||||
Name = "blazor-cli"
|
||||
};
|
||||
app.HelpOption("-?|-h|--help");
|
||||
|
||||
app.Command("serve", ServeCommand.Command);
|
||||
app.Commands.Add(new ServeCommand(app));
|
||||
|
||||
if (args.Length > 0)
|
||||
{
|
||||
return app.Execute(args);
|
||||
}
|
||||
else
|
||||
// A command is always required
|
||||
app.OnExecute(() =>
|
||||
{
|
||||
app.ShowHelp();
|
||||
return 0;
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
return app.Execute(args);
|
||||
}
|
||||
catch (CommandParsingException cex)
|
||||
{
|
||||
app.Error.WriteLine(cex.Message);
|
||||
app.ShowHelp();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project>
|
||||
<Project>
|
||||
|
||||
<!--
|
||||
Importing this file is equivalent to having:
|
||||
|
|
@ -17,6 +17,20 @@
|
|||
<Import Project="$(MSBuildThisFileDirectory)targets/All.props" />
|
||||
<Import Project="$(MSBuildThisFileDirectory)targets/All.targets" />
|
||||
|
||||
<!--
|
||||
Debugging support using dotnet-blazor serve.
|
||||
|
||||
A few things to note here:
|
||||
- We have to use dotnet exec to avoid launching another process and confusing the debugger.
|
||||
- Since we're doing dotnet exec, it won't automatically rebuild the CLI project.
|
||||
- $(AdditionalRunArguments) needs to be defined before importing this file.
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<RunCommand>dotnet</RunCommand>
|
||||
<_BlazorCliLocation>$(MSBuildThisFileDirectory)../../blazor/src/Microsoft.AspNetCore.Blazor.Cli/bin/$(Configuration)/netcoreapp3.0/dotnet-blazor.dll </_BlazorCliLocation>
|
||||
<RunArguments>exec $(_BlazorCliLocation) serve $(AdditionalRunArguments)</RunArguments>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.Mono" Version="$(MicrosoftAspNetCoreBlazorMonoPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="$(MicrosoftAspNetCoreRazorDesignPackageVersion)" />
|
||||
|
|
|
|||
|
|
@ -3,9 +3,8 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
|
||||
<!-- Local alternative to <RunArguments>blazor serve</RunArguments> -->
|
||||
<RunCommand>dotnet</RunCommand>
|
||||
<RunArguments>run --project ../../../blazor/src/Microsoft.AspNetCore.Blazor.Cli serve --pathbase /subdir</RunArguments>
|
||||
<!-- Must be defined before ReferenceFromSource.props is imported -->
|
||||
<AdditionalRunArguments>--pathbase /subdir</AdditionalRunArguments>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Local alternative to <PackageReference Include="Microsoft.AspNetCore.Components.Build" /> -->
|
||||
|
|
|
|||
Loading…
Reference in New Issue