Include "serve" command in dotnet-blazor tool

This commit is contained in:
Steve Sanderson 2018-02-26 17:37:00 +00:00
parent c255e77ab5
commit 9d21eda9c4
6 changed files with 30 additions and 6 deletions

View File

@ -0,0 +1,22 @@
// 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 System.Linq;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.CommandLineUtils;
namespace Microsoft.AspNetCore.Blazor.Build.Cli.Commands
{
internal class ServeDevHost
{
public static void Command(CommandLineApplication command, string[] args)
{
command.OnExecute(() =>
{
var remainingArgs = args.Skip(1).ToArray();
DevHost.Server.Program.BuildWebHost(remainingArgs).Run();
return 0;
});
}
}
}

View File

@ -12,12 +12,13 @@ namespace Microsoft.AspNetCore.Blazor.Build
{ {
var app = new CommandLineApplication var app = new CommandLineApplication
{ {
Name = "dotnet-blazorbuild" Name = "dotnet-blazor"
}; };
app.HelpOption("-?|-h|--help"); app.HelpOption("-?|-h|--help");
app.Command("build", BuildCommand.Command); app.Command("build", BuildCommand.Command);
app.Command("buildrazor", BuildRazorCommand.Command); app.Command("buildrazor", BuildRazorCommand.Command);
app.Command("serve", command => ServeDevHost.Command(command, args));
if (args.Length > 0) if (args.Length > 0)
{ {

View File

@ -4,6 +4,7 @@
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<OutDir>tools</OutDir> <OutDir>tools</OutDir>
<AssemblyName>dotnet-blazor</AssemblyName>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup> </PropertyGroup>
@ -21,6 +22,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Microsoft.AspNetCore.Blazor.Browser.JS\Microsoft.AspNetCore.Blazor.Browser.JS.csproj" /> <ProjectReference Include="..\Microsoft.AspNetCore.Blazor.Browser.JS\Microsoft.AspNetCore.Blazor.Browser.JS.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Blazor.DevHost\Microsoft.AspNetCore.Blazor.DevHost.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Blazor.Mono\Microsoft.AspNetCore.Blazor.Mono.csproj" /> <ProjectReference Include="..\Microsoft.AspNetCore.Blazor.Mono\Microsoft.AspNetCore.Blazor.Mono.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Blazor.Razor.Extensions\Microsoft.AspNetCore.Blazor.Razor.Extensions.csproj" /> <ProjectReference Include="..\Microsoft.AspNetCore.Blazor.Razor.Extensions\Microsoft.AspNetCore.Blazor.Razor.Extensions.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Blazor\Microsoft.AspNetCore.Blazor.csproj" /> <ProjectReference Include="..\Microsoft.AspNetCore.Blazor\Microsoft.AspNetCore.Blazor.csproj" />

View File

@ -1,6 +1,6 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<BlazorBuildExe>dotnet &quot;$(MSBuildThisFileDirectory)../tools/Microsoft.AspNetCore.Blazor.Build.dll&quot;</BlazorBuildExe> <BlazorBuildExe>dotnet &quot;$(MSBuildThisFileDirectory)../tools/dotnet-blazor.dll&quot;</BlazorBuildExe>
<!-- The Blazor build code can only find your referenced assemblies if they are in the output directory --> <!-- The Blazor build code can only find your referenced assemblies if they are in the output directory -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

View File

@ -1,15 +1,14 @@
// 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
namespace Microsoft.AspNetCore.Blazor.DevHost.Server namespace Microsoft.AspNetCore.Blazor.DevHost.Server
{ {
internal class Program public class Program
{ {
internal static IWebHost BuildWebHost(string[] args) => public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args) WebHost.CreateDefaultBuilder(args)
.UseConfiguration(new ConfigurationBuilder() .UseConfiguration(new ConfigurationBuilder()
.AddCommandLine(args) .AddCommandLine(args)

View File

@ -40,7 +40,7 @@ namespace AngleSharpBuilder
var assemblyLocation = assembly.Location; var assemblyLocation = assembly.Location;
var moduleDefinition = ModuleDefinition.ReadModule(assemblyLocation); var moduleDefinition = ModuleDefinition.ReadModule(assemblyLocation);
AddInternalsVisibleTo(moduleDefinition, "Microsoft.AspNetCore.Blazor.Build"); AddInternalsVisibleTo(moduleDefinition, "dotnet-blazor");
AddInternalsVisibleTo(moduleDefinition, "Microsoft.AspNetCore.Blazor.Razor.Extensions"); AddInternalsVisibleTo(moduleDefinition, "Microsoft.AspNetCore.Blazor.Razor.Extensions");
RemoveStrongName(moduleDefinition); RemoveStrongName(moduleDefinition);
SetAssemblyName(moduleDefinition, "Microsoft.AspNetCore.Blazor.AngleSharp"); SetAssemblyName(moduleDefinition, "Microsoft.AspNetCore.Blazor.AngleSharp");