Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automates generation of .sqlDataProvider file #3419

Merged
merged 3 commits into from
Dec 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Build/Cake/ci.cake
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ Task("BuildAll")
.IsDependentOn("CreateNugetPackages")
.Does(() =>
{
RevertSqlDataProvider();
});
1 change: 0 additions & 1 deletion Build/Cake/compiling.cake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Task("Build")
{
var buildSettings = new MSBuildSettings()
.SetConfiguration(configuration)
.UseToolVersion(MSBuildToolVersion.VS2017)
.SetPlatformTarget(PlatformTarget.MSIL)
.WithTarget("Rebuild")
.SetMaxCpuCount(4);
Expand Down
43 changes: 42 additions & 1 deletion Build/Cake/packaging.cake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class PackagingPatterns {

PackagingPatterns packagingPatterns;

var sqlDataProviderExists = false;

Task("PreparePackaging")
.IsDependentOn("CopyWebsite")
.IsDependentOn("Build")
Expand All @@ -26,7 +28,8 @@ Task("PreparePackaging")

Task("CopyWebsite")
.IsDependentOn("CleanWebsite")
.Does(() =>
.IsDependentOn("GenerateSqlDataProvider")
.Does(() =>
{
CopyFiles(GetFiles("./DNN Platform/Website/**/*"), websiteFolder, true);
});
Expand Down Expand Up @@ -107,3 +110,41 @@ Task("CreateSymbols")
var resFile = Dnn.CakeUtils.Compression.ZipToBytes(websiteFolder.TrimEnd('/'), files);
Dnn.CakeUtils.Compression.AddBinaryFileToZip(packageZip, resFile, "Resources.zip", true);
});

Task("GenerateSqlDataProvider")
.IsDependentOn("SetVersion")
.Does(() => {
var fileName = GetTwoDigitsVersionNumber() + ".SqlDataProvider";
var filePath = "./Dnn Platform/Website/Providers/DataProviders/SqlDataProvider/" + fileName;
if (System.IO.File.Exists(filePath))
{
sqlDataProviderExists = true;
return;
}
sqlDataProviderExists = false;

using (System.IO.StreamWriter file =
new System.IO.StreamWriter(filePath, true))
{
file.WriteLine("/************************************************************/");
file.WriteLine("/***** SqlDataProvider *****/");
file.WriteLine("/***** *****/");
file.WriteLine("/***** *****/");
file.WriteLine("/***** Note: To manually execute this script you must *****/");
file.WriteLine("/***** perform a search and replace operation *****/");
file.WriteLine("/***** for {databaseOwner} and {objectQualifier} *****/");
file.WriteLine("/***** *****/");
file.WriteLine("/************************************************************/");
}
});

private void RevertSqlDataProvider(){
var fileName = GetTwoDigitsVersionNumber() + ".SqlDataProvider";
var filePath = "./Dnn Platform/Website/Providers/DataProviders/SqlDataProvider/" + fileName;
if (!sqlDataProviderExists && System.IO.File.Exists(filePath))
{
System.IO.File.Delete(filePath);
}
}


13 changes: 13 additions & 0 deletions Build/Cake/version.cake
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ public string GetBuildNumber()
return buildNumber;
}

public string GetTwoDigitsVersionNumber(){
var fullVer = GetBuildNumber().Split('-')[0]; // Gets rid of the -unstable, -beta, etc.
var numbers = fullVer.Split('.');
for (int i=0; i < numbers.Length; i++)
{
if (numbers[i].Length < 2)
{
numbers[i] = "0" + numbers[i];
}
}
return String.Join(".", numbers);
}

public string GetProductVersion()
{
return productVersion;
Expand Down