Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to ASP NETCore 3.1 #129

Draft
wants to merge 19 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Kudu.Console/Kudu.Console.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TieredCompilation>true</TieredCompilation>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>kudu</AssemblyName>
</PropertyGroup>

<PropertyGroup>
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="XmlSettings" Version="0.1.3" />
</ItemGroup>
Expand All @@ -32,7 +34,4 @@
<PropertyGroup>
<NoWarn>$(NoWarn);NU1701</NoWarn>
</PropertyGroup>
<PropertyGroup>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>
</Project>
7 changes: 2 additions & 5 deletions Kudu.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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'");
}
}
Expand Down Expand Up @@ -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()));
}
Expand Down
2 changes: 1 addition & 1 deletion Kudu.Contracts/IEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand Down
2 changes: 1 addition & 1 deletion Kudu.Contracts/Kudu.Contracts.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TieredCompilation>true</TieredCompilation>
</PropertyGroup>
<PropertyGroup>
Expand Down
11 changes: 6 additions & 5 deletions Kudu.Core/Infrastructure/ZipArchiveExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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<ZipArchiveEntry> 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<ZipArchiveEntry> AddFile(this ZipArchive zipArchive, FileInfoBase file, ITracer tracer, string directoryNameInArchive)
{
Stream fileStream = null;
try
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Kudu.Core/Kudu.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TieredCompilation>true</TieredCompilation>
</PropertyGroup>
<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Kudu.Core/SourceControl/Git/KnownEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "\"";
Expand Down
34 changes: 30 additions & 4 deletions Kudu.Services.Web/Kudu.Services.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TieredCompilation>true</TieredCompilation>
</PropertyGroup>
<!-- Supressing Net Core migration warnings-->
Expand All @@ -24,11 +24,11 @@
<ItemGroup>
<PackageReference Include="AspNetCore.RouteAnalyzer" Version="0.5.3" />
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Proxy" />
<PackageReference Include="Microsoft.Diagnostics.Runtime" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
<PackageReference Include="XmlSettings" Version="0.1.3" />
</ItemGroup>
Expand All @@ -46,6 +46,32 @@
<Folder Include="wwwroot\Content\Styles\" />
<Folder Include="wwwroot\Content\Scripts\" />
</ItemGroup>
<ItemGroup>
<Content Update="Pages\bash.cshtml">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="Pages\OldBash\LinuxBashConsole.cshtml">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="Pages\OldBash\WindowsBashConsole.cshtml">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="Pages\Env.cshtml">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="Pages\Index.cshtml">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="Pages\_Layout.cshtml">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<!-- Run updateNodeModules to install kuduscript -->
<Target Name="PutNodeModulesInBinDir" AfterTargets="Build">
<Exec Command="$(ProjectDir)\updateNodeModules.cmd &quot;$(PublishDir)&quot;" Condition="'$(OS)' == 'Windows_NT' AND '$(Configuration)'=='Release'" />
Expand All @@ -57,8 +83,8 @@
<Message Text="%0a%0aBuilding KuduConsole%0a" Importance="high" />
<Exec Command="dotnet build ../Kudu.Console -o $(MSBuildProjectDirectory)/$(PublishDir)..\KuduConsole" Condition="'$(Configuration)' == 'Debug' AND '$(OS)' == 'Windows_NT'" />
<Exec Command="dotnet build ../Kudu.Console -o $(OutputPath)/KuduConsole" Condition="'$(Configuration)' == 'Debug' AND '$(OS)' != 'Windows_NT'" />
<Exec Command="dotnet publish ..\Kudu.Console --configuration Release -o $(PublishDir)\KuduConsole" Condition="'$(Configuration)' == 'Release' AND '$(OS)' == 'Windows_NT'" />
<Exec Command="dotnet publish ../Kudu.Console --configuration Release -o $(PublishDir)/KuduConsole" Condition="'$(Configuration)' == 'Release' AND '$(OS)' != 'Windows_NT'" />
<Exec Command="dotnet publish ..\Kudu.Console -r linux-x64 --self-contained --configuration Release -p:PublishSingleFile=false -p:PublishTrimmed=true -o $(PublishDir)\KuduConsole" Condition="'$(Configuration)' == 'Release' AND '$(OS)' == 'Windows_NT'" />
<Exec Command="dotnet publish ../Kudu.Console -r linux-x64 --self-contained --configuration Release -p:PublishSingleFile=false -p:PublishTrimmed=true -o $(PublishDir)/KuduConsole" Condition="'$(Configuration)' == 'Release' AND '$(OS)' != 'Windows_NT'" />
</Target>
<Target Name="ChangeScriptPermissionsForLinux" AfterTargets="publish">
<Message Text="%0a%0aSetting Permissions for Kudu Script(s)%0a" Importance="high" />
Expand Down
6 changes: 3 additions & 3 deletions Kudu.Services.Web/KuduWebUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, IOperationLock> _namedLocks;
Expand Down Expand Up @@ -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 dotnet", ""));
}
}

Expand Down Expand Up @@ -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.
/// </summary>
internal static IEnvironment GetEnvironment(IHostingEnvironment hostingEnvironment,
internal static IEnvironment GetEnvironment(IWebHostEnvironment hostingEnvironment,
IFileSystemPathProvider fileSystemPathsProvider,
IDeploymentSettingsManager settings = null,
IHttpContextAccessor httpContextAccessor = null)
Expand Down
2 changes: 1 addition & 1 deletion Kudu.Services.Web/Pages/DebugConsole/LinuxConsole.cshtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
ViewData["Title"] = "Diagnostic Console";
Layout = "~/Pages/_Layout.cshtml";
Layout = "~/Pages/_Layout.Legacy.cshtml";
}

<head>
Expand Down
2 changes: 1 addition & 1 deletion Kudu.Services.Web/Pages/DebugConsole/WindowsConsole.cshtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
ViewData["Title"] = "Diagnostic Console";
Layout = "~/Pages/_Layout.cshtml";
Layout = "~/Pages/_Layout.Legacy.cshtml";
}

<head>
Expand Down
4 changes: 3 additions & 1 deletion Kudu.Services.Web/Pages/Error.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
ViewData["Title"] = "Error";
}

<h1 class="text-danger">Error.</h1>
<h1 class="text-danger">
<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>&nbsp;Error.
</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
Expand Down
Loading