瀏覽代碼

Cleanup the dev server (#32743)

Pranav K 4 年之前
父節點
當前提交
785aeb3b4f

+ 3 - 1
eng/scripts/CodeCheck.ps1

@@ -208,7 +208,9 @@ try {
             foreach ($file in $changedFilesFromTarget) {
                 # Check for changes in Shipped in all branches
                 if ($file -like '*PublicAPI.Shipped.txt') {
-                    $changedAPIBaselines.Add($file)
+                    if (!$file.Contains('DevServer/src/PublicAPI.Shipped.txt')) {
+                        $changedAPIBaselines.Add($file)
+                    }
                 }
                 # Check for changes in Unshipped in servicing branches
                 if ($targetBranch -like 'release*' -and $targetBranch -notlike '*preview*' -and $file -like '*PublicAPI.Unshipped.txt') {

+ 1 - 1
src/Components/Directory.Build.targets

@@ -9,7 +9,7 @@
 
     <_BlazorDevServerPath>$(ArtifactsDir)bin/Microsoft.AspNetCore.Components.WebAssembly.DevServer/$(Configuration)/$(DefaultNetCoreTargetFramework)/blazor-devserver.dll</_BlazorDevServerPath>
     <RunCommand>dotnet</RunCommand>
-    <RunArguments>exec &quot;$(_BlazorDevServerPath)&quot; serve --applicationpath &quot;$(TargetPath)&quot; $(AdditionalRunArguments)</RunArguments>
+    <RunArguments>exec &quot;$(_BlazorDevServerPath)&quot; --applicationpath &quot;$(TargetPath)&quot; $(AdditionalRunArguments)</RunArguments>
   </PropertyGroup>
 
   <ItemGroup>

+ 0 - 34
src/Components/WebAssembly/DevServer/src/Commands/ServeCommand.cs

@@ -1,34 +0,0 @@
-// 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 Microsoft.Extensions.CommandLineUtils;
-using Microsoft.Extensions.Hosting;
-using DevServerProgram = Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server.Program;
-
-namespace Microsoft.AspNetCore.Components.Web.DevServer.Commands
-{
-    internal class ServeCommand : CommandLineApplication
-    {
-        public ServeCommand(CommandLineApplication parent)
-
-            // 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()
-        {
-            DevServerProgram.BuildWebHost(RemainingArguments.ToArray()).Run();
-            return 0;
-        }
-    }
-}

+ 3 - 2
src/Components/WebAssembly/DevServer/src/Microsoft.AspNetCore.Components.WebAssembly.DevServer.csproj

@@ -14,14 +14,15 @@
     <!-- Disable the default runtimeconfig.json in favor of the one that we create which contains the correct
     framework references. Workaround for issues launching Blazor WASM apps with IIS Express. -->
     <GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles>
+    <AddPublicApiAnalyzers>false</AddPublicApiAnalyzers>
+    <Nullable>enable</Nullable>
   </PropertyGroup>
 
   <ItemGroup>
     <Reference Include="Microsoft.AspNetCore" />
     <Reference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" />
-    <Compile Include="$(SharedSourceRoot)CommandLineUtils\**\*.cs" />
   </ItemGroup>
-   
+
   <!--  We include this here to ensure that the shared framework is built before we leverage it when running
   the dev server. -->
   <ItemGroup>

+ 6 - 27
src/Components/WebAssembly/DevServer/src/Program.cs

@@ -1,8 +1,10 @@
 // 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.Components.Web.DevServer.Commands;
-using Microsoft.Extensions.CommandLineUtils;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Hosting;
+using DevServerProgram = Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server.Program;
+
 
 namespace Microsoft.AspNetCore.Components.WebAssembly.DevServer
 {
@@ -10,31 +12,8 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.DevServer
     {
         static int Main(string[] args)
         {
-            var app = new CommandLineApplication(throwOnUnexpectedArg: false)
-            {
-                Name = "blazor-devserver"
-            };
-            app.HelpOption("-?|-h|--help");
-
-            app.Commands.Add(new ServeCommand(app));
-
-            // 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;
-            }
+            DevServerProgram.BuildWebHost(args).Run();
+            return 0;
         }
     }
 }

+ 0 - 4
src/Components/WebAssembly/DevServer/src/PublicAPI.Shipped.txt

@@ -1,4 +0,0 @@
-#nullable enable
-Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server.Program
-Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server.Program.Program() -> void
-~static Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server.Program.BuildWebHost(string[] args) -> Microsoft.Extensions.Hosting.IHost

+ 0 - 1
src/Components/WebAssembly/DevServer/src/PublicAPI.Unshipped.txt

@@ -1 +0,0 @@
-#nullable enable

+ 2 - 2
src/Components/WebAssembly/DevServer/src/Server/Program.cs

@@ -26,8 +26,8 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server
             Host.CreateDefaultBuilder(args)
                 .ConfigureHostConfiguration(config =>
                 {
-                    var applicationPath = args.SkipWhile(a => a != "--applicationpath").Skip(1).FirstOrDefault();
-                    var applicationDirectory = Path.GetDirectoryName(applicationPath);
+                    var applicationPath = args.SkipWhile(a => a != "--applicationpath").Skip(1).First();
+                    var applicationDirectory = Path.GetDirectoryName(applicationPath)!;
                     var name = Path.ChangeExtension(applicationPath, ".StaticWebAssets.xml");
 
                     var inMemoryConfiguration = new Dictionary<string, string>

+ 1 - 1
src/Components/WebAssembly/DevServer/src/build/Microsoft.AspNetCore.Components.WebAssembly.DevServer.targets

@@ -2,6 +2,6 @@
   <PropertyGroup>
     <_BlazorDevServerDll>$(MSBuildThisFileDirectory)../tools/blazor-devserver.dll</_BlazorDevServerDll>
     <RunCommand>dotnet</RunCommand>
-    <RunArguments>&quot;$(_BlazorDevServerDll)&quot; serve --applicationpath &quot;$(TargetPath)&quot;</RunArguments>
+    <RunArguments>&quot;$(_BlazorDevServerDll)&quot; --applicationpath &quot;$(TargetPath)&quot;</RunArguments>
   </PropertyGroup>
 </Project>