예제 #1
0
        /// <summary>
        /// Ensures smooth transition between mono based Kudu and KuduLite.
        /// <remarks>
        /// <list type="bullet">
        ///     <item>
        ///         POST Receive GitHook File:This file was previously hard coded with mono path to launch kudu console.
        ///     </item>
        ///     <item>
        ///         We will would use the OryxBuild in future for deployments, as a safety measure we clear
        ///         the deployment script.
        ///     </item>
        /// </list>
        /// </remarks>
        /// </summary>
        /// <param name="environment"></param>
        internal static void MigrateToNetCorePatch(IEnvironment environment)
        {
            // Get the repository path:
            // Use value in the settings.xml file if it is present.
            string repositoryPath = environment.RepositoryPath;
            IDeploymentSettingsManager settings = GetDeploymentSettingsManager(environment);

            if (settings != null)
            {
                var settingsRepoPath = DeploymentSettingsExtension.GetRepositoryPath(settings);
                repositoryPath = Path.Combine(environment.SiteRootPath, settingsRepoPath);
            }

            var gitPostReceiveHookFile = Path.Combine(repositoryPath, ".git", "hooks", "post-receive");

            if (FileSystemHelpers.FileExists(gitPostReceiveHookFile))
            {
                var fileText = "";
                if ((fileText = FileSystemHelpers.ReadAllText(gitPostReceiveHookFile)).Contains("/usr/bin/mono"))
                {
                    FileSystemHelpers.WriteAllText(gitPostReceiveHookFile, fileText.Replace("/usr/bin/mono", "dotnet"));
                }
            }

            if (FileSystemHelpers.DirectoryExists(Path.Combine(environment.RootPath, ".mono")) &&
                FileSystemHelpers.FileExists(Path.Combine(environment.DeploymentToolsPath, "deploy.sh")))
            {
                FileSystemHelpers.DeleteFileSafe(Path.Combine(environment.DeploymentToolsPath, "deploy.sh"));
            }
        }
예제 #2
0
        /// <summary>
        /// Ensures smooth transition between mono based Kudu and KuduLite.
        /// <remarks>
        /// <list type="bullet">
        ///     <item>
        ///         POST Receive GitHook File:This file was previously hard coded with mono path to launch kudu console.
        ///     </item>
        ///     <item>
        ///         We will would use the OryxBuild in future for deployments, as a safety measure we clear
        ///         the deployment script.
        ///     </item>
        /// </list>
        /// </remarks>
        /// </summary>
        /// <param name="environment"></param>
        internal static void MigrateToNetCorePatch(IEnvironment environment)
        {
            // Get the repository path:
            // Use value in the settings.xml file if it is present.
            string repositoryPath = environment.RepositoryPath;
            IDeploymentSettingsManager settings = GetDeploymentSettingsManager(environment);

            if (settings != null)
            {
                var settingsRepoPath = DeploymentSettingsExtension.GetRepositoryPath(settings);
                repositoryPath = Path.Combine(environment.SiteRootPath, settingsRepoPath);
            }

            var gitPostReceiveHookFile = Path.Combine(repositoryPath, ".git", "hooks", "post-receive");

            if (FileSystemHelpers.FileExists(gitPostReceiveHookFile))
            {
                var fileText         = FileSystemHelpers.ReadAllText(gitPostReceiveHookFile);
                var isRunningOnAzure = System.Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID") != null;

                if (!EnvironmentHelper.IsDynamicInstallEnvironment())
                {
                    if (fileText.Contains("/usr/bin/mono"))
                    {
                        if (isRunningOnAzure)
                        {
                            FileSystemHelpers.WriteAllText(gitPostReceiveHookFile, fileText.Replace("/usr/bin/mono", "benv dotnet=2.2 dotnet"));
                        }
                    }
                    else if (!fileText.Contains("benv") && fileText.Contains("dotnet") && isRunningOnAzure)
                    {
                        FileSystemHelpers.WriteAllText(gitPostReceiveHookFile, fileText.Replace("dotnet", "benv dotnet=2.2 dotnet"));
                    }
                }
                else
                {
                    // Dynamic Install should just contain dotnet
                    if (fileText.Contains("benv") && fileText.Contains("dotnet") && isRunningOnAzure)
                    {
                        FileSystemHelpers.WriteAllText(gitPostReceiveHookFile, fileText.Replace("benv dotnet=2.2", "dotnet"));
                    }
                }
            }

            if (FileSystemHelpers.DirectoryExists(Path.Combine(environment.RootPath, ".mono")) &&
                FileSystemHelpers.FileExists(Path.Combine(environment.DeploymentToolsPath, "deploy.sh")))
            {
                FileSystemHelpers.DeleteFileSafe(Path.Combine(environment.DeploymentToolsPath, "deploy.sh"));
            }
        }