зеркало из https://github.com/microsoft/Oryx.git
Code clean-up (renames, usings, whitespace removal) (#190)
This commit is contained in:
Родитель
24dd087a0a
Коммит
5160c57f40
|
@ -84,7 +84,7 @@ if [[ "$OSTYPE" == "linux-gnu" ]] || [[ "$OSTYPE" == "darwin"* ]]; then
|
|||
source $REPO_DIR/build/build-buildpacks-images.sh
|
||||
else
|
||||
echo
|
||||
echo "Skipping building 'Buildpacks images' as platform '$OSTYPE' is not supported."
|
||||
echo "Skipping building Buildpacks images as platform '$OSTYPE' is not supported."
|
||||
fi
|
||||
|
||||
# Retag build image with DockerHub and ACR tags
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator
|
|||
services
|
||||
.AddNodeScriptGeneratorServices()
|
||||
.AddPythonScriptGeneratorServices()
|
||||
.AddDotnetCoreScriptGeneratorServices()
|
||||
.AddDotNetCoreScriptGeneratorServices()
|
||||
.AddPhpScriptGeneratorServices();
|
||||
|
||||
services.AddSingleton<IBuildScriptGenerator, DefaultBuildScriptGenerator>();
|
||||
|
|
|
@ -15,7 +15,9 @@ namespace Microsoft.Oryx.BuildScriptGenerator
|
|||
/// </summary>
|
||||
/// <param name="ctx">The <see cref="BuildScriptGeneratorContext"/> with parameters for the script.</param>
|
||||
/// <param name="script">The generated script if the operation was successful.</param>
|
||||
/// <param name="checkerMessageSink">If specified, messages from checkers will be appended to this list.</param>
|
||||
/// <param name="checkerMessageSink">
|
||||
/// If specified, messages from checkers will be appended to this list.
|
||||
/// </param>
|
||||
void GenerateBashScript(
|
||||
BuildScriptGeneratorContext ctx,
|
||||
out string script,
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
{
|
||||
internal class DefaultAspNetCoreWebAppProjectFileProvider : IAspNetCoreWebAppProjectFileProvider
|
||||
{
|
||||
private readonly DotnetCoreScriptGeneratorOptions _options;
|
||||
private readonly DotNetCoreScriptGeneratorOptions _options;
|
||||
private readonly ILogger<DefaultAspNetCoreWebAppProjectFileProvider> _logger;
|
||||
|
||||
// Since this service is registered as a singleton, we can cache the lookup of project file.
|
||||
|
@ -26,7 +26,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
private string _projectFileRelativePath;
|
||||
|
||||
public DefaultAspNetCoreWebAppProjectFileProvider(
|
||||
IOptions<DotnetCoreScriptGeneratorOptions> options,
|
||||
IOptions<DotNetCoreScriptGeneratorOptions> options,
|
||||
ILogger<DefaultAspNetCoreWebAppProjectFileProvider> logger)
|
||||
{
|
||||
_options = options.Value;
|
||||
|
@ -63,8 +63,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
}
|
||||
|
||||
// Check if root of the repo has a .csproj or a .fsproj file
|
||||
projectFile = GetProjectFileAtRoot(sourceRepo, DotnetCoreConstants.CSharpProjectFileExtension) ??
|
||||
GetProjectFileAtRoot(sourceRepo, DotnetCoreConstants.FSharpProjectFileExtension);
|
||||
projectFile = GetProjectFileAtRoot(sourceRepo, DotNetCoreConstants.CSharpProjectFileExtension) ??
|
||||
GetProjectFileAtRoot(sourceRepo, DotNetCoreConstants.FSharpProjectFileExtension);
|
||||
|
||||
if (projectFile != null)
|
||||
{
|
||||
|
@ -83,24 +83,24 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
// search for .csproj files
|
||||
var projectFiles = GetAllProjectFilesInRepo(
|
||||
sourceRepo,
|
||||
DotnetCoreConstants.CSharpProjectFileExtension);
|
||||
DotNetCoreConstants.CSharpProjectFileExtension);
|
||||
|
||||
if (!projectFiles.Any())
|
||||
{
|
||||
_logger.LogDebug(
|
||||
"Could not find any files with extension " +
|
||||
$"'{DotnetCoreConstants.CSharpProjectFileExtension}' in repo.");
|
||||
$"'{DotNetCoreConstants.CSharpProjectFileExtension}' in repo.");
|
||||
|
||||
// search for .fsproj files
|
||||
projectFiles = GetAllProjectFilesInRepo(
|
||||
sourceRepo,
|
||||
DotnetCoreConstants.FSharpProjectFileExtension);
|
||||
DotNetCoreConstants.FSharpProjectFileExtension);
|
||||
|
||||
if (!projectFiles.Any())
|
||||
{
|
||||
_logger.LogDebug(
|
||||
"Could not find any files with extension " +
|
||||
$"'{DotnetCoreConstants.FSharpProjectFileExtension}' in repo.");
|
||||
$"'{DotNetCoreConstants.FSharpProjectFileExtension}' in repo.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -149,9 +149,9 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
|
||||
// Look for the attribute value on Project element first as that is more common
|
||||
// Example: <Project Sdk="Microsoft.NET.Sdk.Web/1.0.0">
|
||||
var expectedWebSdkName = DotnetCoreConstants.WebSdkName.ToLowerInvariant();
|
||||
var expectedWebSdkName = DotNetCoreConstants.WebSdkName.ToLowerInvariant();
|
||||
var sdkAttributeValue = projectFileDoc.XPathEvaluate(
|
||||
DotnetCoreConstants.ProjectSdkAttributeValueXPathExpression);
|
||||
DotNetCoreConstants.ProjectSdkAttributeValueXPathExpression);
|
||||
var sdkName = sdkAttributeValue as string;
|
||||
if (!string.IsNullOrEmpty(sdkName) &&
|
||||
sdkName.StartsWith(expectedWebSdkName, StringComparison.OrdinalIgnoreCase))
|
||||
|
@ -163,7 +163,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
// <Project>
|
||||
// <Sdk Name="Microsoft.NET.Sdk.Web" Version="1.0.0" />
|
||||
var sdkNameAttributeValue = projectFileDoc.XPathEvaluate(
|
||||
DotnetCoreConstants.ProjectSdkElementNameAttributeValueXPathExpression);
|
||||
DotNetCoreConstants.ProjectSdkElementNameAttributeValueXPathExpression);
|
||||
sdkName = sdkNameAttributeValue as string;
|
||||
|
||||
return string.Equals(sdkName, expectedWebSdkName, StringComparison.OrdinalIgnoreCase);
|
||||
|
@ -205,11 +205,11 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
private static bool IsAspNetCore30App(XDocument projectFileDoc)
|
||||
{
|
||||
var targetFrameworkElement = projectFileDoc.XPathSelectElement(
|
||||
DotnetCoreConstants.TargetFrameworkElementXPathExpression);
|
||||
if (string.Equals(targetFrameworkElement.Value, DotnetCoreConstants.NetCoreApp30))
|
||||
DotNetCoreConstants.TargetFrameworkElementXPathExpression);
|
||||
if (string.Equals(targetFrameworkElement.Value, DotNetCoreConstants.NetCoreApp30))
|
||||
{
|
||||
var projectElement = projectFileDoc.XPathSelectElement(
|
||||
DotnetCoreConstants.ProjectSdkAttributeValueXPathExpression);
|
||||
DotNetCoreConstants.ProjectSdkAttributeValueXPathExpression);
|
||||
return projectElement != null;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ using System.Collections.Generic;
|
|||
namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
||||
{
|
||||
/// <summary>
|
||||
/// Build script template for DotnetCore in Bash.
|
||||
/// Build script template for DotNetCore in Bash.
|
||||
/// </summary>
|
||||
public class DotNetCoreBashBuildSnippetProperties
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
||||
{
|
||||
public static class DotnetCoreConstants
|
||||
public static class DotNetCoreConstants
|
||||
{
|
||||
public const string LanguageName = "dotnet";
|
||||
public const string CSharpProjectFileExtension = "csproj";
|
||||
|
|
|
@ -14,18 +14,18 @@ using Newtonsoft.Json;
|
|||
|
||||
namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
||||
{
|
||||
internal class DotnetCoreLanguageDetector : ILanguageDetector
|
||||
internal class DotNetCoreLanguageDetector : ILanguageDetector
|
||||
{
|
||||
private readonly IDotnetCoreVersionProvider _versionProvider;
|
||||
private readonly DotnetCoreScriptGeneratorOptions _scriptGeneratorOptions;
|
||||
private readonly IDotNetCoreVersionProvider _versionProvider;
|
||||
private readonly DotNetCoreScriptGeneratorOptions _scriptGeneratorOptions;
|
||||
private readonly IAspNetCoreWebAppProjectFileProvider _aspNetCoreWebAppProjectFileProvider;
|
||||
private readonly ILogger<DotnetCoreLanguageDetector> _logger;
|
||||
private readonly ILogger<DotNetCoreLanguageDetector> _logger;
|
||||
|
||||
public DotnetCoreLanguageDetector(
|
||||
IDotnetCoreVersionProvider versionProvider,
|
||||
IOptions<DotnetCoreScriptGeneratorOptions> options,
|
||||
public DotNetCoreLanguageDetector(
|
||||
IDotNetCoreVersionProvider versionProvider,
|
||||
IOptions<DotNetCoreScriptGeneratorOptions> options,
|
||||
IAspNetCoreWebAppProjectFileProvider aspNetCoreWebAppProjectFileProvider,
|
||||
ILogger<DotnetCoreLanguageDetector> logger)
|
||||
ILogger<DotNetCoreLanguageDetector> logger)
|
||||
{
|
||||
_versionProvider = versionProvider;
|
||||
_scriptGeneratorOptions = options.Value;
|
||||
|
@ -43,7 +43,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
|
||||
var projectFileDoc = XDocument.Load(new StringReader(sourceRepo.ReadFile(projectFile)));
|
||||
var targetFrameworkElement = projectFileDoc.XPathSelectElement(
|
||||
DotnetCoreConstants.TargetFrameworkElementXPathExpression);
|
||||
DotNetCoreConstants.TargetFrameworkElementXPathExpression);
|
||||
var targetFramework = targetFrameworkElement?.Value;
|
||||
if (string.IsNullOrEmpty(targetFramework))
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
|
||||
// If a repo explicitly specifies an sdk version, then just use it as it is.
|
||||
string languageVersion = null;
|
||||
if (sourceRepo.FileExists(DotnetCoreConstants.GlobalJsonFileName))
|
||||
if (sourceRepo.FileExists(DotNetCoreConstants.GlobalJsonFileName))
|
||||
{
|
||||
var globalJson = GetGlobalJsonObject(sourceRepo);
|
||||
var sdkVersion = globalJson?.sdk?.version?.Value as string;
|
||||
|
@ -72,7 +72,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
if (languageVersion == null)
|
||||
{
|
||||
_logger.LogDebug(
|
||||
$"Could not find a {DotnetCoreConstants.LanguageName} version corresponding to 'TargetFramework'" +
|
||||
$"Could not find a {DotNetCoreConstants.LanguageName} version corresponding to 'TargetFramework'" +
|
||||
$" '{targetFramework}'.");
|
||||
return null;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
|
||||
return new LanguageDetectorResult
|
||||
{
|
||||
Language = DotnetCoreConstants.LanguageName,
|
||||
Language = DotNetCoreConstants.LanguageName,
|
||||
LanguageVersion = languageVersion
|
||||
};
|
||||
}
|
||||
|
@ -90,22 +90,22 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
{
|
||||
switch (targetFramework)
|
||||
{
|
||||
case DotnetCoreConstants.NetCoreApp10:
|
||||
case DotNetCoreConstants.NetCoreApp10:
|
||||
return DotNetCoreRuntimeVersions.NetCoreApp10;
|
||||
|
||||
case DotnetCoreConstants.NetCoreApp11:
|
||||
case DotNetCoreConstants.NetCoreApp11:
|
||||
return DotNetCoreRuntimeVersions.NetCoreApp11;
|
||||
|
||||
case DotnetCoreConstants.NetCoreApp20:
|
||||
case DotNetCoreConstants.NetCoreApp20:
|
||||
return DotNetCoreRuntimeVersions.NetCoreApp20;
|
||||
|
||||
case DotnetCoreConstants.NetCoreApp21:
|
||||
case DotNetCoreConstants.NetCoreApp21:
|
||||
return DotNetCoreRuntimeVersions.NetCoreApp21;
|
||||
|
||||
case DotnetCoreConstants.NetCoreApp22:
|
||||
case DotNetCoreConstants.NetCoreApp22:
|
||||
return DotNetCoreRuntimeVersions.NetCoreApp22;
|
||||
|
||||
case DotnetCoreConstants.NetCoreApp30:
|
||||
case DotNetCoreConstants.NetCoreApp30:
|
||||
return DotNetCoreRuntimeVersions.NetCoreApp30;
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
dynamic globalJson = null;
|
||||
try
|
||||
{
|
||||
var jsonContent = sourceRepo.ReadFile(DotnetCoreConstants.GlobalJsonFileName);
|
||||
var jsonContent = sourceRepo.ReadFile(DotNetCoreConstants.GlobalJsonFileName);
|
||||
globalJson = JsonConvert.DeserializeObject(jsonContent);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -153,7 +153,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
// in the package.json file.
|
||||
_logger.LogError(
|
||||
ex,
|
||||
$"An error occurred while trying to deserialize {DotnetCoreConstants.GlobalJsonFileName}");
|
||||
$"An error occurred while trying to deserialize {DotNetCoreConstants.GlobalJsonFileName}");
|
||||
}
|
||||
|
||||
return globalJson;
|
||||
|
|
|
@ -16,22 +16,22 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
/// .NET Core platform.
|
||||
/// </summary>
|
||||
[BuildProperty(Constants.ZipAllOutputBuildPropertyKey, Constants.ZipAllOutputBuildPropertyKeyDocumentation)]
|
||||
internal class DotnetCorePlatform : IProgrammingPlatform
|
||||
internal class DotNetCorePlatform : IProgrammingPlatform
|
||||
{
|
||||
private readonly IDotnetCoreVersionProvider _versionProvider;
|
||||
private readonly IDotNetCoreVersionProvider _versionProvider;
|
||||
private readonly IAspNetCoreWebAppProjectFileProvider _aspNetCoreWebAppProjectFileProvider;
|
||||
private readonly IEnvironmentSettingsProvider _environmentSettingsProvider;
|
||||
private readonly ILogger<DotnetCorePlatform> _logger;
|
||||
private readonly DotnetCoreLanguageDetector _detector;
|
||||
private readonly DotnetCoreScriptGeneratorOptions _options;
|
||||
private readonly ILogger<DotNetCorePlatform> _logger;
|
||||
private readonly DotNetCoreLanguageDetector _detector;
|
||||
private readonly DotNetCoreScriptGeneratorOptions _options;
|
||||
|
||||
public DotnetCorePlatform(
|
||||
IDotnetCoreVersionProvider versionProvider,
|
||||
public DotNetCorePlatform(
|
||||
IDotNetCoreVersionProvider versionProvider,
|
||||
IAspNetCoreWebAppProjectFileProvider aspNetCoreWebAppProjectFileProvider,
|
||||
IEnvironmentSettingsProvider environmentSettingsProvider,
|
||||
ILogger<DotnetCorePlatform> logger,
|
||||
DotnetCoreLanguageDetector detector,
|
||||
IOptions<DotnetCoreScriptGeneratorOptions> options)
|
||||
ILogger<DotNetCorePlatform> logger,
|
||||
DotNetCoreLanguageDetector detector,
|
||||
IOptions<DotNetCoreScriptGeneratorOptions> options)
|
||||
{
|
||||
_versionProvider = versionProvider;
|
||||
_aspNetCoreWebAppProjectFileProvider = aspNetCoreWebAppProjectFileProvider;
|
||||
|
@ -41,7 +41,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
_options = options.Value;
|
||||
}
|
||||
|
||||
public string Name => DotnetCoreConstants.LanguageName;
|
||||
public string Name => DotNetCoreConstants.LanguageName;
|
||||
|
||||
public IEnumerable<string> SupportedLanguageVersions => _versionProvider.SupportedDotNetCoreVersions;
|
||||
|
||||
|
@ -147,7 +147,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
dirs.Add(".git");
|
||||
dirs.Add("obj");
|
||||
dirs.Add("bin");
|
||||
dirs.Add(DotnetCoreConstants.OryxOutputPublishDirectory);
|
||||
dirs.Add(DotNetCoreConstants.OryxOutputPublishDirectory);
|
||||
return dirs;
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
var configuration = _options.MSBuildConfiguration;
|
||||
if (string.IsNullOrEmpty(configuration))
|
||||
{
|
||||
configuration = DotnetCoreConstants.DefaultMSBuildConfiguration;
|
||||
configuration = DotNetCoreConstants.DefaultMSBuildConfiguration;
|
||||
}
|
||||
|
||||
return configuration;
|
||||
|
@ -178,7 +178,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
return (null, null);
|
||||
}
|
||||
|
||||
var publishDir = Path.Combine(repo.RootPath, DotnetCoreConstants.OryxOutputPublishDirectory);
|
||||
var publishDir = Path.Combine(repo.RootPath, DotNetCoreConstants.OryxOutputPublishDirectory);
|
||||
return (projectFile, publishDir);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
||||
{
|
||||
public class DotnetCoreScriptGeneratorOptions
|
||||
public class DotNetCoreScriptGeneratorOptions
|
||||
{
|
||||
public string DefaultVersion { get; set; }
|
||||
|
||||
|
|
|
@ -7,21 +7,21 @@ using Microsoft.Extensions.Options;
|
|||
|
||||
namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
||||
{
|
||||
internal class DotnetCoreScriptGeneratorOptionsSetup : IConfigureOptions<DotnetCoreScriptGeneratorOptions>
|
||||
internal class DotNetCoreScriptGeneratorOptionsSetup : IConfigureOptions<DotNetCoreScriptGeneratorOptions>
|
||||
{
|
||||
internal const string DefaultVersion = DotNetCoreRuntimeVersions.NetCoreApp21;
|
||||
internal const string InstalledVersionsDir = "/opt/dotnet/runtimes";
|
||||
|
||||
private readonly IEnvironment _environment;
|
||||
|
||||
public DotnetCoreScriptGeneratorOptionsSetup(IEnvironment environment)
|
||||
public DotNetCoreScriptGeneratorOptionsSetup(IEnvironment environment)
|
||||
{
|
||||
_environment = environment;
|
||||
}
|
||||
|
||||
public void Configure(DotnetCoreScriptGeneratorOptions options)
|
||||
public void Configure(DotNetCoreScriptGeneratorOptions options)
|
||||
{
|
||||
var defaultVersion = _environment.GetEnvironmentVariable(EnvironmentSettingsKeys.DotnetCoreDefaultVersion);
|
||||
var defaultVersion = _environment.GetEnvironmentVariable(EnvironmentSettingsKeys.DotNetCoreDefaultVersion);
|
||||
if (string.IsNullOrEmpty(defaultVersion))
|
||||
{
|
||||
defaultVersion = DefaultVersion;
|
||||
|
@ -30,7 +30,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
options.DefaultVersion = defaultVersion;
|
||||
options.InstalledVersionsDir = InstalledVersionsDir;
|
||||
options.SupportedVersions = _environment.GetEnvironmentVariableAsList(
|
||||
EnvironmentSettingsKeys.DotnetCoreSupportedVersions);
|
||||
EnvironmentSettingsKeys.DotNetCoreSupportedVersions);
|
||||
options.Project = _environment.GetEnvironmentVariable(EnvironmentSettingsKeys.Project);
|
||||
options.MSBuildConfiguration = _environment.GetEnvironmentVariable(
|
||||
EnvironmentSettingsKeys.MSBuildConfiguration);
|
||||
|
|
|
@ -10,18 +10,18 @@ using Microsoft.Oryx.BuildScriptGenerator.DotNetCore;
|
|||
|
||||
namespace Microsoft.Oryx.BuildScriptGenerator
|
||||
{
|
||||
internal static class DotnetCoreScriptGeneratorServiceCollectionExtensions
|
||||
internal static class DotNetCoreScriptGeneratorServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddDotnetCoreScriptGeneratorServices(this IServiceCollection services)
|
||||
public static IServiceCollection AddDotNetCoreScriptGeneratorServices(this IServiceCollection services)
|
||||
{
|
||||
services.TryAddEnumerable(
|
||||
ServiceDescriptor.Singleton<ILanguageDetector, DotnetCoreLanguageDetector>());
|
||||
ServiceDescriptor.Singleton<ILanguageDetector, DotNetCoreLanguageDetector>());
|
||||
services.TryAddEnumerable(
|
||||
ServiceDescriptor.Singleton<IProgrammingPlatform, DotnetCorePlatform>());
|
||||
ServiceDescriptor.Singleton<IProgrammingPlatform, DotNetCorePlatform>());
|
||||
services.TryAddEnumerable(
|
||||
ServiceDescriptor.Singleton<IConfigureOptions<DotnetCoreScriptGeneratorOptions>, DotnetCoreScriptGeneratorOptionsSetup>());
|
||||
services.AddSingleton<IDotnetCoreVersionProvider, DotnetCoreVersionProvider>();
|
||||
services.AddScoped<DotnetCoreLanguageDetector>();
|
||||
ServiceDescriptor.Singleton<IConfigureOptions<DotNetCoreScriptGeneratorOptions>, DotNetCoreScriptGeneratorOptionsSetup>());
|
||||
services.AddSingleton<IDotNetCoreVersionProvider, DotNetCoreVersionProvider>();
|
||||
services.AddScoped<DotNetCoreLanguageDetector>();
|
||||
services.AddSingleton<IAspNetCoreWebAppProjectFileProvider, DefaultAspNetCoreWebAppProjectFileProvider>();
|
||||
return services;
|
||||
}
|
||||
|
|
|
@ -8,12 +8,12 @@ using Microsoft.Extensions.Options;
|
|||
|
||||
namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
||||
{
|
||||
internal class DotnetCoreVersionProvider : IDotnetCoreVersionProvider
|
||||
internal class DotNetCoreVersionProvider : IDotNetCoreVersionProvider
|
||||
{
|
||||
private readonly DotnetCoreScriptGeneratorOptions _options;
|
||||
private readonly DotNetCoreScriptGeneratorOptions _options;
|
||||
private IEnumerable<string> _supportedVersions;
|
||||
|
||||
public DotnetCoreVersionProvider(IOptions<DotnetCoreScriptGeneratorOptions> options)
|
||||
public DotNetCoreVersionProvider(IOptions<DotNetCoreScriptGeneratorOptions> options)
|
||||
{
|
||||
_options = options.Value;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
|
|||
/// <summary>
|
||||
/// Abstraction listing the supported .NET Core versions.
|
||||
/// </summary>
|
||||
public interface IDotnetCoreVersionProvider
|
||||
public interface IDotNetCoreVersionProvider
|
||||
{
|
||||
IEnumerable<string> SupportedDotNetCoreVersions { get; }
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ namespace Microsoft.Oryx.BuildScriptGenerator
|
|||
/// </summary>
|
||||
public const string PostBuildCommand = "POST_BUILD_COMMAND";
|
||||
|
||||
public const string DotnetCoreDefaultVersion = "ORYX_DOTNETCORE_DEFAULT_VERSION";
|
||||
public const string DotNetCoreDefaultVersion = "ORYX_DOTNETCORE_DEFAULT_VERSION";
|
||||
|
||||
public const string DotnetCoreSupportedVersions = "DOTNETCORE_SUPPORTED_VERSIONS";
|
||||
public const string DotNetCoreSupportedVersions = "DOTNETCORE_SUPPORTED_VERSIONS";
|
||||
|
||||
public const string Project = "PROJECT";
|
||||
|
||||
|
|
|
@ -34,8 +34,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Python
|
|||
internal const string CompressVirtualEnvPropertyKey = "compress_virtualenv";
|
||||
internal const string ZipOption = "zip";
|
||||
internal const string TarGzOption = "tar-gz";
|
||||
|
||||
private readonly PythonScriptGeneratorOptions _pythonScriptGeneratorOptions;
|
||||
|
||||
private readonly IPythonVersionProvider _pythonVersionProvider;
|
||||
private readonly IEnvironment _environment;
|
||||
private readonly ILogger<PythonPlatform> _logger;
|
||||
|
@ -48,7 +47,6 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Python
|
|||
ILogger<PythonPlatform> logger,
|
||||
PythonLanguageDetector detector)
|
||||
{
|
||||
_pythonScriptGeneratorOptions = pythonScriptGeneratorOptions.Value;
|
||||
_pythonVersionProvider = pythonVersionProvider;
|
||||
_environment = environment;
|
||||
_logger = logger;
|
||||
|
@ -145,70 +143,6 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Python
|
|||
};
|
||||
}
|
||||
|
||||
private static string GetDefaultVirtualEnvName(BuildScriptGeneratorContext context)
|
||||
{
|
||||
string pythonVersion = context.PythonVersion;
|
||||
if (!string.IsNullOrWhiteSpace(pythonVersion))
|
||||
{
|
||||
var versionSplit = pythonVersion.Split('.');
|
||||
if (versionSplit.Length > 1)
|
||||
{
|
||||
pythonVersion = $"{versionSplit[0]}.{versionSplit[1]}";
|
||||
}
|
||||
}
|
||||
|
||||
return $"pythonenv{pythonVersion}";
|
||||
}
|
||||
|
||||
private static string GetPackageDirectory(BuildScriptGeneratorContext context)
|
||||
{
|
||||
string packageDir = null;
|
||||
if (context.Properties != null)
|
||||
{
|
||||
context.Properties.TryGetValue(TargetPackageDirectoryPropertyKey, out packageDir);
|
||||
}
|
||||
|
||||
return packageDir;
|
||||
}
|
||||
|
||||
private bool IsCollectStaticEnabled()
|
||||
{
|
||||
// Collect static is enabled by default, but users can opt-out of it
|
||||
var enableCollectStatic = true;
|
||||
var disableCollectStaticEnvValue = _environment.GetEnvironmentVariable(
|
||||
EnvironmentSettingsKeys.DisableCollectStatic);
|
||||
if (string.Equals(disableCollectStaticEnvValue, "true", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
enableCollectStatic = false;
|
||||
}
|
||||
|
||||
return enableCollectStatic;
|
||||
}
|
||||
|
||||
private (string virtualEnvModule, string virtualEnvCopyParam) GetVirtualEnvModules(string pythonVersion)
|
||||
{
|
||||
string virtualEnvModule;
|
||||
string virtualEnvCopyParam = string.Empty;
|
||||
switch (pythonVersion.Split('.')[0])
|
||||
{
|
||||
case "2":
|
||||
virtualEnvModule = "virtualenv";
|
||||
break;
|
||||
|
||||
case "3":
|
||||
virtualEnvModule = "venv";
|
||||
virtualEnvCopyParam = "--copies";
|
||||
break;
|
||||
|
||||
default:
|
||||
string errorMessage = "Python version '" + pythonVersion + "' is not supported";
|
||||
_logger.LogError(errorMessage);
|
||||
throw new NotSupportedException(errorMessage);
|
||||
}
|
||||
|
||||
return (virtualEnvModule, virtualEnvCopyParam);
|
||||
}
|
||||
|
||||
public bool IsCleanRepo(ISourceRepo repo)
|
||||
{
|
||||
// TODO: support venvs
|
||||
|
@ -255,7 +189,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Python
|
|||
if (GetVirtualEnvPackOptions(
|
||||
context,
|
||||
virtualEnvName,
|
||||
out string compressCommand,
|
||||
out _,
|
||||
out string compressedFileName))
|
||||
{
|
||||
dirs.Add(virtualEnvName);
|
||||
|
@ -286,6 +220,32 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Python
|
|||
return excludeDirs;
|
||||
}
|
||||
|
||||
private static string GetDefaultVirtualEnvName(BuildScriptGeneratorContext context)
|
||||
{
|
||||
string pythonVersion = context.PythonVersion;
|
||||
if (!string.IsNullOrWhiteSpace(pythonVersion))
|
||||
{
|
||||
var versionSplit = pythonVersion.Split('.');
|
||||
if (versionSplit.Length > 1)
|
||||
{
|
||||
pythonVersion = $"{versionSplit[0]}.{versionSplit[1]}";
|
||||
}
|
||||
}
|
||||
|
||||
return $"pythonenv{pythonVersion}";
|
||||
}
|
||||
|
||||
private static string GetPackageDirectory(BuildScriptGeneratorContext context)
|
||||
{
|
||||
string packageDir = null;
|
||||
if (context.Properties != null)
|
||||
{
|
||||
context.Properties.TryGetValue(TargetPackageDirectoryPropertyKey, out packageDir);
|
||||
}
|
||||
|
||||
return packageDir;
|
||||
}
|
||||
|
||||
private static bool GetVirtualEnvPackOptions(
|
||||
BuildScriptGeneratorContext context,
|
||||
string virtualEnvName,
|
||||
|
@ -323,6 +283,44 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Python
|
|||
return isVirtualEnvPackaged;
|
||||
}
|
||||
|
||||
private bool IsCollectStaticEnabled()
|
||||
{
|
||||
// Collect static is enabled by default, but users can opt-out of it
|
||||
var enableCollectStatic = true;
|
||||
var disableCollectStaticEnvValue = _environment.GetEnvironmentVariable(
|
||||
EnvironmentSettingsKeys.DisableCollectStatic);
|
||||
if (string.Equals(disableCollectStaticEnvValue, "true", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
enableCollectStatic = false;
|
||||
}
|
||||
|
||||
return enableCollectStatic;
|
||||
}
|
||||
|
||||
private (string virtualEnvModule, string virtualEnvCopyParam) GetVirtualEnvModules(string pythonVersion)
|
||||
{
|
||||
string virtualEnvModule;
|
||||
string virtualEnvCopyParam = string.Empty;
|
||||
switch (pythonVersion.Split('.')[0])
|
||||
{
|
||||
case "2":
|
||||
virtualEnvModule = "virtualenv";
|
||||
break;
|
||||
|
||||
case "3":
|
||||
virtualEnvModule = "venv";
|
||||
virtualEnvCopyParam = "--copies";
|
||||
break;
|
||||
|
||||
default:
|
||||
string errorMessage = "Python version '" + pythonVersion + "' is not supported";
|
||||
_logger.LogError(errorMessage);
|
||||
throw new NotSupportedException(errorMessage);
|
||||
}
|
||||
|
||||
return (virtualEnvModule, virtualEnvCopyParam);
|
||||
}
|
||||
|
||||
private void TryLogDependencies(string pythonVersion, ISourceRepo repo)
|
||||
{
|
||||
if (!repo.FileExists(PythonConstants.RequirementsFileName))
|
||||
|
|
|
@ -187,7 +187,7 @@ func getVirtualEnvironmentCommand() string {
|
|||
func (gen *PythonStartupScriptGenerator) getDjangoStartupModule(buildManifest common.BuildManifest) string {
|
||||
logger := common.GetLogger("python.scriptgenerator.getDjangoStartupModule")
|
||||
defer logger.Shutdown()
|
||||
|
||||
|
||||
appRootFiles, err := ioutil.ReadDir(gen.SourcePath)
|
||||
if err != nil {
|
||||
logReadDirError(logger, gen.SourcePath, err)
|
||||
|
|
|
@ -157,9 +157,10 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(DotnetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotnetCoreConstants.FSharpProjectFileExtension)]
|
||||
public void GetRelativePathToProjectFile_ReturnsProjectFile_PresentAtRoot_IfPresent(string projectFileExtension)
|
||||
[InlineData(DotNetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotNetCoreConstants.FSharpProjectFileExtension)]
|
||||
public void GetRelativePathToProjectFile_ReturnsProjectFile_PresentAtRoot_IfPresent(
|
||||
string projectFileExtension)
|
||||
{
|
||||
// Arrange
|
||||
var sourceRepoDir = CreateSourceRepoDir();
|
||||
|
@ -282,9 +283,10 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(DotnetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotnetCoreConstants.FSharpProjectFileExtension)]
|
||||
public void GetRelativePathToProjectFile_ReturnsNull_IfRootProject_IsNotWebSdkProject(string projectFileExtension)
|
||||
[InlineData(DotNetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotNetCoreConstants.FSharpProjectFileExtension)]
|
||||
public void GetRelativePathToProjectFile_ReturnsNull_IfRootProject_IsNotWebSdkProject(
|
||||
string projectFileExtension)
|
||||
{
|
||||
// Arrange
|
||||
var sourceRepoDir = CreateSourceRepoDir();
|
||||
|
@ -303,9 +305,9 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
// This is a scenario where our probing of a project could be incorrect. In this case a user can explicitly
|
||||
// specify the project file to use and we use it without checking further.
|
||||
[Theory]
|
||||
[InlineData(DotnetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotnetCoreConstants.FSharpProjectFileExtension)]
|
||||
public void GetRelativePathToProjectFile_ReturnsFile_IfProjectEnvVariableIsSet_AndProjectFileIsNotAspNetCoreApp(
|
||||
[InlineData(DotNetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotNetCoreConstants.FSharpProjectFileExtension)]
|
||||
public void GetRelativePathToProjectFile_ReturnsFile_IfProjEnvVariableIsSet_AndProjectFileIsNotAspNetCoreApp(
|
||||
string projectFileExtension)
|
||||
{
|
||||
// Arrange
|
||||
|
@ -316,7 +318,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
File.WriteAllText(projectFile, NonWebSdkProjectFile);
|
||||
var sourceRepo = CreateSourceRepo(sourceRepoDir);
|
||||
var relativeProjectPath = Path.Combine("src", "WebApp1", $"WebApp1.{projectFileExtension}");
|
||||
var options = new DotnetCoreScriptGeneratorOptions();
|
||||
var options = new DotNetCoreScriptGeneratorOptions();
|
||||
options.Project = relativeProjectPath;
|
||||
var provider = CreateProjectFileProvider(options);
|
||||
|
||||
|
@ -339,7 +341,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
File.WriteAllText(Path.Combine(webApp2Dir, "WebApp2.csproj"), WebSdkProjectFile);
|
||||
var sourceRepo = CreateSourceRepo(sourceRepoDir);
|
||||
var relativeProjectPath = Path.Combine("src", "WebApp2", "WebApp2-doesnotexist.csproj");
|
||||
var options = new DotnetCoreScriptGeneratorOptions();
|
||||
var options = new DotNetCoreScriptGeneratorOptions();
|
||||
options.Project = relativeProjectPath;
|
||||
var provider = CreateProjectFileProvider(options);
|
||||
|
||||
|
@ -350,8 +352,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(DotnetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotnetCoreConstants.FSharpProjectFileExtension)]
|
||||
[InlineData(DotNetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotNetCoreConstants.FSharpProjectFileExtension)]
|
||||
public void GetRelativePathToProjectFile_ReturnsNull_IfNoWebSdkProjectFound_AllAcrossRepo(
|
||||
string projectFileExtension)
|
||||
{
|
||||
|
@ -373,8 +375,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(DotnetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotnetCoreConstants.FSharpProjectFileExtension)]
|
||||
[InlineData(DotNetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotNetCoreConstants.FSharpProjectFileExtension)]
|
||||
public void GetRelativePathToProjectFile_Throws_IfSourceRepo_HasMultipleWebSdkProjects(
|
||||
string projectFileExtension)
|
||||
{
|
||||
|
@ -397,8 +399,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(DotnetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotnetCoreConstants.FSharpProjectFileExtension)]
|
||||
[InlineData(DotNetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotNetCoreConstants.FSharpProjectFileExtension)]
|
||||
public void GetRelativePathToProjectFile_Throws_IfSourceRepo_HasMultipleWebAppProjects_AtDifferentDirLevels(
|
||||
string projectFileExtension)
|
||||
{
|
||||
|
@ -422,8 +424,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(DotnetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotnetCoreConstants.FSharpProjectFileExtension)]
|
||||
[InlineData(DotNetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotNetCoreConstants.FSharpProjectFileExtension)]
|
||||
public void GetRelativePathToProjectFile_DoesNotThrow_IfRepoHasMultipleWebApps_AndProjectEnvVariableIsSet(
|
||||
string projectFileExtension)
|
||||
{
|
||||
|
@ -437,7 +439,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
File.WriteAllText(projectFile, webApp1Dir);
|
||||
var sourceRepo = CreateSourceRepo(sourceRepoDir);
|
||||
var relativeProjectPath = Path.Combine("src", "WebApp2", $"WebApp2.{projectFileExtension}");
|
||||
var options = new DotnetCoreScriptGeneratorOptions();
|
||||
var options = new DotNetCoreScriptGeneratorOptions();
|
||||
options.Project = relativeProjectPath;
|
||||
var provider = CreateProjectFileProvider(options);
|
||||
|
||||
|
@ -449,8 +451,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(DotnetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotnetCoreConstants.FSharpProjectFileExtension)]
|
||||
[InlineData(DotNetCoreConstants.CSharpProjectFileExtension)]
|
||||
[InlineData(DotNetCoreConstants.FSharpProjectFileExtension)]
|
||||
public void GetRelativePathToProjectFile_ReturnsProjectFile_ByProbingAllAcrossRepo(string projectFileExtension)
|
||||
{
|
||||
// Arrange
|
||||
|
@ -518,11 +520,11 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
|
||||
private DefaultAspNetCoreWebAppProjectFileProvider CreateProjectFileProvider()
|
||||
{
|
||||
return CreateProjectFileProvider(new DotnetCoreScriptGeneratorOptions());
|
||||
return CreateProjectFileProvider(new DotNetCoreScriptGeneratorOptions());
|
||||
}
|
||||
|
||||
private DefaultAspNetCoreWebAppProjectFileProvider CreateProjectFileProvider(
|
||||
DotnetCoreScriptGeneratorOptions options)
|
||||
DotNetCoreScriptGeneratorOptions options)
|
||||
{
|
||||
return new DefaultAspNetCoreWebAppProjectFileProvider(
|
||||
Options.Create(options),
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Oryx.BuildScriptGenerator.DotNetCore;
|
||||
using Moq;
|
||||
using Microsoft.Oryx.Tests.Common;
|
||||
using Xunit;
|
||||
using Microsoft.Oryx.BuildScriptGenerator.Exceptions;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Oryx.Tests.Common;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
||||
{
|
||||
|
@ -57,7 +56,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
{
|
||||
// Arrange
|
||||
var sourceRepo = new Mock<ISourceRepo>();
|
||||
var detector = CreateDotnetCoreLanguageDetector(
|
||||
var detector = CreateDotNetCoreLanguageDetector(
|
||||
supportedVersions: GetAllSupportedRuntimeVersions(),
|
||||
projectFile: null);
|
||||
|
||||
|
@ -80,7 +79,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
sourceRepo
|
||||
.Setup(repo => repo.ReadFile(It.IsAny<string>()))
|
||||
.Returns(ProjectFileWithNoTargetFramework);
|
||||
var detector = CreateDotnetCoreLanguageDetector(
|
||||
var detector = CreateDotNetCoreLanguageDetector(
|
||||
supportedVersions: GetAllSupportedRuntimeVersions(),
|
||||
projectFile);
|
||||
|
||||
|
@ -114,7 +113,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
sourceRepo
|
||||
.Setup(repo => repo.ReadFile(It.IsAny<string>()))
|
||||
.Returns(projectFileContent);
|
||||
var detector = CreateDotnetCoreLanguageDetector(
|
||||
var detector = CreateDotNetCoreLanguageDetector(
|
||||
supportedVersions: GetAllSupportedRuntimeVersions(),
|
||||
projectFile);
|
||||
|
||||
|
@ -123,7 +122,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(DotnetCoreConstants.LanguageName, result.Language);
|
||||
Assert.Equal(DotNetCoreConstants.LanguageName, result.Language);
|
||||
Assert.Equal(expectedSdkVersion, result.LanguageVersion);
|
||||
}
|
||||
|
||||
|
@ -139,7 +138,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
sourceRepo
|
||||
.Setup(repo => repo.ReadFile(It.IsAny<string>()))
|
||||
.Returns(ProjectFileWithMultipleProperties);
|
||||
var detector = CreateDotnetCoreLanguageDetector(
|
||||
var detector = CreateDotNetCoreLanguageDetector(
|
||||
supportedVersions: GetAllSupportedRuntimeVersions(),
|
||||
projectFile);
|
||||
|
||||
|
@ -148,7 +147,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(DotnetCoreConstants.LanguageName, result.Language);
|
||||
Assert.Equal(DotNetCoreConstants.LanguageName, result.Language);
|
||||
Assert.Equal(DotNetCoreRuntimeVersions.NetCoreApp21, result.LanguageVersion);
|
||||
}
|
||||
|
||||
|
@ -167,7 +166,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
sourceRepo
|
||||
.Setup(repo => repo.ReadFile(It.IsAny<string>()))
|
||||
.Returns(projectFileContent);
|
||||
var detector = CreateDotnetCoreLanguageDetector(
|
||||
var detector = CreateDotNetCoreLanguageDetector(
|
||||
supportedVersions: GetAllSupportedRuntimeVersions(),
|
||||
projectFile);
|
||||
|
||||
|
@ -190,7 +189,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
sourceRepo
|
||||
.Setup(repo => repo.ReadFile(It.IsAny<string>()))
|
||||
.Returns(ProjectFileWithTargetFrameworkPlaceHolder.Replace("#TargetFramework#", "netcoreapp2.1"));
|
||||
var detector = CreateDotnetCoreLanguageDetector(
|
||||
var detector = CreateDotNetCoreLanguageDetector(
|
||||
supportedVersions: new[] { "2.2" },
|
||||
projectFile);
|
||||
|
||||
|
@ -202,30 +201,30 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.DotNetCore
|
|||
exception.Message);
|
||||
}
|
||||
|
||||
private DotnetCoreLanguageDetector CreateDotnetCoreLanguageDetector(
|
||||
private DotNetCoreLanguageDetector CreateDotNetCoreLanguageDetector(
|
||||
string[] supportedVersions,
|
||||
string projectFile)
|
||||
{
|
||||
return CreateDotnetCoreLanguageDetector(
|
||||
return CreateDotNetCoreLanguageDetector(
|
||||
supportedVersions,
|
||||
projectFile,
|
||||
new TestEnvironment());
|
||||
}
|
||||
|
||||
private DotnetCoreLanguageDetector CreateDotnetCoreLanguageDetector(
|
||||
private DotNetCoreLanguageDetector CreateDotNetCoreLanguageDetector(
|
||||
string[] supportedVersions,
|
||||
string projectFile,
|
||||
IEnvironment environment)
|
||||
{
|
||||
var optionsSetup = new DotnetCoreScriptGeneratorOptionsSetup(environment);
|
||||
var options = new DotnetCoreScriptGeneratorOptions();
|
||||
var optionsSetup = new DotNetCoreScriptGeneratorOptionsSetup(environment);
|
||||
var options = new DotNetCoreScriptGeneratorOptions();
|
||||
optionsSetup.Configure(options);
|
||||
|
||||
return new DotnetCoreLanguageDetector(
|
||||
return new DotNetCoreLanguageDetector(
|
||||
new TestVersionProvider(supportedVersions),
|
||||
Options.Create(options),
|
||||
new TestAspNetCoreWebAppProjectFileProvider(projectFile),
|
||||
NullLogger<DotnetCoreLanguageDetector>.Instance);
|
||||
NullLogger<DotNetCoreLanguageDetector>.Instance);
|
||||
}
|
||||
|
||||
private string[] GetAllSupportedRuntimeVersions()
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
using System;
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
// --------------------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.Oryx.BuildScriptGenerator.Tests
|
||||
|
|
|
@ -228,7 +228,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Node
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void GeneratedScript_UsesYarnInstallAndRunsNpmBuild_IfYarnLockFileIsPresent_AndBuildNodeIsPresentUnderScripts()
|
||||
public void GeneratedScript_UsesYarnInstallAndRunsNpmBuild_IfYarnLockIsPresent_AndHasBuildNodeUnderScripts()
|
||||
{
|
||||
// Arrange
|
||||
var scriptGenerator = GetNodePlatformInstance(defaultNpmVersion: "6.0.0");
|
||||
|
@ -456,7 +456,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Node
|
|||
[Theory]
|
||||
[MemberData(nameof(TestValueGenerator.GetNodeVersions_DoesNotSupportDebugging),
|
||||
MemberType = typeof(TestValueGenerator))]
|
||||
public void GeneratedScript_DoesNotConfigureAppInsights_IfAppInsightsEnvironmentVariable_NotSet(string nodeVersion)
|
||||
public void GeneratedScript_DoesNotConfigureAppInsights_IfAppInsightsEnvironmentVariable_NotSet(
|
||||
string nodeVersion)
|
||||
{
|
||||
// Arrange
|
||||
var scriptGenerator = GetNodePlatformInstance(defaultNodeVersion: nodeVersion);
|
||||
|
@ -497,7 +498,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Node
|
|||
{
|
||||
// Arrange
|
||||
var otherEnvironment = new Dictionary<string, string> { { Constants.AppInsightsKey, "xyz" } };
|
||||
var scriptGenerator = GetNodePlatformInstance(defaultNodeVersion: nodeVersion, otherEnvironment: otherEnvironment);
|
||||
var scriptGenerator = GetNodePlatformInstance(
|
||||
defaultNodeVersion: nodeVersion, otherEnvironment: otherEnvironment);
|
||||
var repo = new MemorySourceRepo();
|
||||
repo.AddFile(PackageJsonWithBuildScript, NodeConstants.PackageJsonFileName);
|
||||
var context = CreateScriptGeneratorContext(repo);
|
||||
|
@ -537,7 +539,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Node
|
|||
// As we don't support 6.12.0 in our build image we condition remains node 8 or newer
|
||||
// Arrange
|
||||
var otherEnvironment = new Dictionary<string, string> { { Constants.AppInsightsKey, "xyz" } };
|
||||
var scriptGenerator = GetNodePlatformInstance(defaultNodeVersion: version, otherEnvironment: otherEnvironment);
|
||||
var scriptGenerator = GetNodePlatformInstance(
|
||||
defaultNodeVersion: version, otherEnvironment: otherEnvironment);
|
||||
var repo = new MemorySourceRepo();
|
||||
repo.AddFile(PackageJsonWithBuildScript, NodeConstants.PackageJsonFileName);
|
||||
var context = CreateScriptGeneratorContext(repo);
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
// Licensed under the MIT license.
|
||||
// --------------------------------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Oryx.BuildScriptGenerator.Php;
|
||||
using Microsoft.Oryx.Tests.Common;
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Php
|
||||
|
@ -87,7 +87,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Php
|
|||
|
||||
// // Assert
|
||||
// Assert.NotNull(snippet);
|
||||
// Assert.Equal(TemplateHelpers.Render(TemplateHelpers.TemplateResource.NodeSnippet, expected), snippet.BashBuildScriptSnippet);
|
||||
// Assert.Equal(TemplateHelpers.Render(
|
||||
// TemplateHelpers.TemplateResource.NodeSnippet, expected), snippet.BashBuildScriptSnippet);
|
||||
//}
|
||||
|
||||
//[Fact]
|
||||
|
@ -109,7 +110,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Php
|
|||
|
||||
// // Assert
|
||||
// Assert.NotNull(snippet);
|
||||
// Assert.Equal(TemplateHelpers.Render(TemplateHelpers.TemplateResource.NodeSnippet, expected), snippet.BashBuildScriptSnippet);
|
||||
// Assert.Equal(TemplateHelpers.Render(
|
||||
// TemplateHelpers.TemplateResource.NodeSnippet, expected), snippet.BashBuildScriptSnippet);
|
||||
//}
|
||||
|
||||
private IProgrammingPlatform GetScriptGenerator(string defaultVersion = null)
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
// Licensed under the MIT license.
|
||||
// --------------------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Oryx.BuildScriptGenerator.Exceptions;
|
||||
|
@ -28,7 +26,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Python
|
|||
public void Detect_ReturnsNull_WhenSourceDirectoryIsEmpty()
|
||||
{
|
||||
// Arrange
|
||||
var detector = CreatePythonLanguageDetector(supportedPythonVersions: new[] { Common.PythonVersions.Python37Version });
|
||||
var detector = CreatePythonLanguageDetector(
|
||||
supportedPythonVersions: new[] { Common.PythonVersions.Python37Version });
|
||||
var sourceDir = IOHelpers.CreateTempDir(_tempDirRoot);
|
||||
// No files in source directory
|
||||
var repo = new LocalSourceRepo(sourceDir, NullLoggerFactory.Instance);
|
||||
|
@ -44,7 +43,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Python
|
|||
public void Detect_ReutrnsNull_WhenRequirementsFileDoesNotExist()
|
||||
{
|
||||
// Arrange
|
||||
var detector = CreatePythonLanguageDetector(supportedPythonVersions: new[] { Common.PythonVersions.Python37Version });
|
||||
var detector = CreatePythonLanguageDetector(
|
||||
supportedPythonVersions: new[] { Common.PythonVersions.Python37Version });
|
||||
var sourceDir = IOHelpers.CreateTempDir(_tempDirRoot);
|
||||
IOHelpers.CreateFile(sourceDir, "foo.py content", "foo.py");
|
||||
var repo = new LocalSourceRepo(sourceDir, NullLoggerFactory.Instance);
|
||||
|
@ -60,7 +60,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Python
|
|||
public void Detect_ReutrnsNull_WhenRequirementsTextFileExists_ButNoPyOrRuntimeFileExists()
|
||||
{
|
||||
// Arrange
|
||||
var detector = CreatePythonLanguageDetector(supportedPythonVersions: new[] { Common.PythonVersions.Python37Version });
|
||||
var detector = CreatePythonLanguageDetector(
|
||||
supportedPythonVersions: new[] { Common.PythonVersions.Python37Version });
|
||||
var sourceDir = IOHelpers.CreateTempDir(_tempDirRoot);
|
||||
// No files with '.py' or no runtime.txt file
|
||||
IOHelpers.CreateFile(sourceDir, "requirements.txt content", PythonConstants.RequirementsFileName);
|
||||
|
@ -77,7 +78,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Python
|
|||
public void Detect_ReutrnsResult_WhenNoPyFileExists_ButRuntimeTextFileExists_HavingPythonVersionInIt()
|
||||
{
|
||||
// Arrange
|
||||
var detector = CreatePythonLanguageDetector(supportedPythonVersions: new[] { Common.PythonVersions.Python37Version });
|
||||
var detector = CreatePythonLanguageDetector(
|
||||
supportedPythonVersions: new[] { Common.PythonVersions.Python37Version });
|
||||
var sourceDir = IOHelpers.CreateTempDir(_tempDirRoot);
|
||||
// No file with a '.py' extension
|
||||
IOHelpers.CreateFile(sourceDir, "", PythonConstants.RequirementsFileName);
|
||||
|
@ -97,7 +99,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Python
|
|||
public void Detect_Throws_WhenUnsupportedPythonVersion_FoundInRuntimeFile()
|
||||
{
|
||||
// Arrange
|
||||
var detector = CreatePythonLanguageDetector(supportedPythonVersions: new[] { Common.PythonVersions.Python37Version });
|
||||
var detector = CreatePythonLanguageDetector(
|
||||
supportedPythonVersions: new[] { Common.PythonVersions.Python37Version });
|
||||
var sourceDir = IOHelpers.CreateTempDir(_tempDirRoot);
|
||||
IOHelpers.CreateFile(sourceDir, "", PythonConstants.RequirementsFileName);
|
||||
IOHelpers.CreateFile(sourceDir, "python-100.100.100", PythonConstants.RuntimeFileName);
|
||||
|
@ -106,7 +109,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Python
|
|||
// Act & Assert
|
||||
var exception = Assert.Throws<UnsupportedVersionException>(() => detector.Detect(repo));
|
||||
Assert.Equal(
|
||||
$"Target Python version '100.100.100' is unsupported. Supported versions are: {Common.PythonVersions.Python37Version}",
|
||||
"Target Python version '100.100.100' is unsupported. " +
|
||||
$"Supported versions are: {Common.PythonVersions.Python37Version}",
|
||||
exception.Message);
|
||||
}
|
||||
|
||||
|
@ -117,7 +121,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Python
|
|||
public void Detect_ReutrnsNull_WhenRuntimeTextFileExists_ButDoesNotTextInExpectedFormat(string fileContent)
|
||||
{
|
||||
// Arrange
|
||||
var detector = CreatePythonLanguageDetector(supportedPythonVersions: new[] { Common.PythonVersions.Python37Version });
|
||||
var detector = CreatePythonLanguageDetector(
|
||||
supportedPythonVersions: new[] { Common.PythonVersions.Python37Version });
|
||||
var sourceDir = IOHelpers.CreateTempDir(_tempDirRoot);
|
||||
IOHelpers.CreateFile(sourceDir, "", PythonConstants.RequirementsFileName);
|
||||
IOHelpers.CreateFile(sourceDir, fileContent, "runtime.txt");
|
||||
|
@ -134,7 +139,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Python
|
|||
public void Detect_ReturnsResult_WithPythonDefaultVersion_WhenNoRuntimeTextFileExists()
|
||||
{
|
||||
// Arrange
|
||||
var detector = CreatePythonLanguageDetector(supportedPythonVersions: new[] { Common.PythonVersions.Python37Version });
|
||||
var detector = CreatePythonLanguageDetector(
|
||||
supportedPythonVersions: new[] { Common.PythonVersions.Python37Version });
|
||||
var sourceDir = IOHelpers.CreateTempDir(_tempDirRoot);
|
||||
IOHelpers.CreateFile(sourceDir, "content", PythonConstants.RequirementsFileName);
|
||||
IOHelpers.CreateFile(sourceDir, "foo.py content", "foo.py");
|
||||
|
@ -162,7 +168,10 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Python
|
|||
var options = new PythonScriptGeneratorOptions();
|
||||
optionsSetup.Configure(options);
|
||||
|
||||
return new PythonLanguageDetector(Options.Create(options), new TestPythonVersionProvider(supportedPythonVersions), NullLogger<PythonLanguageDetector>.Instance);
|
||||
return new PythonLanguageDetector(
|
||||
Options.Create(options),
|
||||
new TestPythonVersionProvider(supportedPythonVersions),
|
||||
NullLogger<PythonLanguageDetector>.Instance);
|
||||
}
|
||||
|
||||
private class TestPythonVersionProvider : IPythonVersionProvider
|
||||
|
|
|
@ -75,7 +75,12 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Python
|
|||
var optionsSetup = new PythonScriptGeneratorOptionsSetup(testEnv);
|
||||
optionsSetup.Configure(scriptGeneratorOptions.Value);
|
||||
|
||||
return new PythonPlatform(scriptGeneratorOptions, nodeVersionProvider, testEnv, NullLogger<PythonPlatform>.Instance, null);
|
||||
return new PythonPlatform(
|
||||
scriptGeneratorOptions,
|
||||
nodeVersionProvider,
|
||||
testEnv,
|
||||
NullLogger<PythonPlatform>.Instance,
|
||||
detector: null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,9 @@
|
|||
using System.Linq;
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
// --------------------------------------------------------------------------------------------
|
||||
|
||||
using System.Linq;
|
||||
using Scriban.Syntax;
|
||||
using Xunit;
|
||||
|
||||
|
@ -21,7 +26,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests
|
|||
|
||||
foreach (string name in requiredTemplates)
|
||||
{
|
||||
Assert.True(existingResources.Count(s => s.EndsWith(name)) == 1, $"Could not find resource \"{name}\"");
|
||||
Assert.True(
|
||||
existingResources.Count(s => s.EndsWith(name)) == 1, $"Could not find resource \"{name}\"");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,18 +35,19 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests
|
|||
public void ExtraFunctions()
|
||||
{
|
||||
string template = "{{ if IsNotBlank SomeVar }}not blank{{ else }}blank{{ end }}";
|
||||
Assert.Equal("blank", TemplateHelpers.RenderString(template, new { SomeVar = "" }));
|
||||
Assert.Equal("not blank", TemplateHelpers.RenderString(template, new { SomeVar = "bla" }));
|
||||
Assert.Equal("blank", TemplateHelpers.RenderString(template, new { SomeVar = "" }));
|
||||
Assert.Equal("not blank", TemplateHelpers.RenderString(template, new { SomeVar = "bla" }));
|
||||
|
||||
string templateWithPipe = "{{ if SomeVar | IsNotBlank }}not blank{{ else }}blank{{ end }}";
|
||||
Assert.Equal("blank", TemplateHelpers.RenderString(templateWithPipe, new { SomeVar = "" }));
|
||||
Assert.Equal("blank", TemplateHelpers.RenderString(templateWithPipe, new { SomeVar = "" }));
|
||||
Assert.Equal("not blank", TemplateHelpers.RenderString(templateWithPipe, new { SomeVar = "bla" }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Render_Throws_WhenNonExistentVariableIsUsed()
|
||||
{
|
||||
Assert.Throws<ScriptRuntimeException>(() => TemplateHelpers.RenderString("Hello {{ World }}!", new { Foo = "Bar" }));
|
||||
Assert.Throws<ScriptRuntimeException>(
|
||||
() => TemplateHelpers.RenderString("Hello {{ World }}!", new { Foo = "Bar" }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests
|
|||
class TestVersionProvider :
|
||||
BuildScriptGenerator.Node.INodeVersionProvider,
|
||||
BuildScriptGenerator.Python.IPythonVersionProvider,
|
||||
BuildScriptGenerator.DotNetCore.IDotnetCoreVersionProvider
|
||||
BuildScriptGenerator.DotNetCore.IDotNetCoreVersionProvider
|
||||
{
|
||||
public TestVersionProvider(string[] supportedVersions, string[] supportedNpmVersions = null)
|
||||
{
|
||||
|
|
|
@ -76,8 +76,17 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli.Tests
|
|||
|
||||
public bool IsErrorRedirected => throw new NotImplementedException();
|
||||
|
||||
public ConsoleColor ForegroundColor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public ConsoleColor BackgroundColor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public ConsoleColor ForegroundColor
|
||||
{
|
||||
get => throw new NotImplementedException();
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ConsoleColor BackgroundColor
|
||||
{
|
||||
get => throw new NotImplementedException();
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#pragma warning disable 0067
|
||||
public event ConsoleCancelEventHandler CancelKeyPress;
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
private readonly string SdkVersionMessageFormat = "Using .NET Core SDK Version: {0}";
|
||||
|
||||
[Fact]
|
||||
public void Builds_NetCore10App_UsingNetCore11_DotnetSdkVersion()
|
||||
public void Builds_NetCore10App_UsingNetCore11_DotNetSdkVersion()
|
||||
{
|
||||
// Arrange
|
||||
var appName = "aspnetcore10";
|
||||
|
@ -66,7 +66,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void Builds_NetCore11App_UsingNetCore11_DotnetSdkVersion()
|
||||
public void Builds_NetCore11App_UsingNetCore11_DotNetSdkVersion()
|
||||
{
|
||||
// Arrange
|
||||
var appName = "NetCoreApp11WebApp";
|
||||
|
@ -102,7 +102,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void Publishes_DotnetCore11App_ToOryxOutputDirectory_WhenSourceAndDestinationDir_AreSame()
|
||||
public void Publishes_DotNetCore11App_ToOryxOutputDirectory_WhenSourceAndDestinationDir_AreSame()
|
||||
{
|
||||
// Arrange
|
||||
var appName = "NetCoreApp11WebApp";
|
||||
|
@ -110,7 +110,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
var appDir = volume.ContainerDir;
|
||||
var script = new ShellScriptBuilder()
|
||||
.AddBuildCommand($"{appDir}")
|
||||
.AddFileExistsCheck($"{appDir}/{DotnetCoreConstants.OryxOutputPublishDirectory}/{appName}.dll")
|
||||
.AddFileExistsCheck($"{appDir}/{DotNetCoreConstants.OryxOutputPublishDirectory}/{appName}.dll")
|
||||
.ToString();
|
||||
|
||||
// Act
|
||||
|
@ -137,7 +137,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void Builds_NetCore20App_UsingNetCore21_DotnetSdkVersion()
|
||||
public void Builds_NetCore20App_UsingNetCore21_DotNetSdkVersion()
|
||||
{
|
||||
// Arrange
|
||||
var appName = "aspnetcore20";
|
||||
|
@ -173,7 +173,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void Builds_NetCore21App_UsingNetCore21_DotnetSdkVersion()
|
||||
public void Builds_NetCore21App_UsingNetCore21_DotNetSdkVersion()
|
||||
{
|
||||
// Arrange
|
||||
var appName = "NetCoreApp21WebApp";
|
||||
|
@ -208,7 +208,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void Publishes_DotnetCore21App_ToOryxOutputDirectory_WhenSourceAndDestinationDir_AreSame()
|
||||
public void Publishes_DotNetCore21App_ToOryxOutputDirectory_WhenSourceAndDestinationDir_AreSame()
|
||||
{
|
||||
// Arrange
|
||||
var appName = "NetCoreApp21WebApp";
|
||||
|
@ -216,7 +216,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
var appDir = volume.ContainerDir;
|
||||
var script = new ShellScriptBuilder()
|
||||
.AddBuildCommand($"{appDir}")
|
||||
.AddFileExistsCheck($"{appDir}/{DotnetCoreConstants.OryxOutputPublishDirectory}/{appName}.dll")
|
||||
.AddFileExistsCheck($"{appDir}/{DotNetCoreConstants.OryxOutputPublishDirectory}/{appName}.dll")
|
||||
.ToString();
|
||||
|
||||
// Act
|
||||
|
@ -242,7 +242,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void Builds_NetCore22App_UsingNetCore22_DotnetSdkVersion()
|
||||
public void Builds_NetCore22App_UsingNetCore22_DotNetSdkVersion()
|
||||
{
|
||||
// Arrange
|
||||
var appName = "NetCoreApp22WebApp";
|
||||
|
@ -277,7 +277,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void Builds_NetCore30App_UsingNetCore30_DotnetSdkVersion()
|
||||
public void Builds_NetCore30App_UsingNetCore30_DotNetSdkVersion()
|
||||
{
|
||||
// Arrange
|
||||
var appName = "NetCoreApp30.WebApp";
|
||||
|
@ -314,7 +314,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void Publishes_DotnetCore22App_ToOryxOutputDirectory_WhenSourceAndDestinationDir_AreSame()
|
||||
public void Publishes_DotNetCore22App_ToOryxOutputDirectory_WhenSourceAndDestinationDir_AreSame()
|
||||
{
|
||||
// Arrange
|
||||
var appName = "NetCoreApp22WebApp";
|
||||
|
@ -322,7 +322,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
var appDir = volume.ContainerDir;
|
||||
var script = new ShellScriptBuilder()
|
||||
.AddBuildCommand($"{appDir}")
|
||||
.AddFileExistsCheck($"{appDir}/{DotnetCoreConstants.OryxOutputPublishDirectory}/{appName}.dll")
|
||||
.AddFileExistsCheck($"{appDir}/{DotNetCoreConstants.OryxOutputPublishDirectory}/{appName}.dll")
|
||||
.ToString();
|
||||
|
||||
// Act
|
||||
|
@ -505,7 +505,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
}
|
||||
|
||||
var appDir = volume.ContainerDir;
|
||||
var outputDir = $"{appDir}/{DotnetCoreConstants.OryxOutputPublishDirectory}";
|
||||
var outputDir = $"{appDir}/{DotNetCoreConstants.OryxOutputPublishDirectory}";
|
||||
var script = new ShellScriptBuilder()
|
||||
.AddBuildCommand($"{appDir} -l dotnet --language-version 2.1")
|
||||
.AddFileExistsCheck($"{outputDir}/pre-{fileName}")
|
||||
|
@ -658,7 +658,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
}
|
||||
|
||||
var appDir = volume.ContainerDir;
|
||||
var outputDir = $"{appDir}/{DotnetCoreConstants.OryxOutputPublishDirectory}";
|
||||
var outputDir = $"{appDir}/{DotNetCoreConstants.OryxOutputPublishDirectory}";
|
||||
var script = new ShellScriptBuilder()
|
||||
.AddBuildCommand(
|
||||
$"{appDir} -l dotnet --language-version 2.1 " +
|
||||
|
@ -842,7 +842,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
var script = new ShellScriptBuilder()
|
||||
.SetEnvironmentVariable(EnvironmentSettingsKeys.Project, "src/WebApp1/WebApp1.csproj")
|
||||
.AddBuildCommand($"{appDir}")
|
||||
.AddFileExistsCheck($"{appDir}/{DotnetCoreConstants.OryxOutputPublishDirectory}/MyWebApp.dll")
|
||||
.AddFileExistsCheck($"{appDir}/{DotNetCoreConstants.OryxOutputPublishDirectory}/MyWebApp.dll")
|
||||
.ToString();
|
||||
|
||||
// Act
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
|
||||
[Trait("platform", "dotnet")]
|
||||
[Fact]
|
||||
public void DotnetAlias_UsesLtsVersion_ByDefault()
|
||||
public void DotNetAlias_UsesLtsVersion_ByDefault()
|
||||
{
|
||||
// Arrange
|
||||
var expectedOutput = DotNetCoreSdkVersions.DotNetCore21SdkVersion;
|
||||
|
@ -98,7 +98,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
|
|||
[InlineData("2.2", DotNetCoreSdkVersions.DotNetCore22SdkVersion)]
|
||||
[InlineData("3", DotNetCoreSdkVersions.DotNetCore30SdkVersionPreviewName)]
|
||||
[InlineData("3.0", DotNetCoreSdkVersions.DotNetCore30SdkVersionPreviewName)]
|
||||
public void DotnetAlias_UsesVersion_SetOnBenv(string runtimeVersion, string expectedSdkVersion)
|
||||
public void DotNetAlias_UsesVersion_SetOnBenv(string runtimeVersion, string expectedSdkVersion)
|
||||
{
|
||||
// Arrange
|
||||
var script = new ShellScriptBuilder()
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
// Licensed under the MIT license.
|
||||
// --------------------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.Oryx.Common;
|
||||
using Microsoft.Oryx.Tests.Common;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Oryx.Tests.Common;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Oryx.Common.Test
|
||||
|
@ -18,9 +17,12 @@ namespace Microsoft.Oryx.Common.Test
|
|||
{
|
||||
_tempDirRoot = testFixture.RootDirPath;
|
||||
}
|
||||
|
||||
private string CreateNewDir(string dirName)
|
||||
{
|
||||
return !string.IsNullOrEmpty(dirName) && !string.IsNullOrWhiteSpace(dirName) && Directory.Exists(_tempDirRoot)
|
||||
return !string.IsNullOrEmpty(dirName)
|
||||
&& !string.IsNullOrWhiteSpace(dirName)
|
||||
&& Directory.Exists(_tempDirRoot)
|
||||
? Directory.CreateDirectory(Path.Combine(_tempDirRoot, dirName)).FullName
|
||||
: Directory.CreateDirectory(Path.Combine(_tempDirRoot, Guid.NewGuid().ToString("N"))).FullName;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ namespace Microsoft.Oryx.Common.Extensions
|
|||
|
||||
Assert.Equal(
|
||||
"before https://***@example.com/ and then ftp://***@example.org/subdir",
|
||||
"before https://bla:123bla@example.com/ and then ftp://user:pass@example.org/subdir".ReplaceUrlUserInfo());
|
||||
"before https://bla:123bla@example.com/ and " +
|
||||
"then ftp://user:pass@example.org/subdir".ReplaceUrlUserInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -258,7 +258,7 @@ namespace Microsoft.Oryx.Integration.Tests
|
|||
var hostDir = Path.Combine(_hostSamplesDir, "DotNetCore", NetCoreApp21WebApp);
|
||||
var volume = DockerVolume.CreateMirror(hostDir);
|
||||
var appDir = volume.ContainerDir;
|
||||
var appOutputDir = $"{appDir}/{DotnetCoreConstants.OryxOutputPublishDirectory}";
|
||||
var appOutputDir = $"{appDir}/{DotNetCoreConstants.OryxOutputPublishDirectory}";
|
||||
var buildImageScript = new ShellScriptBuilder()
|
||||
.AddCommand($"oryx build {appDir} -l dotnet --language-version {dotnetcoreVersion}")
|
||||
.ToString();
|
||||
|
|
|
@ -107,7 +107,8 @@ namespace Microsoft.Oryx.Integration.Tests.Fixtures
|
|||
|
||||
protected virtual string GetSampleDataInsertionSql()
|
||||
{
|
||||
var sb = new StringBuilder($"USE {Constants.DatabaseName}; CREATE TABLE Products (Name varchar(50) NOT NULL);");
|
||||
var sb = new StringBuilder(
|
||||
$"USE {Constants.DatabaseName}; CREATE TABLE Products (Name varchar(50) NOT NULL);");
|
||||
foreach (var record in SampleData)
|
||||
{
|
||||
sb.Append($" INSERT INTO Products VALUES('{record.Name}');");
|
||||
|
|
|
@ -11,9 +11,9 @@ using Xunit.Abstractions;
|
|||
namespace Microsoft.Oryx.RuntimeImage.Tests
|
||||
{
|
||||
[Trait("platform", "dotnet")]
|
||||
public class DotnetCoreImageVersionsTest : TestBase
|
||||
public class DotNetCoreImageVersionsTest : TestBase
|
||||
{
|
||||
public DotnetCoreImageVersionsTest(ITestOutputHelper output) : base(output)
|
||||
public DotNetCoreImageVersionsTest(ITestOutputHelper output) : base(output)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace Microsoft.Oryx.RuntimeImage.Tests
|
|||
[InlineData("2.1")]
|
||||
[InlineData("2.2")]
|
||||
[InlineData("3.0")]
|
||||
public void DotnetCoreRuntimeImage_Contains_VersionAndCommit_Information(string version)
|
||||
public void DotNetCoreRuntimeImage_Contains_VersionAndCommit_Information(string version)
|
||||
{
|
||||
var agentOS = Environment.GetEnvironmentVariable("AGENT_OS");
|
||||
var gitCommitID = Environment.GetEnvironmentVariable("BUILD_SOURCEVERSION");
|
||||
|
@ -61,7 +61,7 @@ namespace Microsoft.Oryx.RuntimeImage.Tests
|
|||
[Theory]
|
||||
[InlineData("1.0", "Version : 1.0.1")]
|
||||
[InlineData("1.1", "Version : 1.1.13")]
|
||||
public void RuntimeImage_HasExecptedDotnetVersion_NetCoreApp10Versions(string version, string expectedOutput)
|
||||
public void RuntimeImage_HasExecptedDotNetVersion_NetCoreApp10Versions(string version, string expectedOutput)
|
||||
{
|
||||
// Arrange & Act
|
||||
var result = _dockerCli.Run(new DockerRunArguments
|
||||
|
@ -86,7 +86,7 @@ namespace Microsoft.Oryx.RuntimeImage.Tests
|
|||
[InlineData("2.1", "Version: 2.1.11")]
|
||||
[InlineData("2.2", "Version: 2.2.5")]
|
||||
[InlineData("3.0", "Version: 3.0.0-preview5-27626-15")]
|
||||
public void RuntimeImage_HasExecptedDotnetVersion(string version, string expectedOutput)
|
||||
public void RuntimeImage_HasExecptedDotNetVersion(string version, string expectedOutput)
|
||||
{
|
||||
// Arrange & Act
|
||||
var result = _dockerCli.Run(new DockerRunArguments
|
||||
|
|
|
@ -218,7 +218,8 @@ namespace Microsoft.Oryx.RuntimeImage.Tests
|
|||
|
||||
public class NodeRuntimeImageCanRunWhenAppInsightsModuleNotFound : NodeImagesTestBase
|
||||
{
|
||||
public NodeRuntimeImageCanRunWhenAppInsightsModuleNotFound(ITestOutputHelper output, TestTempDirTestFixture testTempDirTestFixture)
|
||||
public NodeRuntimeImageCanRunWhenAppInsightsModuleNotFound(
|
||||
ITestOutputHelper output, TestTempDirTestFixture testTempDirTestFixture)
|
||||
: base(output, testTempDirTestFixture)
|
||||
{
|
||||
}
|
||||
|
@ -285,7 +286,8 @@ namespace Microsoft.Oryx.RuntimeImage.Tests
|
|||
|
||||
public class NodeRuntimeImageContainsRequiredPrograms : NodeImagesTestBase
|
||||
{
|
||||
public NodeRuntimeImageContainsRequiredPrograms(ITestOutputHelper output, TestTempDirTestFixture testTempDirTestFixture)
|
||||
public NodeRuntimeImageContainsRequiredPrograms(
|
||||
ITestOutputHelper output, TestTempDirTestFixture testTempDirTestFixture)
|
||||
: base(output, testTempDirTestFixture)
|
||||
{
|
||||
}
|
||||
|
@ -313,7 +315,8 @@ namespace Microsoft.Oryx.RuntimeImage.Tests
|
|||
|
||||
public class NodeRuntimeImageRunAppUsingConfigYml : NodeImagesTestBase
|
||||
{
|
||||
public NodeRuntimeImageRunAppUsingConfigYml(ITestOutputHelper output, TestTempDirTestFixture testTempDirTestFixture)
|
||||
public NodeRuntimeImageRunAppUsingConfigYml(
|
||||
ITestOutputHelper output, TestTempDirTestFixture testTempDirTestFixture)
|
||||
: base(output, testTempDirTestFixture)
|
||||
{
|
||||
}
|
||||
|
@ -357,7 +360,8 @@ namespace Microsoft.Oryx.RuntimeImage.Tests
|
|||
|
||||
public class NodeRuntimeImageRunAppUsingProcessJson : NodeImagesTestBase
|
||||
{
|
||||
public NodeRuntimeImageRunAppUsingProcessJson(ITestOutputHelper output, TestTempDirTestFixture testTempDirTestFixture)
|
||||
public NodeRuntimeImageRunAppUsingProcessJson(
|
||||
ITestOutputHelper output, TestTempDirTestFixture testTempDirTestFixture)
|
||||
: base(output, testTempDirTestFixture)
|
||||
{
|
||||
}
|
||||
|
@ -402,7 +406,8 @@ namespace Microsoft.Oryx.RuntimeImage.Tests
|
|||
|
||||
public class NodeRuntimeImageRunAppUsingConfigJs : NodeImagesTestBase
|
||||
{
|
||||
public NodeRuntimeImageRunAppUsingConfigJs(ITestOutputHelper output, TestTempDirTestFixture testTempDirTestFixture)
|
||||
public NodeRuntimeImageRunAppUsingConfigJs(
|
||||
ITestOutputHelper output, TestTempDirTestFixture testTempDirTestFixture)
|
||||
: base(output, testTempDirTestFixture)
|
||||
{
|
||||
}
|
||||
|
@ -447,7 +452,8 @@ namespace Microsoft.Oryx.RuntimeImage.Tests
|
|||
|
||||
public class NodeRuntimeImageContainsVersionAndCommitInfo : NodeImagesTestBase
|
||||
{
|
||||
public NodeRuntimeImageContainsVersionAndCommitInfo(ITestOutputHelper output, TestTempDirTestFixture testTempDirTestFixture)
|
||||
public NodeRuntimeImageContainsVersionAndCommitInfo(
|
||||
ITestOutputHelper output, TestTempDirTestFixture testTempDirTestFixture)
|
||||
: base(output, testTempDirTestFixture)
|
||||
{
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче