Skip to content

Commit

Permalink
Enables and documents local builds (#2932)
Browse files Browse the repository at this point in the history
* Makes temp dir local

* Ignores build results folders from git

* Backup manifests and restore after build

* Added Website/Templates to gitignore

* Fixed more references to c:\temp

* Build documentation

* Fixed wrong tempdir path

* Fixed wrong path for AE packaging

* Updated build instructions

* Deleted Cake Folder

* Recreated Cake folder with Uppercase

* Adjusted to use Cake instead of cake folder

* Trying to remove Cake.LongPath Module

* Bumped cake addins versions to latest working versions

* pins cake version and commits it

* Revert "Trying to remove Cake.LongPath Module"

This reverts commit 3ed4eee.

* Pins Cake to v0.26.0 to prevent build warnings
  • Loading branch information
valadas authored and mitchelsellers committed Aug 13, 2019
1 parent 0c37195 commit c3c35ae
Show file tree
Hide file tree
Showing 8 changed files with 238 additions and 201 deletions.
31 changes: 31 additions & 0 deletions .github/BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Building Dnn

You do not always need to build the entire solution, you can download and install from the releases and only build the part you are working on, please read [How to Contribue](CONTRIBUTING.md) first.

If you do need to build the entire solution and the distribution packages, you need to be aware that the entire distribution is split in multiple github repositories.
* This repository - contains all the core APIs
* [CKEditorProvider](https://github.com/DNN-Connect/CKEditorProvider) - The default HTML Editor Provider
* [CDF](https://github.com/dnnsoftware/ClientDependency) - The Dnn Client Dependency Framework
* [Admin Experience](https://github.com/dnnsoftware/Dnn.AdminExperience) The default administration interface (Persona Bar)

Also, we currently maintain two branches, the development branch is the next major release and we also maintain a release/x.x.x branch that allows doing bug fixes on the current major version.

To prevent issues with long paths in some build scripts, fork this repository in a short named folder on the root of any drive such as `c:\dnnsrc\` if you fork to a long path such as `c:\users\username\documents\dnn\source\` you may encounter long path issues.

If you need to build the next major release you simply need to open PowerShell and run the following command:
```
.\build.ps1 -Target BuildAll
```

But if you need to build from one of the release branches, then you also need to reference each branch you want to pull from those repositories as such (example for the 9.4.0 release, replace the branch names as needed):
```
.\build.ps1 -Target BuildAll -ScriptArgs '--CkBranch="development"','--CdfBranch="dnn"','--CpBranch="release/3.0.x"'
```

If you encounter any build issues, please re-run the build with more verbosity as such:
```
.\build.ps1 -Target BuildAll -Verbosity diagnostic
```
This will log much more information about the problem and allow you to open an issue with those more detailed logs.

If you encounter PowerShell security issues, please read [Cake - PowerShell Security](https://cakebuild.net/docs/tutorials/powershell-security)
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
*.idea/

# Build results
[Tt]ools
[Tt]ools/*
!tools/packages.config
[Rr]elease
*_i.c
*_p.c
Expand All @@ -42,6 +43,10 @@
*.dotCover
*.ldf
Artifacts/
[Ss]rc
[Tt]emp
[Bb]uild/**/*.zip


# git merge artifacts
*.orig
Expand Down Expand Up @@ -206,6 +211,8 @@ DNN [Pp]latform/[Pp]roviders/*/[Bb]in/*

[Ww]ebsite/[Ss]ignatures

[Ww]ebsite/[Tt]emplates

[Ww]ebsite/51[Dd]egrees.mobi.config
[Ww]ebsite/[Dd]ot[Nn]et[Nn]uke.log4net.config
[Ww]ebsite/[Dd]ot[Nn]et[Nn]uke.config
Expand Down
260 changes: 130 additions & 130 deletions Build/Cake/create-database.cake
Original file line number Diff line number Diff line change
@@ -1,131 +1,131 @@

string connectionString = @"server=(localdb)\MSSQLLocalDB";

Task("CreateDatabase")
.Does(() =>
{
var deleteScript = "if db_id('Dnn_Platform') is not null DROP DATABASE Dnn_Platform;";
Information("Dropping LocalDb: {0}", ExecuteSqlScript(deleteScript));
var createDbScript = string.Format(@"
CREATE DATABASE
[Dnn_Platform]
ON PRIMARY (
NAME=Dnn_data,
FILENAME = '{0}\Dnn_Platform.mdf'
)
LOG ON (
NAME=Dnn_log,
FILENAME = '{0}\Dnn_Platform.ldf'
)",
tempDir
);
var createDbStatus = ExecuteSqlScript(createDbScript);
Information("Created LocalDb: {0}", createDbStatus);
if (createDbStatus)
{
connectionString = @"server=(localdb)\MSSQLLocalDB;Database=Dnn_Platform;Trusted_Connection=True;";
var schemaScriptName = XmlPeek("./Website/Install/DotNetNuke.install.config.resources", "/dotnetnuke/scripts/script[@name='Schema']");
var dataScriptName = XmlPeek("./Website/Install/DotNetNuke.install.config.resources", "/dotnetnuke/scripts/script[@name='Data']");
var schemaVersion = XmlPeek("./Website/Install/DotNetNuke.install.config.resources", "/dotnetnuke/version");
//#####################################################################
//run initial schema first
//#####################################################################
var fileContents = System.IO.File.ReadAllText("./Website/Providers/DataProviders/SqlDataProvider/" + schemaScriptName.ToString() + ".SqlDataProvider");
var sqlDelimiterRegex = new System.Text.RegularExpressions.Regex("(?<=(?:[^\\w]+|^))GO(?=(?: |\\t)*?(?:\\r?\\n|$))", System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Multiline);
string[] sqlStatements = sqlDelimiterRegex.Split(fileContents);
foreach (string statement in sqlStatements)
{
ExecuteSqlScript(statement);
}
Information("Initial Schema for v{0}", schemaVersion);
//#####################################################################
//populate with data next
//#####################################################################
fileContents = System.IO.File.ReadAllText("./Website/Providers/DataProviders/SqlDataProvider/" + dataScriptName.ToString() + ".SqlDataProvider");
sqlStatements = sqlDelimiterRegex.Split(fileContents);
foreach (string statement in sqlStatements)
{
Information("Test Data: {1}", schemaVersion, ExecuteSqlScript(statement));
}
var createDummyPortalStatement = "INSERT [dbo].[dnn_Portals] ([ExpiryDate], [UserRegistration], [BannerAdvertising], [AdministratorId], [Currency], [HostFee], [HostSpace], [AdministratorRoleId], [RegisteredRoleId], [GUID], [PaymentProcessor], [ProcessorUserId], [ProcessorPassword], [SiteLogHistory], [DefaultLanguage], [TimezoneOffset], [HomeDirectory], [PageQuota], [UserQuota], [CreatedByUserID], [CreatedOnDate], [LastModifiedByUserID], [LastModifiedOnDate], [PortalGroupID]) VALUES (NULL, 1, 0, 1, N'USD', 0.0000, 0, 0, 1, N'97debbc9-4643-4bd9-b0a0-b14170b38b0f', N'PayPal', NULL, NULL, 0, N'en-US', -8, N'Portals/0', 0, 0, -1, CAST(N'2015-02-05 14:49:37.873' AS DateTime), 1, CAST(N'2015-10-13 11:08:13.513' AS DateTime), -1)";
Information("Test Portal: {1}", schemaVersion, ExecuteSqlScript(createDummyPortalStatement));
//#####################################################################
//now get all other SqlDataProvider files and run those....
//#####################################################################
var files = GetFiles("./Website/Providers/DataProviders/SqlDataProvider/*.SqlDataProvider");
var currentFileToProcess = string.Empty;
foreach(var file in files)
{
currentFileToProcess = file.GetFilenameWithoutExtension().ToString();
var fileBits = currentFileToProcess.Split('.');
int firstBit;
int secondBit;
int thirdBit;
if (int.TryParse(fileBits[0], out firstBit) && int.TryParse(fileBits[1], out secondBit) && int.TryParse(fileBits[2], out thirdBit)) {
var schemaVersionBits = schemaVersion.Split('.');
int schemaFirstBit = int.Parse(schemaVersionBits[0]);
int schemaSecondBit = int.Parse(schemaVersionBits[1]);
int schemaThirdBit = int.Parse(schemaVersionBits[2]);
if ((firstBit == schemaFirstBit && (secondBit >= schemaSecondBit && thirdBit >= schemaThirdBit)) || firstBit > schemaFirstBit){
Information("Updated to v{0}", currentFileToProcess);
fileContents = System.IO.File.ReadAllText(file.ToString());
sqlStatements = sqlDelimiterRegex.Split(fileContents);
foreach (string statement in sqlStatements)
{
var statementSuccess = ExecuteSqlScript(statement);
}
}
}
}
}
else {
Information("An Error has occured. Please review and try again.");
}
});


public bool ExecuteSqlScript(string ScriptStatement)
{
try
{
using (var connection = new System.Data.SqlClient.SqlConnection(connectionString))
{
connection.Open();

var command = new System.Data.SqlClient.SqlCommand(ScriptStatement.Replace("{databaseOwner}", "dbo.").Replace("{objectQualifier}", "dnn_"), connection);
command.ExecuteNonQuery();

connection.Close();
}
}
catch (Exception err){
Error(err);

return false;
}

return true;

string connectionString = @"server=(localdb)\MSSQLLocalDB";

Task("CreateDatabase")
.Does(() =>
{
var deleteScript = "if db_id('Dnn_Platform') is not null DROP DATABASE Dnn_Platform;";
Information("Dropping LocalDb: {0}", ExecuteSqlScript(deleteScript));
var createDbScript = string.Format(@"
CREATE DATABASE
[Dnn_Platform]
ON PRIMARY (
NAME=Dnn_data,
FILENAME = '{0}\Dnn_Platform.mdf'
)
LOG ON (
NAME=Dnn_log,
FILENAME = '{0}\Dnn_Platform.ldf'
)",
tempDir
);
var createDbStatus = ExecuteSqlScript(createDbScript);
Information("Created LocalDb: {0}", createDbStatus);
if (createDbStatus)
{
connectionString = @"server=(localdb)\MSSQLLocalDB;Database=Dnn_Platform;Trusted_Connection=True;";
var schemaScriptName = XmlPeek("./Website/Install/DotNetNuke.install.config.resources", "/dotnetnuke/scripts/script[@name='Schema']");
var dataScriptName = XmlPeek("./Website/Install/DotNetNuke.install.config.resources", "/dotnetnuke/scripts/script[@name='Data']");
var schemaVersion = XmlPeek("./Website/Install/DotNetNuke.install.config.resources", "/dotnetnuke/version");
//#####################################################################
//run initial schema first
//#####################################################################
var fileContents = System.IO.File.ReadAllText("./Website/Providers/DataProviders/SqlDataProvider/" + schemaScriptName.ToString() + ".SqlDataProvider");
var sqlDelimiterRegex = new System.Text.RegularExpressions.Regex("(?<=(?:[^\\w]+|^))GO(?=(?: |\\t)*?(?:\\r?\\n|$))", System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Multiline);
string[] sqlStatements = sqlDelimiterRegex.Split(fileContents);
foreach (string statement in sqlStatements)
{
ExecuteSqlScript(statement);
}
Information("Initial Schema for v{0}", schemaVersion);
//#####################################################################
//populate with data next
//#####################################################################
fileContents = System.IO.File.ReadAllText("./Website/Providers/DataProviders/SqlDataProvider/" + dataScriptName.ToString() + ".SqlDataProvider");
sqlStatements = sqlDelimiterRegex.Split(fileContents);
foreach (string statement in sqlStatements)
{
Information("Test Data: {1}", schemaVersion, ExecuteSqlScript(statement));
}
var createDummyPortalStatement = "INSERT [dbo].[dnn_Portals] ([ExpiryDate], [UserRegistration], [BannerAdvertising], [AdministratorId], [Currency], [HostFee], [HostSpace], [AdministratorRoleId], [RegisteredRoleId], [GUID], [PaymentProcessor], [ProcessorUserId], [ProcessorPassword], [SiteLogHistory], [DefaultLanguage], [TimezoneOffset], [HomeDirectory], [PageQuota], [UserQuota], [CreatedByUserID], [CreatedOnDate], [LastModifiedByUserID], [LastModifiedOnDate], [PortalGroupID]) VALUES (NULL, 1, 0, 1, N'USD', 0.0000, 0, 0, 1, N'97debbc9-4643-4bd9-b0a0-b14170b38b0f', N'PayPal', NULL, NULL, 0, N'en-US', -8, N'Portals/0', 0, 0, -1, CAST(N'2015-02-05 14:49:37.873' AS DateTime), 1, CAST(N'2015-10-13 11:08:13.513' AS DateTime), -1)";
Information("Test Portal: {1}", schemaVersion, ExecuteSqlScript(createDummyPortalStatement));
//#####################################################################
//now get all other SqlDataProvider files and run those....
//#####################################################################
var files = GetFiles("./Website/Providers/DataProviders/SqlDataProvider/*.SqlDataProvider");
var currentFileToProcess = string.Empty;
foreach(var file in files)
{
currentFileToProcess = file.GetFilenameWithoutExtension().ToString();
var fileBits = currentFileToProcess.Split('.');
int firstBit;
int secondBit;
int thirdBit;
if (int.TryParse(fileBits[0], out firstBit) && int.TryParse(fileBits[1], out secondBit) && int.TryParse(fileBits[2], out thirdBit)) {
var schemaVersionBits = schemaVersion.Split('.');
int schemaFirstBit = int.Parse(schemaVersionBits[0]);
int schemaSecondBit = int.Parse(schemaVersionBits[1]);
int schemaThirdBit = int.Parse(schemaVersionBits[2]);
if ((firstBit == schemaFirstBit && (secondBit >= schemaSecondBit && thirdBit >= schemaThirdBit)) || firstBit > schemaFirstBit){
Information("Updated to v{0}", currentFileToProcess);
fileContents = System.IO.File.ReadAllText(file.ToString());
sqlStatements = sqlDelimiterRegex.Split(fileContents);
foreach (string statement in sqlStatements)
{
var statementSuccess = ExecuteSqlScript(statement);
}
}
}
}
}
else {
Information("An Error has occured. Please review and try again.");
}
});


public bool ExecuteSqlScript(string ScriptStatement)
{
try
{
using (var connection = new System.Data.SqlClient.SqlConnection(connectionString))
{
connection.Open();

var command = new System.Data.SqlClient.SqlCommand(ScriptStatement.Replace("{databaseOwner}", "dbo.").Replace("{objectQualifier}", "dnn_"), connection);
command.ExecuteNonQuery();

connection.Close();
}
}
catch (Exception err){
Error(err);

return false;
}

return true;
}
66 changes: 33 additions & 33 deletions Build/cake/unit-tests.cake → Build/Cake/unit-tests.cake
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@

Task("EnsureAllProjectsBuilt")
.IsDependentOn("UpdateDnnManifests")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
MSBuild("DNN_Platform.sln", new MSBuildSettings {
Verbosity = Verbosity.Minimal,
ToolVersion = MSBuildToolVersion.VS2017,
Configuration = configuration
});
});

Task("UnitTests")
.IsDependentOn("EnsureAllProjectsBuilt")
.Does(() =>
{
var testAssemblies = GetFiles($@"**\bin\{configuration}\DotNetNuke.Tests.*.dll");
testAssemblies -= GetFiles(@"**\DotNetNuke.Tests.Data.dll");
testAssemblies -= GetFiles(@"**\DotNetNuke.Tests.Integration.dll");
testAssemblies -= GetFiles(@"**\DotNetNuke.Tests.Utilities.dll");
testAssemblies -= GetFiles(@"**\DotNetNuke.Tests.Urls.dll");
foreach(var file in testAssemblies) {
VSTest(file.FullPath, new VSTestSettings() {
Logger = $"trx;LogFileName={file.GetFilename()}.xml",
Parallel = true,
EnableCodeCoverage = true,
FrameworkVersion = VSTestFrameworkVersion.NET45,
TestAdapterPath = @"tools\NUnitTestAdapter.2.1.1\tools"
});
}
});

Task("EnsureAllProjectsBuilt")
.IsDependentOn("UpdateDnnManifests")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
MSBuild("DNN_Platform.sln", new MSBuildSettings {
Verbosity = Verbosity.Minimal,
ToolVersion = MSBuildToolVersion.VS2017,
Configuration = configuration
});
});

Task("UnitTests")
.IsDependentOn("EnsureAllProjectsBuilt")
.Does(() =>
{
var testAssemblies = GetFiles($@"**\bin\{configuration}\DotNetNuke.Tests.*.dll");
testAssemblies -= GetFiles(@"**\DotNetNuke.Tests.Data.dll");
testAssemblies -= GetFiles(@"**\DotNetNuke.Tests.Integration.dll");
testAssemblies -= GetFiles(@"**\DotNetNuke.Tests.Utilities.dll");
testAssemblies -= GetFiles(@"**\DotNetNuke.Tests.Urls.dll");
foreach(var file in testAssemblies) {
VSTest(file.FullPath, new VSTestSettings() {
Logger = $"trx;LogFileName={file.GetFilename()}.xml",
Parallel = true,
EnableCodeCoverage = true,
FrameworkVersion = VSTestFrameworkVersion.NET45,
TestAdapterPath = @"tools\NUnitTestAdapter.2.1.1\tools"
});
}
});
File renamed without changes.
Loading

0 comments on commit c3c35ae

Please sign in to comment.