File tree Expand file tree Collapse file tree 6 files changed +50
-29
lines changed
benchmarks/Microsoft.AspNetCore.Blazor.E2EPerformance
src/Microsoft.AspNetCore.Blazor.Cli
src/Microsoft.AspNetCore.Components.Build
test/testapps/BasicTestApp Expand file tree Collapse file tree 6 files changed +50
-29
lines changed Original file line number Diff line number Diff line change 2
2
3
3
<PropertyGroup >
4
4
<TargetFramework >netstandard2.0</TargetFramework >
5
-
6
- <!-- Local alternative to <RunArguments>blazor serve</RunArguments> -->
7
- <RunCommand >dotnet</RunCommand >
8
- <RunArguments >run --project ../../../blazor/src/Microsoft.AspNetCore.Blazor.Cli serve</RunArguments >
9
5
</PropertyGroup >
10
6
11
7
<ItemGroup >
Original file line number Diff line number Diff line change 2
2
3
3
<PropertyGroup >
4
4
<TargetFramework >netstandard2.0</TargetFramework >
5
-
6
- <!-- Local alternative to <RunArguments>blazor serve</RunArguments> -->
7
- <RunCommand >dotnet</RunCommand >
8
- <RunArguments >run --project ../../src/Microsoft.AspNetCore.Blazor.Cli serve</RunArguments >
9
5
</PropertyGroup >
10
6
11
7
<ItemGroup >
Original file line number Diff line number Diff line change 3
3
4
4
using Microsoft . AspNetCore . Hosting ;
5
5
using Microsoft . Extensions . CommandLineUtils ;
6
- using System ;
7
- using System . Diagnostics ;
8
- using System . Text . RegularExpressions ;
9
6
10
7
namespace Microsoft . AspNetCore . Blazor . Cli . Commands
11
8
{
12
- class ServeCommand
9
+ internal class ServeCommand : CommandLineApplication
13
10
{
14
- public static void Command ( CommandLineApplication command )
11
+ public ServeCommand ( CommandLineApplication parent )
12
+
13
+ // We pass arbitrary arguments through to the ASP.NET Core configuration
14
+ : base ( throwOnUnexpectedArg : false )
15
15
{
16
- var remainingArgs = command . RemainingArguments . ToArray ( ) ;
16
+ Parent = parent ;
17
+
18
+ Name = "serve" ;
19
+ Description = "Serve requests to a Blazor application" ;
20
+
21
+ HelpOption ( "-?|-h|--help" ) ;
17
22
18
- Server . Program . BuildWebHost ( remainingArgs ) . Run ( ) ;
23
+ OnExecute ( Execute ) ;
24
+ }
25
+
26
+ private int Execute ( )
27
+ {
28
+ Server . Program . BuildWebHost ( RemainingArguments . ToArray ( ) ) . Run ( ) ;
29
+ return 0 ;
19
30
}
20
31
}
21
32
}
Original file line number Diff line number Diff line change 1
- // Copyright (c) .NET Foundation. All rights reserved.
1
+ // Copyright (c) .NET Foundation. All rights reserved.
2
2
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
3
4
- using Microsoft . AspNetCore . Hosting ;
5
- using System ;
6
- using System . Linq ;
7
- using Microsoft . Extensions . CommandLineUtils ;
8
4
using Microsoft . AspNetCore . Blazor . Cli . Commands ;
5
+ using Microsoft . Extensions . CommandLineUtils ;
9
6
10
7
namespace Microsoft . AspNetCore . Blazor . Cli
11
8
{
12
9
internal class Program
13
10
{
14
11
static int Main ( string [ ] args )
15
12
{
16
- var app = new CommandLineApplication
13
+ var app = new CommandLineApplication ( throwOnUnexpectedArg : false )
17
14
{
18
15
Name = "blazor-cli"
19
16
} ;
20
17
app . HelpOption ( "-?|-h|--help" ) ;
21
18
22
- app . Command ( "serve" , ServeCommand . Command ) ;
19
+ app . Commands . Add ( new ServeCommand ( app ) ) ;
23
20
24
- if ( args . Length > 0 )
21
+ // A command is always required
22
+ app . OnExecute ( ( ) =>
23
+ {
24
+ app . ShowHelp ( ) ;
25
+ return 0 ;
26
+ } ) ;
27
+
28
+ try
25
29
{
26
30
return app . Execute ( args ) ;
27
31
}
28
- else
32
+ catch ( CommandParsingException cex )
29
33
{
34
+ app . Error . WriteLine ( cex . Message ) ;
30
35
app . ShowHelp ( ) ;
31
- return 0 ;
36
+ return 1 ;
32
37
}
33
38
}
34
39
}
Original file line number Diff line number Diff line change 1
- <Project >
1
+ <Project >
2
2
3
3
<!--
4
4
Importing this file is equivalent to having:
17
17
<Import Project =" $(MSBuildThisFileDirectory)targets/All.props" />
18
18
<Import Project =" $(MSBuildThisFileDirectory)targets/All.targets" />
19
19
20
+ <!--
21
+ Debugging support using dotnet-blazor serve.
22
+
23
+ A few things to note here:
24
+ - We have to use dotnet exec to avoid launching another process and confusing the debugger.
25
+ - Since we're doing dotnet exec, it won't automatically rebuild the CLI project.
26
+ - $(AdditionalRunArguments) needs to be defined before importing this file.
27
+ -->
28
+ <PropertyGroup >
29
+ <RunCommand >dotnet</RunCommand >
30
+ <_BlazorCliLocation >$(MSBuildThisFileDirectory)../../blazor/src/Microsoft.AspNetCore.Blazor.Cli/bin/$(Configuration)/netcoreapp3.0/dotnet-blazor.dll </_BlazorCliLocation >
31
+ <RunArguments >exec $(_BlazorCliLocation) serve $(AdditionalRunArguments)</RunArguments >
32
+ </PropertyGroup >
33
+
20
34
<ItemGroup >
21
35
<PackageReference Include =" Microsoft.AspNetCore.Blazor.Mono" Version =" $(MicrosoftAspNetCoreBlazorMonoPackageVersion)" />
22
36
<PackageReference Include =" Microsoft.AspNetCore.Razor.Design" Version =" $(MicrosoftAspNetCoreRazorDesignPackageVersion)" />
Original file line number Diff line number Diff line change 3
3
<PropertyGroup >
4
4
<TargetFramework >netstandard2.0</TargetFramework >
5
5
6
- <!-- Local alternative to <RunArguments>blazor serve</RunArguments> -->
7
- <RunCommand >dotnet</RunCommand >
8
- <RunArguments >run --project ../../../blazor/src/Microsoft.AspNetCore.Blazor.Cli serve --pathbase /subdir</RunArguments >
6
+ <!-- Must be defined before ReferenceFromSource.props is imported -->
7
+ <AdditionalRunArguments >--pathbase /subdir</AdditionalRunArguments >
9
8
</PropertyGroup >
10
9
11
10
<!-- Local alternative to <PackageReference Include="Microsoft.AspNetCore.Components.Build" /> -->
You can’t perform that action at this time.
0 commit comments