Skip to content

Commit

Permalink
Smooth out potential issues using ResetDevSite (#5310)
Browse files Browse the repository at this point in the history
* Ensure full db path is used

SQL Server can't handle paths with forward slashes instead of
backslashes

* Proactively validate DnnConnectionString setting
  • Loading branch information
bdukes authored Sep 22, 2022
1 parent ac6e9df commit fe799a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Build/Tasks/CopyWebConfigToDevSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public sealed class CopyWebConfigToDevSite : FrostingTask<Context>
/// <inheritdoc/>
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))
Expand Down
7 changes: 6 additions & 1 deletion Build/Tasks/ResetDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace DotNetNuke.Build.Tasks
{
using System;
using System.Data.SqlClient;
using System.IO;
using System.Linq;

using Cake.Common.Diagnostics;
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit fe799a4

Please sign in to comment.