From fe799a49e4a6674cd4a13fc04f1675d5615f1e93 Mon Sep 17 00:00:00 2001 From: Brian Dukes Date: Thu, 22 Sep 2022 04:03:32 -0500 Subject: [PATCH] Smooth out potential issues using ResetDevSite (#5310) * Ensure full db path is used SQL Server can't handle paths with forward slashes instead of backslashes * Proactively validate DnnConnectionString setting --- Build/Tasks/CopyWebConfigToDevSite.cs | 5 +++++ Build/Tasks/ResetDatabase.cs | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Build/Tasks/CopyWebConfigToDevSite.cs b/Build/Tasks/CopyWebConfigToDevSite.cs index fe6af0a11a9..ad57c98a166 100644 --- a/Build/Tasks/CopyWebConfigToDevSite.cs +++ b/Build/Tasks/CopyWebConfigToDevSite.cs @@ -17,6 +17,11 @@ public sealed class CopyWebConfigToDevSite : FrostingTask /// public override void Run(Context context) { + if (string.IsNullOrWhiteSpace(context.Settings.DnnConnectionString)) + { + throw new InvalidOperationException("DnnConnectionString was blank and must have a value when the CopyWebConfigToDevSite task is run"); + } + var conf = context.FileReadText("./Website/web.config"); var transFile = "./Build/Tasks/webconfig-transform.local.xsl"; if (!context.FileExists(transFile)) diff --git a/Build/Tasks/ResetDatabase.cs b/Build/Tasks/ResetDatabase.cs index d23560e4f3f..d05247ca6b9 100644 --- a/Build/Tasks/ResetDatabase.cs +++ b/Build/Tasks/ResetDatabase.cs @@ -5,6 +5,7 @@ namespace DotNetNuke.Build.Tasks { using System; using System.Data.SqlClient; + using System.IO; using System.Linq; using Cake.Common.Diagnostics; @@ -46,8 +47,12 @@ private static string LoadScript(ICakeContext context, string scriptName) private static string ReplaceScriptVariables(Context context, string script) { + var dbPath = context.FileSystem.GetDirectory(context.Settings.DatabasePath); + dbPath.Create(); + var fullDbPath = Path.GetFullPath(dbPath.Path.FullPath); + return script.Replace("{DBName}", context.Settings.DnnDatabaseName) - .Replace("{DBPath}", context.Settings.DatabasePath) + .Replace("{DBPath}", fullDbPath) .Replace("{DBLogin}", context.Settings.DnnSqlUsername); }