From ab7462f695d106f09188432f20c16e027dedaa04 Mon Sep 17 00:00:00 2001 From: Sanchit Mehta Date: Fri, 24 Jul 2020 16:06:02 -0700 Subject: [PATCH 01/18] Initial working version of ASP NETCore 3.1 Migration --- Kudu.Console/Kudu.Console.csproj | 11 ++++---- Kudu.Contracts/Kudu.Contracts.csproj | 2 +- Kudu.Core/Kudu.Core.csproj | 2 +- Kudu.Services.Web/Kudu.Services.Web.csproj | 3 +-- Kudu.Services.Web/Startup.cs | 26 +++---------------- Kudu.Services.Web/updateNodeModules.sh | 16 +++++------- .../DebugExtensionMiddleware.cs | 5 +--- Kudu.Services/Diagnostics/LogStreamManager.cs | 6 ++--- .../Infrastructure/FileCallbackResult.cs | 1 - Kudu.Services/Kudu.Services.csproj | 9 +++---- Kudu.Services/Zip/ZipController.cs | 1 - 11 files changed, 26 insertions(+), 56 deletions(-) diff --git a/Kudu.Console/Kudu.Console.csproj b/Kudu.Console/Kudu.Console.csproj index 3cfc0393..44727a09 100644 --- a/Kudu.Console/Kudu.Console.csproj +++ b/Kudu.Console/Kudu.Console.csproj @@ -1,11 +1,13 @@  - - netcoreapp2.2 - true + netcoreapp3.1 kudu + + true + + @@ -32,7 +34,4 @@ $(NoWarn);NU1701 - - true - diff --git a/Kudu.Contracts/Kudu.Contracts.csproj b/Kudu.Contracts/Kudu.Contracts.csproj index 1ea09fef..c9e6f745 100644 --- a/Kudu.Contracts/Kudu.Contracts.csproj +++ b/Kudu.Contracts/Kudu.Contracts.csproj @@ -1,7 +1,7 @@  - netcoreapp2.2 + netcoreapp3.1 true diff --git a/Kudu.Core/Kudu.Core.csproj b/Kudu.Core/Kudu.Core.csproj index d75282c2..a9e8201c 100644 --- a/Kudu.Core/Kudu.Core.csproj +++ b/Kudu.Core/Kudu.Core.csproj @@ -1,7 +1,7 @@  - netcoreapp2.2 + netcoreapp3.1 true diff --git a/Kudu.Services.Web/Kudu.Services.Web.csproj b/Kudu.Services.Web/Kudu.Services.Web.csproj index 8a3dc344..55465416 100644 --- a/Kudu.Services.Web/Kudu.Services.Web.csproj +++ b/Kudu.Services.Web/Kudu.Services.Web.csproj @@ -1,6 +1,6 @@  - netcoreapp2.2 + netcoreapp3.1 true @@ -24,7 +24,6 @@ - diff --git a/Kudu.Services.Web/Startup.cs b/Kudu.Services.Web/Startup.cs index 2d84e298..95ab0fee 100644 --- a/Kudu.Services.Web/Startup.cs +++ b/Kudu.Services.Web/Startup.cs @@ -3,7 +3,6 @@ using System.Configuration; using System.IO; using System.Net.Http; -using System.Net.Http.Formatting; using System.Reflection; using AspNetCore.RouteAnalyzer; using Kudu.Contracts; @@ -74,7 +73,6 @@ public Startup(IConfiguration configuration, IHostingEnvironment hostingEnvironm public void ConfigureServices(IServiceCollection services) { Console.WriteLine(@"Configure Services : " + DateTime.Now.ToString("hh.mm.ss.ffffff")); - FileSystemHelpers.DeleteDirectorySafe("/home/site/locks/deployment"); services.Configure(options => { options.MultipartBodyLengthLimit = 52428800; @@ -87,11 +85,9 @@ public void ConfigureServices(IServiceCollection services) // Kudu.Services contains all the Controllers var kuduServicesAssembly = Assembly.Load("Kudu.Services"); - services.AddMvcCore() + services.AddMvcCore(options => options.EnableEndpointRouting = false) .AddRazorPages() .AddAuthorization() - .AddJsonFormatters() - .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver()) .AddApplicationPart(kuduServicesAssembly).AddControllersAsServices() .AddApiExplorer(); @@ -317,10 +313,6 @@ public void ConfigureServices(IServiceCollection services) //target.FileName = logfile; } - // CORE TODO See NinjectServices.Stop - - // CORE TODO See signalr stuff in NinjectServices - private static Uri GetAbsoluteUri(HttpContext httpContext) { var request = httpContext.Request; @@ -338,7 +330,7 @@ public void Configure(IApplicationBuilder app, { Console.WriteLine(@"Configure : " + DateTime.Now.ToString("hh.mm.ss.ffffff")); - loggerFactory.AddEventSourceLogger(); + //loggerFactory.AddEventSourceLogger(); KuduWebUtil.MigrateToNetCorePatch(_webAppRuntimeEnvironment); @@ -397,16 +389,6 @@ public void Configure(IApplicationBuilder app, var configuration = app.ApplicationServices.GetRequiredService(); - // CORE TODO any equivalent for this? Needed? - //var configuration = kernel.Get(); - //GlobalConfiguration.Configuration.Formatters.Clear(); - //GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; - - var jsonFormatter = new JsonMediaTypeFormatter(); - - - // CORE TODO concept of "deprecation" in routes for traces, Do we need this for linux ? - // Push url foreach (var url in new[] {"/git-receive-pack", $"/{configuration.GitServerRoot}/git-receive-pack"}) { @@ -438,9 +420,9 @@ public void Configure(IApplicationBuilder app, // Sets up the file server to LogFiles KuduWebUtil.SetupFileServer(app, Path.Combine(_webAppRuntimeEnvironment.LogFilesPath,"kudu","deployment"), "/deploymentlogs"); - app.UseSwagger(); + // app.UseSwagger(); - app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Kudu API Docs"); }); + // app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Kudu API Docs"); }); app.UseMvc(routes => { diff --git a/Kudu.Services.Web/updateNodeModules.sh b/Kudu.Services.Web/updateNodeModules.sh index 6d929271..ce3802ae 100644 --- a/Kudu.Services.Web/updateNodeModules.sh +++ b/Kudu.Services.Web/updateNodeModules.sh @@ -25,19 +25,15 @@ retry() { done } -copy_to_build_dir() { - rm -rf "$@node_modules" - if [ ! -d "node_modules" ]; then +check_build_dir() { + echo "$@/node_modules" + if [ ! -d "$@/node_modules" ]; then exit 1 - else - mkdir -p "$@" - mkdir -p "$@/KuduConsole" - cp -r node_modules "$@" - mv node_modules "$@/KuduConsole/node_modules" fi } +pwd printf "\n\nInstalling Kudu Script\n\n" echo "$@" -retry npm --loglevel=error install https://github.com/projectkudu/KuduScript/tarball/16de31b5f5ca590ea085979e5fa5e74bb62f647e -copy_to_build_dir "$@" +retry npm --loglevel=error install --prefix $@ https://github.com/projectkudu/KuduScript/tarball/16de31b5f5ca590ea085979e5fa5e74bb62f647e +check_build_dir() "$@" diff --git a/Kudu.Services/DebugExtension/DebugExtensionMiddleware.cs b/Kudu.Services/DebugExtension/DebugExtensionMiddleware.cs index 8748c805..846d104b 100644 --- a/Kudu.Services/DebugExtension/DebugExtensionMiddleware.cs +++ b/Kudu.Services/DebugExtension/DebugExtensionMiddleware.cs @@ -51,8 +51,6 @@ public void ConfigureLogging() { if (loggerFactory == null) { - loggerFactory = new LoggerFactory(); - string level = Environment.GetEnvironmentVariable("APPSVC_TUNNEL_VERBOSITY"); LogLevel logLevel = LogLevel.Information; @@ -76,8 +74,7 @@ public void ConfigureLogging() } Console.WriteLine("Setting LogLevel to " + level); } - - loggerFactory.AddConsole(logLevel); + loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); } if (_logger == null) diff --git a/Kudu.Services/Diagnostics/LogStreamManager.cs b/Kudu.Services/Diagnostics/LogStreamManager.cs index 9e4eb4e8..e6fd0412 100644 --- a/Kudu.Services/Diagnostics/LogStreamManager.cs +++ b/Kudu.Services/Diagnostics/LogStreamManager.cs @@ -372,10 +372,10 @@ private Action DoSafeAction(Action func, string private void DisableResponseBuffering(HttpContext context) { - IHttpBufferingFeature bufferingFeature = context.Features.Get(); - if (bufferingFeature != null) + IHttpResponseBodyFeature responseBodyFeature = context.Features.Get(); + if (responseBodyFeature != null) { - bufferingFeature.DisableResponseBuffering(); + responseBodyFeature.DisableBuffering(); } } diff --git a/Kudu.Services/Infrastructure/FileCallbackResult.cs b/Kudu.Services/Infrastructure/FileCallbackResult.cs index e9eeaba8..c4f5d605 100644 --- a/Kudu.Services/Infrastructure/FileCallbackResult.cs +++ b/Kudu.Services/Infrastructure/FileCallbackResult.cs @@ -1,6 +1,5 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Infrastructure; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using System; diff --git a/Kudu.Services/Kudu.Services.csproj b/Kudu.Services/Kudu.Services.csproj index 52f96475..60c8aca3 100644 --- a/Kudu.Services/Kudu.Services.csproj +++ b/Kudu.Services/Kudu.Services.csproj @@ -1,13 +1,15 @@  - netcoreapp2.2 + netcoreapp3.1 true false - + + + @@ -33,7 +35,4 @@ true - - /opt/Kudu/Kudu.Services.xml - diff --git a/Kudu.Services/Zip/ZipController.cs b/Kudu.Services/Zip/ZipController.cs index d9773d84..589163c1 100644 --- a/Kudu.Services/Zip/ZipController.cs +++ b/Kudu.Services/Zip/ZipController.cs @@ -2,7 +2,6 @@ using Kudu.Core; using Kudu.Services.Infrastructure; using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Internal; using System; using System.IO.Abstractions; using System.IO.Compression; From 483cd93abb45be737c1dd05ff89c22b23629878c Mon Sep 17 00:00:00 2001 From: Sanchit Mehta Date: Thu, 30 Jul 2020 16:30:17 -0700 Subject: [PATCH 02/18] More fixes --- Kudu.Console/Program.cs | 5 +---- Kudu.Contracts/IEnvironment.cs | 2 +- Kudu.Services.Web/Startup.cs | 14 -------------- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/Kudu.Console/Program.cs b/Kudu.Console/Program.cs index 3684a8b5..c220caa1 100644 --- a/Kudu.Console/Program.cs +++ b/Kudu.Console/Program.cs @@ -279,17 +279,14 @@ private static IEnvironment GetEnvironment(string siteRoot, string requestId) string binPath = System.Environment.GetEnvironmentVariable("SCM_BIN_PATH"); if (string.IsNullOrWhiteSpace(binPath)) { - // CORE TODO Double check. Process.GetCurrentProcess() always gets the dotnet.exe process, - // so changed to Assembly.GetEntryAssembly().Location binPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); } - // CORE TODO Handing in a null IHttpContextAccessor (and KuduConsoleFullPath) again return new Kudu.Core.Environment(root, EnvironmentHelper.NormalizeBinPath(binPath), repositoryPath, requestId, - Path.Combine(AppContext.BaseDirectory, "KuduConsole", "kudu.dll"), + Path.Combine(AppContext.BaseDirectory, "KuduConsole", "kudu"), null, new FileSystemPathProvider(new NullMeshPersistentFileSystem())); } diff --git a/Kudu.Contracts/IEnvironment.cs b/Kudu.Contracts/IEnvironment.cs index a10c22f8..880e75dd 100644 --- a/Kudu.Contracts/IEnvironment.cs +++ b/Kudu.Contracts/IEnvironment.cs @@ -29,7 +29,7 @@ public interface IEnvironment string FunctionsPath { get; } // e.g. /site/wwwroot string AppBaseUrlPrefix { get; } // e.g. siteName.azurewebsites.net string RequestId { get; } // e.g. x-arr-log-id or x-ms-request-id header value - string KuduConsoleFullPath { get; } // e.g. KuduConsole/kudu.dll + string KuduConsoleFullPath { get; } // e.g. KuduConsole/kudu string SitePackagesPath { get; } // e.g. /data/SitePackages bool IsOnLinuxConsumption { get; } // e.g. True on Linux Consumption. False on App Service. } diff --git a/Kudu.Services.Web/Startup.cs b/Kudu.Services.Web/Startup.cs index 95ab0fee..7f4c2cb2 100644 --- a/Kudu.Services.Web/Startup.cs +++ b/Kudu.Services.Web/Startup.cs @@ -273,20 +273,6 @@ public void ConfigureServices(IServiceCollection services) services.AddScoped(); - // KuduWebUtil.MigrateSite(environment, noContextDeploymentsSettingsManager); - // RemoveOldTracePath(environment); - // RemoveTempFileFromUserDrive(environment); - - // CORE TODO Windows Fix: Temporary fix for https://github.com/npm/npm/issues/5905 - //EnsureNpmGlobalDirectory(); - //EnsureUserProfileDirectory(); - - //// Skip SSL Certificate Validate - //if (Environment.SkipSslValidation) - //{ - // ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; - //} - //// Make sure webpages:Enabled is true. Even though we set it in web.config, it could be overwritten by //// an Azure AppSetting that's supposed to be for the site only but incidently affects Kudu as well. ConfigurationManager.AppSettings["webpages:Enabled"] = "true"; From 01c1c9fead5ff7f14ff029f095c2af0d5621a251 Mon Sep 17 00:00:00 2001 From: Sanchit Mehta Date: Thu, 30 Jul 2020 16:30:17 -0700 Subject: [PATCH 03/18] More fixes --- Kudu.Console/Program.cs | 5 +---- Kudu.Contracts/IEnvironment.cs | 2 +- Kudu.Services.Web/Kudu.Services.Web.csproj | 4 ++-- Kudu.Services.Web/Startup.cs | 14 -------------- 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/Kudu.Console/Program.cs b/Kudu.Console/Program.cs index 3684a8b5..c220caa1 100644 --- a/Kudu.Console/Program.cs +++ b/Kudu.Console/Program.cs @@ -279,17 +279,14 @@ private static IEnvironment GetEnvironment(string siteRoot, string requestId) string binPath = System.Environment.GetEnvironmentVariable("SCM_BIN_PATH"); if (string.IsNullOrWhiteSpace(binPath)) { - // CORE TODO Double check. Process.GetCurrentProcess() always gets the dotnet.exe process, - // so changed to Assembly.GetEntryAssembly().Location binPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); } - // CORE TODO Handing in a null IHttpContextAccessor (and KuduConsoleFullPath) again return new Kudu.Core.Environment(root, EnvironmentHelper.NormalizeBinPath(binPath), repositoryPath, requestId, - Path.Combine(AppContext.BaseDirectory, "KuduConsole", "kudu.dll"), + Path.Combine(AppContext.BaseDirectory, "KuduConsole", "kudu"), null, new FileSystemPathProvider(new NullMeshPersistentFileSystem())); } diff --git a/Kudu.Contracts/IEnvironment.cs b/Kudu.Contracts/IEnvironment.cs index a10c22f8..880e75dd 100644 --- a/Kudu.Contracts/IEnvironment.cs +++ b/Kudu.Contracts/IEnvironment.cs @@ -29,7 +29,7 @@ public interface IEnvironment string FunctionsPath { get; } // e.g. /site/wwwroot string AppBaseUrlPrefix { get; } // e.g. siteName.azurewebsites.net string RequestId { get; } // e.g. x-arr-log-id or x-ms-request-id header value - string KuduConsoleFullPath { get; } // e.g. KuduConsole/kudu.dll + string KuduConsoleFullPath { get; } // e.g. KuduConsole/kudu string SitePackagesPath { get; } // e.g. /data/SitePackages bool IsOnLinuxConsumption { get; } // e.g. True on Linux Consumption. False on App Service. } diff --git a/Kudu.Services.Web/Kudu.Services.Web.csproj b/Kudu.Services.Web/Kudu.Services.Web.csproj index 55465416..bec323ce 100644 --- a/Kudu.Services.Web/Kudu.Services.Web.csproj +++ b/Kudu.Services.Web/Kudu.Services.Web.csproj @@ -55,9 +55,9 @@ - + - + diff --git a/Kudu.Services.Web/Startup.cs b/Kudu.Services.Web/Startup.cs index 95ab0fee..7f4c2cb2 100644 --- a/Kudu.Services.Web/Startup.cs +++ b/Kudu.Services.Web/Startup.cs @@ -273,20 +273,6 @@ public void ConfigureServices(IServiceCollection services) services.AddScoped(); - // KuduWebUtil.MigrateSite(environment, noContextDeploymentsSettingsManager); - // RemoveOldTracePath(environment); - // RemoveTempFileFromUserDrive(environment); - - // CORE TODO Windows Fix: Temporary fix for https://github.com/npm/npm/issues/5905 - //EnsureNpmGlobalDirectory(); - //EnsureUserProfileDirectory(); - - //// Skip SSL Certificate Validate - //if (Environment.SkipSslValidation) - //{ - // ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; - //} - //// Make sure webpages:Enabled is true. Even though we set it in web.config, it could be overwritten by //// an Azure AppSetting that's supposed to be for the site only but incidently affects Kudu as well. ConfigurationManager.AppSettings["webpages:Enabled"] = "true"; From 21afa77641fc3c5fb5cf08426486c3065439411e Mon Sep 17 00:00:00 2001 From: Sanchit Mehta Date: Thu, 30 Jul 2020 19:36:07 -0700 Subject: [PATCH 04/18] test --- Kudu.Services.Web/Kudu.Services.Web.csproj | 7 ------- Kudu.Services.Web/KuduWebUtil.cs | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Kudu.Services.Web/Kudu.Services.Web.csproj b/Kudu.Services.Web/Kudu.Services.Web.csproj index bec323ce..e274bd32 100644 --- a/Kudu.Services.Web/Kudu.Services.Web.csproj +++ b/Kudu.Services.Web/Kudu.Services.Web.csproj @@ -52,13 +52,6 @@ - - - - - - - diff --git a/Kudu.Services.Web/KuduWebUtil.cs b/Kudu.Services.Web/KuduWebUtil.cs index 75879d12..f56f26d9 100644 --- a/Kudu.Services.Web/KuduWebUtil.cs +++ b/Kudu.Services.Web/KuduWebUtil.cs @@ -31,7 +31,7 @@ namespace Kudu.Services.Web { internal static class KuduWebUtil { - private const string KuduConsoleFilename = "kudu.dll"; + private const string KuduConsoleFilename = "kudu"; private const string KuduConsoleRelativePath = "KuduConsole"; private static Dictionary _namedLocks; From 5d43bff24f0e2d3c1739623e5b1cbde570e4014f Mon Sep 17 00:00:00 2001 From: Sanchit Mehta Date: Thu, 30 Jul 2020 19:44:42 -0700 Subject: [PATCH 05/18] Revert "More fixes" This reverts commit 01c1c9fead5ff7f14ff029f095c2af0d5621a251. --- Kudu.Console/Program.cs | 5 ++++- Kudu.Contracts/IEnvironment.cs | 2 +- Kudu.Services.Web/Kudu.Services.Web.csproj | 7 +++++++ Kudu.Services.Web/Startup.cs | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Kudu.Console/Program.cs b/Kudu.Console/Program.cs index c220caa1..3684a8b5 100644 --- a/Kudu.Console/Program.cs +++ b/Kudu.Console/Program.cs @@ -279,14 +279,17 @@ private static IEnvironment GetEnvironment(string siteRoot, string requestId) string binPath = System.Environment.GetEnvironmentVariable("SCM_BIN_PATH"); if (string.IsNullOrWhiteSpace(binPath)) { + // CORE TODO Double check. Process.GetCurrentProcess() always gets the dotnet.exe process, + // so changed to Assembly.GetEntryAssembly().Location binPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); } + // CORE TODO Handing in a null IHttpContextAccessor (and KuduConsoleFullPath) again return new Kudu.Core.Environment(root, EnvironmentHelper.NormalizeBinPath(binPath), repositoryPath, requestId, - Path.Combine(AppContext.BaseDirectory, "KuduConsole", "kudu"), + Path.Combine(AppContext.BaseDirectory, "KuduConsole", "kudu.dll"), null, new FileSystemPathProvider(new NullMeshPersistentFileSystem())); } diff --git a/Kudu.Contracts/IEnvironment.cs b/Kudu.Contracts/IEnvironment.cs index 880e75dd..a10c22f8 100644 --- a/Kudu.Contracts/IEnvironment.cs +++ b/Kudu.Contracts/IEnvironment.cs @@ -29,7 +29,7 @@ public interface IEnvironment string FunctionsPath { get; } // e.g. /site/wwwroot string AppBaseUrlPrefix { get; } // e.g. siteName.azurewebsites.net string RequestId { get; } // e.g. x-arr-log-id or x-ms-request-id header value - string KuduConsoleFullPath { get; } // e.g. KuduConsole/kudu + string KuduConsoleFullPath { get; } // e.g. KuduConsole/kudu.dll string SitePackagesPath { get; } // e.g. /data/SitePackages bool IsOnLinuxConsumption { get; } // e.g. True on Linux Consumption. False on App Service. } diff --git a/Kudu.Services.Web/Kudu.Services.Web.csproj b/Kudu.Services.Web/Kudu.Services.Web.csproj index e274bd32..55465416 100644 --- a/Kudu.Services.Web/Kudu.Services.Web.csproj +++ b/Kudu.Services.Web/Kudu.Services.Web.csproj @@ -52,6 +52,13 @@ + + + + + + + diff --git a/Kudu.Services.Web/Startup.cs b/Kudu.Services.Web/Startup.cs index 7f4c2cb2..95ab0fee 100644 --- a/Kudu.Services.Web/Startup.cs +++ b/Kudu.Services.Web/Startup.cs @@ -273,6 +273,20 @@ public void ConfigureServices(IServiceCollection services) services.AddScoped(); + // KuduWebUtil.MigrateSite(environment, noContextDeploymentsSettingsManager); + // RemoveOldTracePath(environment); + // RemoveTempFileFromUserDrive(environment); + + // CORE TODO Windows Fix: Temporary fix for https://github.com/npm/npm/issues/5905 + //EnsureNpmGlobalDirectory(); + //EnsureUserProfileDirectory(); + + //// Skip SSL Certificate Validate + //if (Environment.SkipSslValidation) + //{ + // ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; + //} + //// Make sure webpages:Enabled is true. Even though we set it in web.config, it could be overwritten by //// an Azure AppSetting that's supposed to be for the site only but incidently affects Kudu as well. ConfigurationManager.AppSettings["webpages:Enabled"] = "true"; From eedefce879ebdb9528a9817b85a0553df78cfaac Mon Sep 17 00:00:00 2001 From: Sanchit Mehta Date: Thu, 30 Jul 2020 20:17:12 -0700 Subject: [PATCH 06/18] Newtonsoft reference fix --- Kudu.Console/Program.cs | 2 +- Kudu.Contracts/IEnvironment.cs | 2 +- Kudu.Core/SourceControl/Git/KnownEnvironment.cs | 2 +- Kudu.Services.Web/Kudu.Services.Web.csproj | 5 +++-- Kudu.Services.Web/Program.cs | 2 +- Kudu.Services.Web/Startup.cs | 4 ++++ Kudu.Tests/TestMockedIEnvironment.cs | 2 +- 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Kudu.Console/Program.cs b/Kudu.Console/Program.cs index 3684a8b5..f92cdc2b 100644 --- a/Kudu.Console/Program.cs +++ b/Kudu.Console/Program.cs @@ -289,7 +289,7 @@ private static IEnvironment GetEnvironment(string siteRoot, string requestId) EnvironmentHelper.NormalizeBinPath(binPath), repositoryPath, requestId, - Path.Combine(AppContext.BaseDirectory, "KuduConsole", "kudu.dll"), + Path.Combine(AppContext.BaseDirectory, "KuduConsole", "kudu"), null, new FileSystemPathProvider(new NullMeshPersistentFileSystem())); } diff --git a/Kudu.Contracts/IEnvironment.cs b/Kudu.Contracts/IEnvironment.cs index a10c22f8..880e75dd 100644 --- a/Kudu.Contracts/IEnvironment.cs +++ b/Kudu.Contracts/IEnvironment.cs @@ -29,7 +29,7 @@ public interface IEnvironment string FunctionsPath { get; } // e.g. /site/wwwroot string AppBaseUrlPrefix { get; } // e.g. siteName.azurewebsites.net string RequestId { get; } // e.g. x-arr-log-id or x-ms-request-id header value - string KuduConsoleFullPath { get; } // e.g. KuduConsole/kudu.dll + string KuduConsoleFullPath { get; } // e.g. KuduConsole/kudu string SitePackagesPath { get; } // e.g. /data/SitePackages bool IsOnLinuxConsumption { get; } // e.g. True on Linux Consumption. False on App Service. } diff --git a/Kudu.Core/SourceControl/Git/KnownEnvironment.cs b/Kudu.Core/SourceControl/Git/KnownEnvironment.cs index 833d233f..d9080d04 100644 --- a/Kudu.Core/SourceControl/Git/KnownEnvironment.cs +++ b/Kudu.Core/SourceControl/Git/KnownEnvironment.cs @@ -22,7 +22,7 @@ internal static class KnownEnvironment // Command to launch the post receive hook for dynamic install // CORE NOTE modified the script to run "dotnet," assuming EXEPATH points // to a framework-dependent Core app. - public static string KUDUCOMMAND_DYNAMICINSTALL = "dotnet \"$" + EXEPATH + "\" " + + public static string KUDUCOMMAND_DYNAMICINSTALL = "\"$" + EXEPATH + "\" " + "\"$" + APPPATH + "\" " + "\"$" + MSBUILD + "\" " + "\"$" + DEPLOYER + "\""; diff --git a/Kudu.Services.Web/Kudu.Services.Web.csproj b/Kudu.Services.Web/Kudu.Services.Web.csproj index 55465416..44e90e31 100644 --- a/Kudu.Services.Web/Kudu.Services.Web.csproj +++ b/Kudu.Services.Web/Kudu.Services.Web.csproj @@ -28,6 +28,7 @@ + @@ -56,8 +57,8 @@ - - + + diff --git a/Kudu.Services.Web/Program.cs b/Kudu.Services.Web/Program.cs index 042b0c85..acf623a7 100644 --- a/Kudu.Services.Web/Program.cs +++ b/Kudu.Services.Web/Program.cs @@ -21,4 +21,4 @@ private static IWebHostBuilder CreateWebHostBuilder(string[] args) => .UseKestrel(options => { options.Limits.MaxRequestBodySize = null; }) .UseStartup(); } -} \ No newline at end of file +} diff --git a/Kudu.Services.Web/Startup.cs b/Kudu.Services.Web/Startup.cs index 95ab0fee..c15b7383 100644 --- a/Kudu.Services.Web/Startup.cs +++ b/Kudu.Services.Web/Startup.cs @@ -86,6 +86,10 @@ public void ConfigureServices(IServiceCollection services) var kuduServicesAssembly = Assembly.Load("Kudu.Services"); services.AddMvcCore(options => options.EnableEndpointRouting = false) + .AddNewtonsoftJson(o => + { + o.SerializerSettings.ContractResolver = new DefaultContractResolver(); + }) .AddRazorPages() .AddAuthorization() .AddApplicationPart(kuduServicesAssembly).AddControllersAsServices() diff --git a/Kudu.Tests/TestMockedIEnvironment.cs b/Kudu.Tests/TestMockedIEnvironment.cs index 7175a34f..f21c9707 100644 --- a/Kudu.Tests/TestMockedIEnvironment.cs +++ b/Kudu.Tests/TestMockedIEnvironment.cs @@ -34,7 +34,7 @@ public class TestMockedIEnvironment : IEnvironment public string _FunctionsPath = "/site/wwwroot"; public string _AppBaseUrlPrefix = "siteName.azurewebsites.net"; public string _RequestId = "00000000-0000-0000-0000-000000000000"; - public string _KuduConsoleFullPath = "KuduConsole/kudu.dll"; + public string _KuduConsoleFullPath = "KuduConsole/kudu"; public string _SitePackagesPath = "/data/SitePackages"; public bool _IsOnLinuxConsumption = false; From 41f354d29f68ee551c1ba66d05d7c646ac3157f2 Mon Sep 17 00:00:00 2001 From: Sanchit Mehta Date: Thu, 30 Jul 2020 22:36:45 -0700 Subject: [PATCH 07/18] UI Changes --- Kudu.Console/Program.cs | 2 +- Kudu.Services.Web/Kudu.Services.Web.csproj | 26 ++ .../DebugConsole2/DebugConsole2Controller.cs | 6 +- .../DebugConsole2/LinuxConsole2.cshtml | 2 +- .../DebugConsole2/WindowsConsole2.cshtml | 2 +- Kudu.Services.Web/Pages/Error.cshtml | 4 +- Kudu.Services.Web/Pages/Index.cshtml | 439 ++++++++++++++---- .../Pages/{NewUI => }/JsonViewer.cshtml | 0 .../Pages/{NewUI => }/JsonViewer.cshtml.cs | 0 Kudu.Services.Web/Pages/NewUI/Env.cshtml | 124 ----- Kudu.Services.Web/Pages/NewUI/Env.cshtml.cs | 17 - Kudu.Services.Web/Pages/NewUI/Index.cshtml | 362 --------------- Kudu.Services.Web/Pages/NewUI/_Layout.cshtml | 172 ------- Kudu.Services.Web/Pages/_Layout.cshtml | 220 +++++---- .../Pages/{NewUI => }/bash.cshtml | 0 .../kududebug.cshtml => kududebugv2.cshtml} | 0 .../Pages/{NewUI => }/logs.cshtml | 0 .../Pages/{NewUI => }/webssh.cshtml | 0 .../Pages/{NewUI => }/wwwroot.cshtml | 0 .../wwwroot/Content/Scripts/jsonTree.js | 2 +- 20 files changed, 517 insertions(+), 861 deletions(-) rename Kudu.Services.Web/Pages/{NewUI => }/DebugConsole2/DebugConsole2Controller.cs (72%) rename Kudu.Services.Web/Pages/{NewUI => }/DebugConsole2/LinuxConsole2.cshtml (94%) rename Kudu.Services.Web/Pages/{NewUI => }/DebugConsole2/WindowsConsole2.cshtml (99%) rename Kudu.Services.Web/Pages/{NewUI => }/JsonViewer.cshtml (100%) rename Kudu.Services.Web/Pages/{NewUI => }/JsonViewer.cshtml.cs (100%) delete mode 100644 Kudu.Services.Web/Pages/NewUI/Env.cshtml delete mode 100644 Kudu.Services.Web/Pages/NewUI/Env.cshtml.cs delete mode 100644 Kudu.Services.Web/Pages/NewUI/Index.cshtml delete mode 100644 Kudu.Services.Web/Pages/NewUI/_Layout.cshtml rename Kudu.Services.Web/Pages/{NewUI => }/bash.cshtml (100%) rename Kudu.Services.Web/Pages/{NewUI/kududebug.cshtml => kududebugv2.cshtml} (100%) rename Kudu.Services.Web/Pages/{NewUI => }/logs.cshtml (100%) rename Kudu.Services.Web/Pages/{NewUI => }/webssh.cshtml (100%) rename Kudu.Services.Web/Pages/{NewUI => }/wwwroot.cshtml (100%) diff --git a/Kudu.Console/Program.cs b/Kudu.Console/Program.cs index c220caa1..d8351488 100644 --- a/Kudu.Console/Program.cs +++ b/Kudu.Console/Program.cs @@ -211,7 +211,7 @@ private static int PerformDeploy( finally { System.Console.WriteLine("Deployment Logs : '"+ - env.AppBaseUrlPrefix+ "/newui/jsonviewer?view_url=/api/deployments/" + + env.AppBaseUrlPrefix+ "/jsonviewer?view_url=/api/deployments/" + gitRepository.GetChangeSet(settingsManager.GetBranch()).Id+"/log'"); } } diff --git a/Kudu.Services.Web/Kudu.Services.Web.csproj b/Kudu.Services.Web/Kudu.Services.Web.csproj index 44e90e31..b2f5962c 100644 --- a/Kudu.Services.Web/Kudu.Services.Web.csproj +++ b/Kudu.Services.Web/Kudu.Services.Web.csproj @@ -46,6 +46,32 @@ + + + true + PreserveNewest + + + true + PreserveNewest + + + true + PreserveNewest + + + true + PreserveNewest + + + true + PreserveNewest + + + true + PreserveNewest + + diff --git a/Kudu.Services.Web/Pages/NewUI/DebugConsole2/DebugConsole2Controller.cs b/Kudu.Services.Web/Pages/DebugConsole2/DebugConsole2Controller.cs similarity index 72% rename from Kudu.Services.Web/Pages/NewUI/DebugConsole2/DebugConsole2Controller.cs rename to Kudu.Services.Web/Pages/DebugConsole2/DebugConsole2Controller.cs index d801917b..8f0addf2 100644 --- a/Kudu.Services.Web/Pages/NewUI/DebugConsole2/DebugConsole2Controller.cs +++ b/Kudu.Services.Web/Pages/DebugConsole2/DebugConsole2Controller.cs @@ -10,17 +10,17 @@ public class DebugConsole2Controller : Controller public ActionResult Index() { var os = OSDetector.IsOnWindows() ? "Windows" : "Linux"; - return View($"~/Pages/NewUI/DebugConsole2/{os}Console2.cshtml"); + return View($"~/Pages/DebugConsole2/{os}Console2.cshtml"); } public ActionResult LinuxConsole() { - return View($"~/Pages/NewUI/DebugConsole/LinuxConsole2.cshtml"); + return View($"~/Pages/DebugConsole/LinuxConsole2.cshtml"); } public ActionResult WindowsConsole() { - return View($"~/Pages/NewUI/DebugConsole2/WindowsConsole2.cshtml"); + return View($"~/Pages/DebugConsole2/WindowsConsole2.cshtml"); } } diff --git a/Kudu.Services.Web/Pages/NewUI/DebugConsole2/LinuxConsole2.cshtml b/Kudu.Services.Web/Pages/DebugConsole2/LinuxConsole2.cshtml similarity index 94% rename from Kudu.Services.Web/Pages/NewUI/DebugConsole2/LinuxConsole2.cshtml rename to Kudu.Services.Web/Pages/DebugConsole2/LinuxConsole2.cshtml index 9bf943b7..80a340e0 100644 --- a/Kudu.Services.Web/Pages/NewUI/DebugConsole2/LinuxConsole2.cshtml +++ b/Kudu.Services.Web/Pages/DebugConsole2/LinuxConsole2.cshtml @@ -1,6 +1,6 @@ @{ ViewData["Title"] = "Diagnostic Console"; - Layout = "~/Pages/NewUI/_Layout.cshtml"; + Layout = "~/Pages/_Layout.cshtml"; } diff --git a/Kudu.Services.Web/Pages/NewUI/DebugConsole2/WindowsConsole2.cshtml b/Kudu.Services.Web/Pages/DebugConsole2/WindowsConsole2.cshtml similarity index 99% rename from Kudu.Services.Web/Pages/NewUI/DebugConsole2/WindowsConsole2.cshtml rename to Kudu.Services.Web/Pages/DebugConsole2/WindowsConsole2.cshtml index d4707d3c..098e1c74 100644 --- a/Kudu.Services.Web/Pages/NewUI/DebugConsole2/WindowsConsole2.cshtml +++ b/Kudu.Services.Web/Pages/DebugConsole2/WindowsConsole2.cshtml @@ -1,6 +1,6 @@ @{ ViewData["Title"] = "Diagnostic Console"; - Layout = "~/Pages/NewUI/_Layout.cshtml"; + Layout = "~/Pages/_Layout.cshtml"; } diff --git a/Kudu.Services.Web/Pages/Error.cshtml b/Kudu.Services.Web/Pages/Error.cshtml index b1f3143a..a6ddc94b 100644 --- a/Kudu.Services.Web/Pages/Error.cshtml +++ b/Kudu.Services.Web/Pages/Error.cshtml @@ -4,7 +4,9 @@ ViewData["Title"] = "Error"; } -

Error.

+

+ Error. +

An error occurred while processing your request.

@if (Model.ShowRequestId) diff --git a/Kudu.Services.Web/Pages/Index.cshtml b/Kudu.Services.Web/Pages/Index.cshtml index 1cf11845..6ee48c29 100644 --- a/Kudu.Services.Web/Pages/Index.cshtml +++ b/Kudu.Services.Web/Pages/Index.cshtml @@ -1,123 +1,362 @@ -@page -@using System -@using System.Reflection + +@page +@using Kudu.Core.Deployment @using Microsoft.AspNetCore.Hosting @inject IHostingEnvironment hostingEnvironment +@inject IDeploymentManager deploymentManager @{ + ViewBag.Title = "title"; + Layout = "_Layout"; +} - // If Kudu home page gets requested with the api-version, we are likely dealing with a call - // on the 'ARM bridge' to list 'extensions'. e.g. - // /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Web/sites/{site}/extensions?api-version=2015-08-01 - // Since we can't actually return a list of extensions, return [], which is enough to avoid ARM faliures + - //if (Request.QueryString["api-version"] != null) - //{ - // Response.Write("[]"); - // Response.ContentType = "application/json"; - // Response.End(); - //} + - string appServiceVersion = GetAppServiceVersion(); - Console.WriteLine(DateTime.Now.ToString("hh.mm.ss.ffffff")); -} +@if (Kudu.Core.Environment.IsAzureEnvironment()) + { + + } -@functions { - string GetAppServiceVersion() +@if (Kudu.Core.Environment.IsAzureEnvironment()) { - Assembly assembly; - try - { - assembly = Assembly.Load("Microsoft.Web.Hosting, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); - var fileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location); - return fileVersionInfo.ProductVersion; - } - catch - { - return ""; - } + } + +@{ + var workerIdHash = System.Environment.GetEnvironmentVariable(Constants.AzureWebsiteInstanceId); + var workerIdShortHash = workerIdHash?.Substring(0, 12); + const string version = Constants.KuduBuild; + var showLearningBanner = !deploymentManager.GetResults().Any(); + var welcomeBannerDisplayVal = showLearningBanner ? "display:block" : "display:none"; + var lastDeployedDisplayVal = !showLearningBanner ? "display:block" : "display:none"; } - -
- @{ - string commitFile = System.IO.Path.Combine(hostingEnvironment.WebRootPath, "commit.txt"); - string sha = System.IO.File.Exists(commitFile) ? System.IO.File.ReadAllText(commitFile).Trim() : null; - //var version = typeof(Kudu.Services.Web.Tracing.TraceMiddleware).Assembly.GetName().Version; - var version = Constants.KuduBuild; - } -

Environment

-
-
- Build + +
+
+
+
+

KuduLite

@version
+ Site UpTime: @Tracing.TraceMiddleware.UpTime.ToString(@"dd\.hh\:mm\:ss") | Site Folder: @PathResolver.ResolveRootPath() | Temp Folder: @System.IO.Path.GetTempPath() +
Kudu Attached to Instance:   @workerIdShortHash | + + +
-
- @version - - @if (!string.IsNullOrEmpty(sha)) - { - - (@sha.Substring(0, 10)) - - } + + -
-
-
- Site up time +
+
+
+ Recent Deployment   +

...  

+ +
+
+ ... | ... ago | ... | +
+
+
+
+ View Logs +
+
-
- @Kudu.Services.Web.Tracing.TraceMiddleware.UpTime.ToString(@"dd\.hh\:mm\:ss") +
+
+
+
+ +
+
+ +
+
+
+
+
-
- Site folder -
-
- @Kudu.Services.Web.PathResolver.ResolveRootPath() +
+
+
+
 App Essentials
+
+ +
-
-
-
- Temp folder +
+
+
+
 Deployments
+
+ +
-
- @System.IO.Path.GetTempPath() +
+
+
+
 Web App Container
+
+ +
+
-

REST API (works best when using a JSON viewer extension)

- -

Browse Directory

- -

More information about Kudu can be found on the wiki.

+ + diff --git a/Kudu.Services.Web/Pages/NewUI/JsonViewer.cshtml b/Kudu.Services.Web/Pages/JsonViewer.cshtml similarity index 100% rename from Kudu.Services.Web/Pages/NewUI/JsonViewer.cshtml rename to Kudu.Services.Web/Pages/JsonViewer.cshtml diff --git a/Kudu.Services.Web/Pages/NewUI/JsonViewer.cshtml.cs b/Kudu.Services.Web/Pages/JsonViewer.cshtml.cs similarity index 100% rename from Kudu.Services.Web/Pages/NewUI/JsonViewer.cshtml.cs rename to Kudu.Services.Web/Pages/JsonViewer.cshtml.cs diff --git a/Kudu.Services.Web/Pages/NewUI/Env.cshtml b/Kudu.Services.Web/Pages/NewUI/Env.cshtml deleted file mode 100644 index 7e23bb7e..00000000 --- a/Kudu.Services.Web/Pages/NewUI/Env.cshtml +++ /dev/null @@ -1,124 +0,0 @@ -@page -@using System -@using System.Collections -@using System.Collections.Generic -@model Kudu.Services.Web.Pages.EnvModel -@inject IHttpContextAccessor httpContextAccessor -@inject IDeploymentSettingsManager _settingsManager -@{ - ViewData["Title"] = "Environment"; -} - - - - -
-

System info

-
    -
  • System up time: @TimeSpan.FromMilliseconds(Environment.TickCount)
  • -
  • OS version: @Environment.OSVersion
  • -
  • 64 bit system: @Environment.Is64BitOperatingSystem
  • -
  • 64 bit process: @Environment.Is64BitProcess
  • -
  • Processor count: @Environment.ProcessorCount
  • -
  • Machine name: @Environment.MachineName
  • -
  • Instance id: @Kudu.Core.Infrastructure.InstanceIdUtility.GetInstanceId()
  • -
  • Short instance id: @Kudu.Core.Infrastructure.InstanceIdUtility.GetShortInstanceId()
  • -
  • CLR version: @Environment.Version
  • -
  • System directory: @Environment.SystemDirectory
  • -
  • Current working directory: @Environment.CurrentDirectory
  • -
  • IIS command line: @Environment.CommandLine
  • - @if (Kudu.Core.Helpers.OSDetector.IsOnWindows()) - { - var homePath = Environment.GetEnvironmentVariable("HOME"); - var localPath = "d:\\local"; -
  • @homePath usage: @Html.Raw(Kudu.Core.Environment.GetFreeSpaceHtml(homePath))
  • - if (Kudu.Core.Environment.IsAzureEnvironment() && System.IO.Directory.Exists(localPath)) - { -
  • @localPath usage: @Html.Raw(@Kudu.Core.Environment.GetFreeSpaceHtml(localPath))
  • - } - } -
- -

AppSettings

-
    - @using System.Configuration; -@using System.Linq -@using Core.Infrastructure -@using Kudu.Contracts.Settings - @using Microsoft.AspNetCore.Http - @foreach (string name in System.Configuration.ConfigurationManager.AppSettings) - { -
  • - @name = @System.Configuration.ConfigurationManager.AppSettings[name] -
  • - } - - @foreach (KeyValuePair kv in _settingsManager.GetValues()) - { - - if (kv.Value != null) - { -
  • @kv.Key = @kv.Value
  • - } - - } -
- -

Connection Strings

-
    - @foreach (ConnectionStringSettings settings in ConfigurationManager.ConnectionStrings) - { -
  • - @settings.Name -
      -
    • ConnectionString = @settings.ConnectionString
    • -
    • ProviderName = @settings.ProviderName
    • -
    -
  • - } -
- -

Environment variables

-
    - @foreach (DictionaryEntry entry in Environment.GetEnvironmentVariables().OfType().OrderBy(e => e.Key)) - { -
  • @entry.Key = @entry.Value
  • - } -
- -

PATH

-
    - @foreach (string folder in Environment.GetEnvironmentVariable("PATH").Split(System.IO.Path.PathSeparator).Where(s => !String.IsNullOrWhiteSpace(s))) - { -
  • @folder
  • - } -
- -

HTTP headers

-
    - @foreach (string name in httpContextAccessor.HttpContext.Request.Headers.Keys.OrderBy(s => s)) - { -
  • @name=@httpContextAccessor.HttpContext.Request.Headers[name].ToString()
  • - } -
- - @* -

Server variables

-
    - @foreach (string name in HttpContext.Connection.OfType().OrderBy(s => s)) - { -
  • @name=@HttpContext.Connection[name]
  • - } -
- *@ -
diff --git a/Kudu.Services.Web/Pages/NewUI/Env.cshtml.cs b/Kudu.Services.Web/Pages/NewUI/Env.cshtml.cs deleted file mode 100644 index 19ca2ae0..00000000 --- a/Kudu.Services.Web/Pages/NewUI/Env.cshtml.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Kudu.Services.Web.Pages.NewUI -{ - public class EnvModel : PageModel - { - public void OnGet() - { - - } - } -} \ No newline at end of file diff --git a/Kudu.Services.Web/Pages/NewUI/Index.cshtml b/Kudu.Services.Web/Pages/NewUI/Index.cshtml deleted file mode 100644 index 33996770..00000000 --- a/Kudu.Services.Web/Pages/NewUI/Index.cshtml +++ /dev/null @@ -1,362 +0,0 @@ - -@page -@using Kudu.Core.Deployment -@using Microsoft.AspNetCore.Hosting -@inject IHostingEnvironment hostingEnvironment -@inject IDeploymentManager deploymentManager - -@{ - ViewBag.Title = "title"; - Layout = "_Layout"; -} - - - - - -@if (Kudu.Core.Environment.IsAzureEnvironment()) - { - - } - -@if (Kudu.Core.Environment.IsAzureEnvironment()) - { - - } - -@{ - var workerIdHash = System.Environment.GetEnvironmentVariable(Constants.AzureWebsiteInstanceId); - var workerIdShortHash = workerIdHash?.Substring(0, 12); - const string version = Constants.KuduBuild; - var showLearningBanner = !deploymentManager.GetResults().Any(); - var welcomeBannerDisplayVal = showLearningBanner ? "display:block" : "display:none"; - var lastDeployedDisplayVal = !showLearningBanner ? "display:block" : "display:none"; -} - -
-
-
-
-

KuduLite

@version
- Site UpTime: @Tracing.TraceMiddleware.UpTime.ToString(@"dd\.hh\:mm\:ss") | Site Folder: @PathResolver.ResolveRootPath() | Temp Folder: @System.IO.Path.GetTempPath() -
Kudu Attached to Instance:   @workerIdShortHash | - - - -
- - -
-
-
- Recent Deployment   -

...  

- -
-
- ... | ... ago | ... | -
-
-
-
- View Logs -
-
-
-
-
-
-
- -
-
- -
-
-
-
-
-
-
-
-
-
-
-
 App Essentials
-
- -
-
-
-
-
-
 Deployments
-
- -
-
-
-
-
-
 Web App Container
-
- -
-
-
-
-
- - diff --git a/Kudu.Services.Web/Pages/NewUI/_Layout.cshtml b/Kudu.Services.Web/Pages/NewUI/_Layout.cshtml deleted file mode 100644 index 09a07e64..00000000 --- a/Kudu.Services.Web/Pages/NewUI/_Layout.cshtml +++ /dev/null @@ -1,172 +0,0 @@ -@using Microsoft.AspNetCore.Http -@inject IHttpContextAccessor httpContextAccessor - - - - - - @if (!Kudu.Core.Helpers.OSDetector.IsOnWindows()) - { - - - } - else - { - - - - } - - - - - - - - - - -Azure App Service - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Kudu.Services.Web/Pages/_Layout.cshtml b/Kudu.Services.Web/Pages/_Layout.cshtml index 25416f55..e03dc681 100644 --- a/Kudu.Services.Web/Pages/_Layout.cshtml +++ b/Kudu.Services.Web/Pages/_Layout.cshtml @@ -1,10 +1,9 @@ @using Microsoft.AspNetCore.Http -@using System @inject IHttpContextAccessor httpContextAccessor - - - + + + @if (!Kudu.Core.Helpers.OSDetector.IsOnWindows()) { @@ -15,70 +14,45 @@ { - - } - - - - Azure App Service - - - - @RenderSection("PageHead", required: false) - - @* // CORE TODO VirtualPathUtility no longer exists *@ - @**@ - @if (Kudu.Core.Helpers.OSDetector.IsOnWindows()) - { - - } - else - { - + } + + + + + + + + + + +Azure App Service + + + + + + + + + + + + - + +
+
+ - -
-@RenderBody() + + + + + + + + + - + \ No newline at end of file diff --git a/Kudu.Services.Web/Pages/NewUI/bash.cshtml b/Kudu.Services.Web/Pages/bash.cshtml similarity index 100% rename from Kudu.Services.Web/Pages/NewUI/bash.cshtml rename to Kudu.Services.Web/Pages/bash.cshtml diff --git a/Kudu.Services.Web/Pages/NewUI/kududebug.cshtml b/Kudu.Services.Web/Pages/kududebugv2.cshtml similarity index 100% rename from Kudu.Services.Web/Pages/NewUI/kududebug.cshtml rename to Kudu.Services.Web/Pages/kududebugv2.cshtml diff --git a/Kudu.Services.Web/Pages/NewUI/logs.cshtml b/Kudu.Services.Web/Pages/logs.cshtml similarity index 100% rename from Kudu.Services.Web/Pages/NewUI/logs.cshtml rename to Kudu.Services.Web/Pages/logs.cshtml diff --git a/Kudu.Services.Web/Pages/NewUI/webssh.cshtml b/Kudu.Services.Web/Pages/webssh.cshtml similarity index 100% rename from Kudu.Services.Web/Pages/NewUI/webssh.cshtml rename to Kudu.Services.Web/Pages/webssh.cshtml diff --git a/Kudu.Services.Web/Pages/NewUI/wwwroot.cshtml b/Kudu.Services.Web/Pages/wwwroot.cshtml similarity index 100% rename from Kudu.Services.Web/Pages/NewUI/wwwroot.cshtml rename to Kudu.Services.Web/Pages/wwwroot.cshtml diff --git a/Kudu.Services.Web/wwwroot/Content/Scripts/jsonTree.js b/Kudu.Services.Web/wwwroot/Content/Scripts/jsonTree.js index f1406434..2c0aa8d4 100644 --- a/Kudu.Services.Web/wwwroot/Content/Scripts/jsonTree.js +++ b/Kudu.Services.Web/wwwroot/Content/Scripts/jsonTree.js @@ -395,7 +395,7 @@ var jsonTree = (function() { shouldShowJSONViewerURL = false; } if(shouldShowJSONViewerURL) { - val = "" + val + ""; + val = "" + val + ""; }else{ val = ""+val+""; } From 8a34530a7ea318e4e9c562b0fb77017270b034f2 Mon Sep 17 00:00:00 2001 From: Sanchit Mehta Date: Thu, 30 Jul 2020 22:42:19 -0700 Subject: [PATCH 08/18] Change Kudu Console publish settings --- Kudu.Services.Web/Kudu.Services.Web.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kudu.Services.Web/Kudu.Services.Web.csproj b/Kudu.Services.Web/Kudu.Services.Web.csproj index b2f5962c..effe427a 100644 --- a/Kudu.Services.Web/Kudu.Services.Web.csproj +++ b/Kudu.Services.Web/Kudu.Services.Web.csproj @@ -83,8 +83,8 @@ - - + + From 8ccadb24aca06cbfdeeb3e6d53fb96ee1c6e146f Mon Sep 17 00:00:00 2001 From: Sanchit Mehta Date: Thu, 30 Jul 2020 23:23:20 -0700 Subject: [PATCH 09/18] Fix IHostingEnvironment --- Kudu.Services.Web/KuduWebUtil.cs | 2 +- Kudu.Services.Web/Pages/kududebugv2.cshtml | 3 --- Kudu.Services.Web/Startup.cs | 7 ++++--- 3 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 Kudu.Services.Web/Pages/kududebugv2.cshtml diff --git a/Kudu.Services.Web/KuduWebUtil.cs b/Kudu.Services.Web/KuduWebUtil.cs index f56f26d9..bafbfb11 100644 --- a/Kudu.Services.Web/KuduWebUtil.cs +++ b/Kudu.Services.Web/KuduWebUtil.cs @@ -311,7 +311,7 @@ internal static ILogger GetDeploymentLogger(IServiceProvider serviceProvider) /// Returns a specified environment configuration as the current webapp's /// default configuration during the runtime. /// - internal static IEnvironment GetEnvironment(IHostingEnvironment hostingEnvironment, + internal static IEnvironment GetEnvironment(IWebHostEnvironment hostingEnvironment, IFileSystemPathProvider fileSystemPathsProvider, IDeploymentSettingsManager settings = null, IHttpContextAccessor httpContextAccessor = null) diff --git a/Kudu.Services.Web/Pages/kududebugv2.cshtml b/Kudu.Services.Web/Pages/kududebugv2.cshtml deleted file mode 100644 index 4ef3c9bf..00000000 --- a/Kudu.Services.Web/Pages/kududebugv2.cshtml +++ /dev/null @@ -1,3 +0,0 @@ -@page - - diff --git a/Kudu.Services.Web/Startup.cs b/Kudu.Services.Web/Startup.cs index b44deb90..89eb1022 100644 --- a/Kudu.Services.Web/Startup.cs +++ b/Kudu.Services.Web/Startup.cs @@ -41,16 +41,17 @@ using Newtonsoft.Json.Serialization; using Swashbuckle.AspNetCore.Swagger; using ILogger = Kudu.Core.Deployment.ILogger; +using Microsoft.Extensions.Hosting; namespace Kudu.Services.Web { public class Startup { - private readonly IHostingEnvironment _hostingEnvironment; + private readonly IWebHostEnvironment _hostingEnvironment; private IEnvironment _webAppRuntimeEnvironment; private IDeploymentSettingsManager _noContextDeploymentsSettingsManager; - public Startup(IConfiguration configuration, IHostingEnvironment hostingEnvironment) + public Startup(IConfiguration configuration, IWebHostEnvironment hostingEnvironment) { Console.WriteLine(@"Startup : " + DateTime.Now.ToString("hh.mm.ss.ffffff")); Configuration = configuration; @@ -315,7 +316,7 @@ private static Uri GetAbsoluteUri(HttpContext httpContext) } public void Configure(IApplicationBuilder app, - IApplicationLifetime applicationLifetime, + IHostApplicationLifetime applicationLifetime, ILoggerFactory loggerFactory) { Console.WriteLine(@"Configure : " + DateTime.Now.ToString("hh.mm.ss.ffffff")); From a3c16d18c5d80c9a94d15cb52b67a0c3dd4f03c7 Mon Sep 17 00:00:00 2001 From: Sanchit Mehta Date: Thu, 30 Jul 2020 23:40:19 -0700 Subject: [PATCH 10/18] Fixing KuduBash --- .../Pages/DebugConsole2/LinuxConsole2.cshtml | 2 +- .../DebugConsole2/WindowsConsole2.cshtml | 2 +- Kudu.Services.Web/Pages/_Layout.Legacy.cshtml | 113 ++++++++++++++++++ Kudu.Services.Web/Pages/_Layout.cshtml | 2 +- Kudu.Services.Web/Pages/kududebug.cshtml | 3 + 5 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 Kudu.Services.Web/Pages/_Layout.Legacy.cshtml create mode 100644 Kudu.Services.Web/Pages/kududebug.cshtml diff --git a/Kudu.Services.Web/Pages/DebugConsole2/LinuxConsole2.cshtml b/Kudu.Services.Web/Pages/DebugConsole2/LinuxConsole2.cshtml index 80a340e0..acb84265 100644 --- a/Kudu.Services.Web/Pages/DebugConsole2/LinuxConsole2.cshtml +++ b/Kudu.Services.Web/Pages/DebugConsole2/LinuxConsole2.cshtml @@ -1,6 +1,6 @@ @{ ViewData["Title"] = "Diagnostic Console"; - Layout = "~/Pages/_Layout.cshtml"; + Layout = "~/Pages/_Layout.Legacy.cshtml"; } diff --git a/Kudu.Services.Web/Pages/DebugConsole2/WindowsConsole2.cshtml b/Kudu.Services.Web/Pages/DebugConsole2/WindowsConsole2.cshtml index 098e1c74..8efa71b2 100644 --- a/Kudu.Services.Web/Pages/DebugConsole2/WindowsConsole2.cshtml +++ b/Kudu.Services.Web/Pages/DebugConsole2/WindowsConsole2.cshtml @@ -1,6 +1,6 @@ @{ ViewData["Title"] = "Diagnostic Console"; - Layout = "~/Pages/_Layout.cshtml"; + Layout = "~/Pages/_Layout.Legacy.cshtml"; } diff --git a/Kudu.Services.Web/Pages/_Layout.Legacy.cshtml b/Kudu.Services.Web/Pages/_Layout.Legacy.cshtml new file mode 100644 index 00000000..9e0d42be --- /dev/null +++ b/Kudu.Services.Web/Pages/_Layout.Legacy.cshtml @@ -0,0 +1,113 @@ +@using Microsoft.AspNetCore.Http +@using System +@inject IHttpContextAccessor httpContextAccessor + + + + + + @if (!Kudu.Core.Helpers.OSDetector.IsOnWindows()) + { + + + } + else + { + + + + } + + + + Azure App Service + + + + @RenderSection("PageHead", required: false) + + @* // CORE TODO VirtualPathUtility no longer exists *@ + @**@ + @if (Kudu.Core.Helpers.OSDetector.IsOnWindows()) + { + + } + else + { + + } + + + + + + + @RenderBody() + + \ No newline at end of file diff --git a/Kudu.Services.Web/Pages/_Layout.cshtml b/Kudu.Services.Web/Pages/_Layout.cshtml index e03dc681..01f496b6 100644 --- a/Kudu.Services.Web/Pages/_Layout.cshtml +++ b/Kudu.Services.Web/Pages/_Layout.cshtml @@ -87,7 +87,7 @@ diff --git a/Kudu.Services.Web/Pages/kududebug.cshtml b/Kudu.Services.Web/Pages/kududebug.cshtml new file mode 100644 index 00000000..4ef3c9bf --- /dev/null +++ b/Kudu.Services.Web/Pages/kududebug.cshtml @@ -0,0 +1,3 @@ +@page + + From 73efec2d73a3429808a4034d609b8fe52d086ad2 Mon Sep 17 00:00:00 2001 From: Sanchit Mehta Date: Fri, 31 Jul 2020 00:48:23 -0700 Subject: [PATCH 11/18] Fix ssh --- Kudu.Services.Web/Pages/_Layout.cshtml | 4 ++-- Kudu.Services.Web/Pages/{webssh.cshtml => ssh.cshtml} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename Kudu.Services.Web/Pages/{webssh.cshtml => ssh.cshtml} (100%) diff --git a/Kudu.Services.Web/Pages/_Layout.cshtml b/Kudu.Services.Web/Pages/_Layout.cshtml index 01f496b6..6847a7f7 100644 --- a/Kudu.Services.Web/Pages/_Layout.cshtml +++ b/Kudu.Services.Web/Pages/_Layout.cshtml @@ -82,12 +82,12 @@ diff --git a/Kudu.Services.Web/Pages/webssh.cshtml b/Kudu.Services.Web/Pages/ssh.cshtml similarity index 100% rename from Kudu.Services.Web/Pages/webssh.cshtml rename to Kudu.Services.Web/Pages/ssh.cshtml From 1c0b24815787711b0619c22216ca07a433ec89db Mon Sep 17 00:00:00 2001 From: Sanchit Mehta Date: Fri, 31 Jul 2020 17:28:30 -0700 Subject: [PATCH 12/18] Fix Zip-Deploy, Docker-Logs, Logs-dump apis --- .../Infrastructure/ZipArchiveExtensions.cs | 11 +- Kudu.Services.Web/Pages/Index.cshtml | 4 +- Kudu.Services.Web/Pages/_Layout.cshtml | 10 +- Kudu.Services.Web/Startup.cs | 24 +++- .../Deployment/PushDeploymentController.cs | 115 +++++++++++++----- .../Diagnostics/DiagnosticsController.cs | 32 +++-- .../Infrastructure/VfsControllerBase.cs | 16 +++ Kudu.Services/Zip/ZipController.cs | 17 ++- 8 files changed, 167 insertions(+), 62 deletions(-) diff --git a/Kudu.Core/Infrastructure/ZipArchiveExtensions.cs b/Kudu.Core/Infrastructure/ZipArchiveExtensions.cs index c6981740..0f0b9c06 100644 --- a/Kudu.Core/Infrastructure/ZipArchiveExtensions.cs +++ b/Kudu.Core/Infrastructure/ZipArchiveExtensions.cs @@ -5,6 +5,7 @@ using System.IO; using System.IO.Abstractions; using System.IO.Compression; +using System.Threading.Tasks; using Kudu.Contracts.Tracing; using Kudu.Core.Helpers; using Kudu.Core.Tracing; @@ -45,7 +46,7 @@ private static void InternalAddDirectory(ZipArchive zipArchive, DirectoryInfoBas else { var entry = zipArchive.AddFile((FileInfoBase)info, tracer, directoryNameInArchive); - files?.Add(entry); + files?.Add(entry.Result); } } @@ -61,13 +62,13 @@ private static string ForwardSlashCombine(string part1, string part2) return Path.Combine(part1, part2).Replace('\\', '/'); } - public static ZipArchiveEntry AddFile(this ZipArchive zipArchive, string filePath, ITracer tracer, string directoryNameInArchive = "") + public static async Task AddFile(this ZipArchive zipArchive, string filePath, ITracer tracer, string directoryNameInArchive = "") { var fileInfo = new FileInfoWrapper(new FileInfo(filePath)); - return zipArchive.AddFile(fileInfo, tracer, directoryNameInArchive); + return await zipArchive.AddFile(fileInfo, tracer, directoryNameInArchive); } - public static ZipArchiveEntry AddFile(this ZipArchive zipArchive, FileInfoBase file, ITracer tracer, string directoryNameInArchive) + public static async Task AddFile(this ZipArchive zipArchive, FileInfoBase file, ITracer tracer, string directoryNameInArchive) { Stream fileStream = null; try @@ -90,7 +91,7 @@ public static ZipArchiveEntry AddFile(this ZipArchive zipArchive, FileInfoBase f using (Stream zipStream = entry.Open()) { - fileStream.CopyTo(zipStream); + await fileStream.CopyToAsync(zipStream); } return entry; } diff --git a/Kudu.Services.Web/Pages/Index.cshtml b/Kudu.Services.Web/Pages/Index.cshtml index 6ee48c29..0c0ce67b 100644 --- a/Kudu.Services.Web/Pages/Index.cshtml +++ b/Kudu.Services.Web/Pages/Index.cshtml @@ -47,7 +47,7 @@ @{ var workerIdHash = System.Environment.GetEnvironmentVariable(Constants.AzureWebsiteInstanceId); var workerIdShortHash = workerIdHash?.Substring(0, 12); - const string version = Constants.KuduBuild; + const string version = "Preview"; var showLearningBanner = !deploymentManager.GetResults().Any(); var welcomeBannerDisplayVal = showLearningBanner ? "display:block" : "display:none"; var lastDeployedDisplayVal = !showLearningBanner ? "display:block" : "display:none"; @@ -261,7 +261,7 @@ if (!data["status"]) { return; } - console.log("API call done "+wasDeploying); + console.log(wasDeploying); $("#appsvc-welcome-banner").css("display", "none"); $("#just-deployed-banner").css("display", "none"); $("#diagnose-btn").css("display","none"); diff --git a/Kudu.Services.Web/Pages/_Layout.cshtml b/Kudu.Services.Web/Pages/_Layout.cshtml index 6847a7f7..b46c105c 100644 --- a/Kudu.Services.Web/Pages/_Layout.cshtml +++ b/Kudu.Services.Web/Pages/_Layout.cshtml @@ -4,7 +4,7 @@ - + @if (!Kudu.Core.Helpers.OSDetector.IsOnWindows()) { @@ -14,13 +14,13 @@ { - + } - + @@ -38,7 +38,7 @@ - +
diff --git a/Kudu.Services.Web/Pages/_Layout.cshtml b/Kudu.Services.Web/Pages/_Layout.cshtml index b46c105c..b0e36ccf 100644 --- a/Kudu.Services.Web/Pages/_Layout.cshtml +++ b/Kudu.Services.Web/Pages/_Layout.cshtml @@ -44,80 +44,128 @@
From 041112ec6395fd0cb221f92bdcb3c12993c69b8e Mon Sep 17 00:00:00 2001 From: Sanchit Mehta Date: Sat, 1 Aug 2020 00:46:35 -0700 Subject: [PATCH 14/18] Fix migration from 2.2 Kudu --- Kudu.Services.Web/KuduWebUtil.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kudu.Services.Web/KuduWebUtil.cs b/Kudu.Services.Web/KuduWebUtil.cs index bafbfb11..b6cde118 100644 --- a/Kudu.Services.Web/KuduWebUtil.cs +++ b/Kudu.Services.Web/KuduWebUtil.cs @@ -236,7 +236,7 @@ internal static void MigrateToNetCorePatch(IEnvironment environment) // Dynamic Install should just contain dotnet if (fileText.Contains("benv") && fileText.Contains("dotnet") && isRunningOnAzure) { - FileSystemHelpers.WriteAllText(gitPostReceiveHookFile, fileText.Replace("benv dotnet=2.2", "dotnet")); + FileSystemHelpers.WriteAllText(gitPostReceiveHookFile, fileText.Replace("benv dotnet=2.2", "")); } } From 3d3bc64f5f3eb038792f08ecac9e2d91291f1b15 Mon Sep 17 00:00:00 2001 From: Sanchit Mehta Date: Sat, 1 Aug 2020 02:32:10 -0700 Subject: [PATCH 15/18] Add navigate to inst --- Kudu.Services.Web/Pages/Index.cshtml | 96 ++++++++++--------- .../Content/Scripts/NavigateToInstance.js | 25 ++--- .../wwwroot/Content/Styles/newui.css | 5 + 3 files changed, 68 insertions(+), 58 deletions(-) diff --git a/Kudu.Services.Web/Pages/Index.cshtml b/Kudu.Services.Web/Pages/Index.cshtml index f3c66557..29228f0d 100644 --- a/Kudu.Services.Web/Pages/Index.cshtml +++ b/Kudu.Services.Web/Pages/Index.cshtml @@ -11,7 +11,9 @@ } @if (Kudu.Core.Environment.IsAzureEnvironment()) - { - - } + + +} @if (Kudu.Core.Environment.IsAzureEnvironment()) - { - - } +{ + +} @{ var workerIdHash = System.Environment.GetEnvironmentVariable(Constants.AzureWebsiteInstanceId); @@ -57,14 +60,17 @@
-

KuduLite

@version
+

KuduLite

@version +
Site UpTime: @Tracing.TraceMiddleware.UpTime.ToString(@"dd\.hh\:mm\:ss") | Site Folder: @PathResolver.ResolveRootPath() | Temp Folder: @System.IO.Path.GetTempPath() -
Kudu Attached to Instance:   @workerIdShortHash | - - - +
+ Kudu Attached to Instance:   @workerIdShortHash | + + + +