forked from dnnsoftware/Dnn.Platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Further reorganization of build process (dnnsoftware#3236)
* Introduce settings and add custom version nr * Ability to create a local dev site * Move node workspaces to root * Reshuffling of variables in MSBuild * Repairs * Fix * Allow local override of global build variables * Only save manifests if the file is not there. This prevents overwriting in case of a failed build before. * Ensure projects build in debug to the website path specified by the platform build settings * Don't track vscode folder
- Loading branch information
1 parent
213bb26
commit 0dd5bad
Showing
80 changed files
with
572 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Task("ResetDatabase") | ||
.Does(() => | ||
{ | ||
var script = ReplaceScriptVariables(LoadScript("db-connections-drop")); | ||
ExecuteScript(script); | ||
script = ReplaceScriptVariables(LoadScript("create-db")); | ||
ExecuteScript(script); | ||
if (Settings.DnnSqlUsername != "") { | ||
script = ReplaceScriptVariables(LoadScript("add-db-user")); | ||
ExecuteScript(script); | ||
} | ||
}); | ||
|
||
public const string ScriptsPath = @".\Build\Cake\sql\"; | ||
|
||
public string LoadScript(string scriptName) { | ||
var script = scriptName + ".local.sql"; | ||
if (!System.IO.File.Exists(ScriptsPath + script)) { | ||
script = scriptName + ".sql"; | ||
} | ||
return Utilities.ReadFile(ScriptsPath + script); | ||
} | ||
|
||
public string ReplaceScriptVariables(string script) { | ||
return script | ||
.Replace("{DBName}", Settings.DnnDatabaseName) | ||
.Replace("{DBPath}", Settings.DatabasePath) | ||
.Replace("{DBLogin}", Settings.DnnSqlUsername); | ||
} | ||
|
||
public bool ExecuteScript(string ScriptStatement) | ||
{ | ||
try | ||
{ | ||
using (var connection = new System.Data.SqlClient.SqlConnection(Settings.SaConnectionString)) | ||
{ | ||
connection.Open(); | ||
foreach (var cmd in ScriptStatement.Split(new string[] {"\r\nGO\r\n"}, StringSplitOptions.RemoveEmptyEntries)) { | ||
var command = new System.Data.SqlClient.SqlCommand(cmd, connection); | ||
command.ExecuteNonQuery(); | ||
} | ||
connection.Close(); | ||
} | ||
} | ||
catch (Exception err){ | ||
Error(err); | ||
return false; | ||
} | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Task("ResetDevSite") | ||
.IsDependentOn("ResetDatabase") | ||
.IsDependentOn("BackupManifests") | ||
.IsDependentOn("PreparePackaging") | ||
.IsDependentOn("OtherPackages") | ||
.IsDependentOn("ExternalExtensions") | ||
.IsDependentOn("CopyToDevSite") | ||
.IsDependentOn("CopyWebConfigToDevSite") | ||
.IsDependentOn("RestoreManifests") | ||
.Does(() => | ||
{ | ||
}); | ||
|
||
Task("CopyToDevSite") | ||
.Does(() => { | ||
CleanDirectory(Settings.WebsitePath); | ||
var files = GetFilesByPatterns(websiteFolder, new string[] {"**/*"}, packagingPatterns.installExclude); | ||
files.Add(GetFilesByPatterns(websiteFolder, packagingPatterns.installInclude)); | ||
Information("Copying {0} files to {1}", files.Count, Settings.WebsitePath); | ||
CopyFiles(files, Settings.WebsitePath, true); | ||
}); | ||
|
||
Task("CopyWebConfigToDevSite") | ||
.Does(() => { | ||
var conf = Utilities.ReadFile("./Website/web.config"); | ||
var transFile = "./Build/Cake/webconfig-transform.local.xsl"; | ||
if (!FileExists(transFile)) transFile = "./Build/Cake/webconfig-transform.xsl"; | ||
var trans = Utilities.ReadFile(transFile); | ||
trans = trans | ||
.Replace("{ConnectionString}", Settings.DnnConnectionString) | ||
.Replace("{DbOwner}", Settings.DbOwner) | ||
.Replace("{ObjectQualifier}", Settings.ObjectQualifier); | ||
var res = XmlTransform(trans, conf); | ||
var webConfig = File(System.IO.Path.Combine(Settings.WebsitePath, "web.config")); | ||
FileWriteText(webConfig, res); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
public class LocalSettings { | ||
public string WebsitePath {get; set;} = ""; | ||
public string WebsiteUrl {get; set;} = ""; | ||
public string SaConnectionString {get; set;} = "server=(local);Trusted_Connection=True;"; | ||
public string DnnConnectionString {get; set;} = ""; | ||
public string DbOwner {get; set;} = "dbo"; | ||
public string ObjectQualifier {get; set;} = ""; | ||
public string DnnDatabaseName {get; set;} = "Dnn_Platform"; | ||
public string DnnSqlUsername {get; set;} = ""; | ||
public string DatabasePath {get; set;} = ""; | ||
public string Version {get; set;} = "auto"; | ||
} | ||
|
||
LocalSettings Settings; | ||
|
||
public void LoadSettings() { | ||
var settingsFile = "settings.local.json"; | ||
if (System.IO.File.Exists(settingsFile)) { | ||
Settings = Newtonsoft.Json.JsonConvert.DeserializeObject<LocalSettings>(Utilities.ReadFile(settingsFile)); | ||
} else { | ||
Settings = new LocalSettings(); | ||
} | ||
using (var sw = new System.IO.StreamWriter(settingsFile)) { | ||
sw.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(Settings, Newtonsoft.Json.Formatting.Indented)); | ||
} | ||
} | ||
|
||
LoadSettings(); | ||
|
||
Task("CreateSettings") | ||
.Does(() => | ||
{ | ||
// Doesn't need to do anything as it's done automatically | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
USE [{DBName}] | ||
GO | ||
IF NOT EXISTS (SELECT * FROM sys.database_principals p INNER JOIN sys.server_principals sp ON sp.sid=p.sid WHERE sp.[name]='{DBLogin}' AND sp.[type]='S') | ||
BEGIN | ||
CREATE USER [DNN Connection] FOR LOGIN [{DBLogin}]; | ||
EXEC sp_addrolemember N'db_owner', N'DNN Connection'; | ||
END | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
IF db_id('{DBName}') IS NOT NULL DROP DATABASE {DBName}; | ||
GO | ||
|
||
CREATE DATABASE [{DBName}] ON PRIMARY | ||
( NAME = N'{DBName}', FILENAME = N'{DBPath}\{DBName}.mdf') | ||
LOG ON | ||
( NAME = N'{DBName}_log', FILENAME = N'{DBPath}\{DBName}_log.ldf') | ||
GO | ||
|
||
EXEC dbo.sp_dbcmptlevel @dbname=N'{DBName}', @new_cmptlevel=100 | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
USE master | ||
|
||
DECLARE @DatabaseName nvarchar(50) | ||
SET @DatabaseName = N'{DBName}' | ||
|
||
DECLARE @SQL varchar(max) | ||
SET @SQL = '' | ||
|
||
SELECT @SQL = @SQL + 'Kill ' + Convert(varchar, SPId) + ';' | ||
FROM MASTER..SysProcesses | ||
WHERE DBId = DB_ID(@DatabaseName) AND SPId <> @@SPId | ||
|
||
EXEC(@SQL) | ||
GO | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<xsl:stylesheet version="1.0" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
<xsl:output method="xml" omit-xml-declaration="yes" /> | ||
<xsl:template match="@*|node()"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@*|node()"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
<xsl:template match="connectionStrings"> | ||
<connectionStrings> | ||
<add name="SiteSqlServer" connectionString="{ConnectionString}" providerName="System.Data.SqlClient" /> | ||
</connectionStrings> | ||
</xsl:template> | ||
<xsl:template match="add[@name='SqlDataProvider']"> | ||
<add name="SqlDataProvider" type="DotNetNuke.Data.SqlDataProvider, DotNetNuke" connectionStringName="SiteSqlServer" upgradeConnectionString="" providerPath="~\Providers\DataProviders\SqlDataProvider\" objectQualifier="{ObjectQualifier}" databaseOwner="{DbOwner}" /> | ||
</xsl:template> | ||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
DNN Platform/Admin Modules/Dnn.Modules.ModuleCreator/Module.build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.