diff --git a/Kudu.Services.Web/KuduWebUtil.cs b/Kudu.Services.Web/KuduWebUtil.cs index 270c3a34..498e42e5 100644 --- a/Kudu.Services.Web/KuduWebUtil.cs +++ b/Kudu.Services.Web/KuduWebUtil.cs @@ -213,11 +213,20 @@ internal static void MigrateToNetCorePatch(IEnvironment environment) var gitPostReceiveHookFile = Path.Combine(repositoryPath, ".git", "hooks", "post-receive"); if (FileSystemHelpers.FileExists(gitPostReceiveHookFile)) { - var fileText = ""; - if ((fileText = FileSystemHelpers.ReadAllText(gitPostReceiveHookFile)).Contains("/usr/bin/mono")) + var fileText = FileSystemHelpers.ReadAllText(gitPostReceiveHookFile); + var isRunningOnAzure = System.Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID") != null; + if (fileText.Contains("/usr/bin/mono")) { - FileSystemHelpers.WriteAllText(gitPostReceiveHookFile, fileText.Replace("/usr/bin/mono", "dotnet")); + 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")); + } + } if (FileSystemHelpers.DirectoryExists(Path.Combine(environment.RootPath, ".mono"))