Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Support ASP.NET 5 beta3
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmelsayed committed Feb 27, 2015
1 parent b89d4db commit 4716485
Show file tree
Hide file tree
Showing 7 changed files with 345 additions and 369 deletions.
3 changes: 2 additions & 1 deletion Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ public static class Constants

public const string HostingStartHtml = "hostingstart.html";

public const string KreDefaultVersion = "1.0.0-beta1";
public const string KreDefaultVersion = "1.0.0-beta3";
public const string KreDefaultClr = "CLR";
public const string KreDefaultNugetApiUrl = "https://www.nuget.org/api/v2";

// These should match the ones that are set by Azure
public const string X64Bit = "AMD64";
public const string X86Bit = "x86";

Expand Down
3 changes: 3 additions & 0 deletions Kudu.Core/Deployment/Generator/AspNet5Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Threading.Tasks;
using Kudu.Contracts.Settings;
using Kudu.Core.Infrastructure;

namespace Kudu.Core.Deployment.Generator
{
Expand All @@ -15,6 +16,8 @@ public AspNet5Builder(IEnvironment environment, IDeploymentSettingsManager setti
: base(environment, settings, propertyProvider, sourcePath)
{
_projectPath = projectPath;
var properties = propertyProvider.GetProperties();
properties.Add(WellKnownEnvironmentVariables.KreVersion, AspNet5Helper.GetAspNet5RuntimeVersion(sourcePath));
}

protected override string ScriptGeneratorCommandArguments
Expand Down
5 changes: 2 additions & 3 deletions Kudu.Core/Deployment/Generator/ExternalCommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public Executable BuildExternalCommandExecutable(string workingDirectory, string
UpdateToDefaultIfNotSet(exe, WellKnownEnvironmentVariables.SelectNodeVersionCommandKey, SelectNodeVersionCommand, logger);
UpdateToDefaultIfNotSet(exe, WellKnownEnvironmentVariables.SelectPythonVersionCommandKey, SelectPythonVersionCommand, logger);
UpdateToDefaultIfNotSet(exe, WellKnownEnvironmentVariables.WebJobsDeployCommandKey, WebJobsDeployCommand, logger);
UpdateToDefaultIfNotSet(exe, WellKnownEnvironmentVariables.KreVersion, Constants.KreDefaultVersion, logger);
UpdateToDefaultIfNotSet(exe, WellKnownEnvironmentVariables.KreClr, Constants.KreDefaultClr, logger);
UpdateToDefaultIfNotSet(exe, WellKnownEnvironmentVariables.KreBitness, KreBitness, logger);
UpdateToDefaultIfNotSet(exe, WellKnownEnvironmentVariables.KreNugetApiUrl, Constants.KreDefaultNugetApiUrl, logger);
Expand Down Expand Up @@ -168,9 +167,9 @@ private static string KreBitness
var bitness = System.Environment.GetEnvironmentVariable(WellKnownEnvironmentVariables.SiteBitness);
if (bitness == null)
{
return System.Environment.Is64BitProcess ? "amd64" : "x86";
return System.Environment.Is64BitProcess ? "x64" : "x86";
}
return bitness.Equals(Constants.X64Bit, StringComparison.OrdinalIgnoreCase) ? "amd64" : "x86";
return bitness.Equals(Constants.X64Bit, StringComparison.OrdinalIgnoreCase) ? "x64" : "x86";
}
}

Expand Down
23 changes: 21 additions & 2 deletions Kudu.Core/Infrastructure/AspNet5Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,29 @@ public static bool IsWebApplicationProjectJsonFile(string projectJsonPath)
}
}

public static bool TryAspNet5Project(string projectDirectory, out string projectJsonPath)
public static string GetAspNet5RuntimeVersion(string rootPath)
{
var runtimeVersion = Constants.KreDefaultVersion;
var globalJson = Path.Combine(rootPath, "global.json");
if (File.Exists(globalJson))
{
using (var reader = new StreamReader(globalJson))
{
var parsedGlobalJson = JObject.Parse(reader.ReadToEnd());
if (parsedGlobalJson["sdk"] != null &&
parsedGlobalJson["sdk"]["version"] != null)
{
runtimeVersion = parsedGlobalJson["sdk"]["version"].ToString();
}
}
}
return runtimeVersion;
}

public static bool TryAspNet5Project(string rootPath, out string projectJsonPath)
{
projectJsonPath = null;
var projectJsonFiles = Directory.GetFiles(projectDirectory, "project.json", SearchOption.AllDirectories);
var projectJsonFiles = Directory.GetFiles(rootPath, "project.json", SearchOption.AllDirectories);
foreach (var filePath in projectJsonFiles.Where(IsWebApplicationProjectJsonFile))
{
projectJsonPath = filePath;
Expand Down
Loading

0 comments on commit 4716485

Please sign in to comment.