Skip to content

Commit c82bea4

Browse files
committed
Update Cake build
1 parent 921bd4e commit c82bea4

7 files changed

Lines changed: 199 additions & 360 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
[Dd]ebug/
1212
[Rr]elease/
1313
x64/
14-
build/
1514
[Bb]in/
1615
[Oo]bj/
1716

Build/Build.csproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
6+
<AssemblyVersion>2.3.9</AssemblyVersion>
7+
<FileVersion>2.3.9</FileVersion>
8+
<Company>DNN Connect</Company>
9+
<Copyright>Copyright 2022 by DNN Connect</Copyright>
10+
<Product>conference</Product>
11+
<Description>Conference module</Description>
12+
</PropertyGroup>
13+
<ItemGroup>
14+
<PackageReference Include="Cake.FileHelpers" Version="5.0.0" />
15+
<PackageReference Include="Cake.Frosting" Version="2.0.0" />
16+
<PackageReference Include="Cake.Npm" Version="1.0.0" />
17+
<PackageReference Include="Dnn.CakeUtils" Version="2.0.0" />
18+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
19+
</ItemGroup>
20+
</Project>

Build/Program.cs

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
using Cake.Common.Diagnostics;
2+
using Cake.Common.IO;
3+
using Cake.Common.Tools.MSBuild;
4+
using Cake.Common.Tools.NuGet;
5+
using Cake.Core;
6+
using Cake.Core.Diagnostics;
7+
using Cake.Core.IO;
8+
using Cake.Frosting;
9+
using Cake.Npm;
10+
using Dnn.CakeUtils;
11+
using Dnn.CakeUtils.Manifest;
12+
using System.Collections.Generic;
13+
using System.Linq;
14+
15+
public static class Program
16+
{
17+
public static int Main(string[] args)
18+
{
19+
return new CakeHost()
20+
.UseContext<BuildContext>()
21+
.Run(args);
22+
}
23+
}
24+
25+
public class BuildContext : FrostingContext
26+
{
27+
public Solution Solution { get; set; }
28+
29+
public MSBuildSettings BuildSettings { get; set; }
30+
31+
public BuildContext(ICakeContext context)
32+
: base(context)
33+
{
34+
context.Environment.WorkingDirectory = context.Environment.WorkingDirectory.FullPath + "/../";
35+
this.Solution = Solution.New(".\\package.json");
36+
this.BuildSettings = new MSBuildSettings()
37+
.SetConfiguration("Release")
38+
.UseToolVersion(MSBuildToolVersion.VS2022)
39+
.WithProperty("OutDir", new System.IO.DirectoryInfo(this.Solution.dnn.pathsAndFiles.pathToAssemblies).FullName);
40+
}
41+
}
42+
43+
[TaskName("AssemblyInfo")]
44+
public sealed class AssemblyInfoTask : FrostingTask<BuildContext>
45+
{
46+
public override void Run(BuildContext context)
47+
{
48+
context.Information("Running {0}", context.Solution.name);
49+
context.Information("Exclude Filter {0}", context.Solution.dnn.pathsAndFiles.excludeFilter.Length);
50+
try
51+
{
52+
var ptrn = new string[] { "./**/AssemblyInfo.*" };
53+
var files = context.GetFilesByPatterns(ptrn, context.Solution.dnn.pathsAndFiles.excludeFilter);
54+
foreach (var file in files)
55+
{
56+
context.Information("Updating Assembly: {0}", file);
57+
context.UpdateAssemblyInfo(context.Solution, file);
58+
}
59+
ptrn = new string[] { "./**/*.csproj" };
60+
files = context.GetFilesByPatterns(ptrn, context.Solution.dnn.pathsAndFiles.excludeFilter);
61+
foreach (var file in files)
62+
{
63+
context.Information("Updating Project File: {0}", file);
64+
context.UpdateCsProjFile(context.Solution, file);
65+
}
66+
}
67+
catch (System.Exception ex)
68+
{
69+
System.Console.WriteLine(ex.Message);
70+
System.Console.WriteLine(ex.StackTrace);
71+
throw ex;
72+
}
73+
}
74+
}
75+
76+
[TaskName("Build")]
77+
[IsDependentOn(typeof(AssemblyInfoTask))]
78+
public sealed class BuildTask : FrostingTask<BuildContext>
79+
{
80+
public override void Run(BuildContext context)
81+
{
82+
context.CleanDirectory(context.Solution.dnn.pathsAndFiles.pathToAssemblies);
83+
context.NuGetRestore(context.Solution.dnn.pathsAndFiles.solutionFile);
84+
context.MSBuild(context.Solution.dnn.pathsAndFiles.solutionFile, context.BuildSettings);
85+
context.NpmRunScript("build");
86+
}
87+
}
88+
89+
[TaskName("Package")]
90+
[IsDependentOn(typeof(BuildTask))]
91+
public sealed class PackageTask : FrostingTask<BuildContext>
92+
{
93+
public override void Run(BuildContext context)
94+
{
95+
var packageName = context.Solution.dnn.pathsAndFiles.zipName + "_" + context.Solution.version + "_Install.zip";
96+
var packagePath = context.Solution.dnn.pathsAndFiles.packagesPath + "/" + packageName;
97+
if (!System.IO.Directory.Exists(context.Solution.dnn.pathsAndFiles.packagesPath))
98+
{
99+
System.IO.Directory.CreateDirectory(context.Solution.dnn.pathsAndFiles.packagesPath);
100+
}
101+
if (System.IO.File.Exists(packagePath))
102+
{
103+
System.IO.File.Delete(packagePath);
104+
}
105+
var addedDlls = new List<string>();
106+
foreach (var pfolder in context.Solution.dnn.projectFolders)
107+
{
108+
var p = context.Solution.dnn.projects[pfolder];
109+
context.Information("Loading " + p.name);
110+
var devPath = System.IO.Path.Combine(context.Solution.dnn.pathsAndFiles.devFolder, pfolder);
111+
var releaseFiles = p.pathsAndFiles.releaseFiles == null ? context.Solution.dnn.pathsAndFiles.releaseFiles : p.pathsAndFiles.releaseFiles;
112+
if (releaseFiles.Length > 0)
113+
{
114+
var excludeFiles = p.pathsAndFiles.excludeFilter;
115+
if (excludeFiles == null)
116+
{
117+
excludeFiles = context.Solution.dnn.pathsAndFiles.excludeFilter;
118+
}
119+
else
120+
{
121+
excludeFiles = excludeFiles.Concat(context.Solution.dnn.pathsAndFiles.excludeFilter).ToArray();
122+
}
123+
context.CreateResourcesFile(new DirectoryPath(devPath), packagePath, p.packageName, releaseFiles, excludeFiles);
124+
}
125+
foreach (var a in p.pathsAndFiles.assemblies)
126+
{
127+
if (!addedDlls.Contains(a))
128+
{
129+
var files = context.GetFiles(context.Solution.dnn.pathsAndFiles.pathToAssemblies + "/" + a);
130+
context.AddFilesToZip(packagePath, context.Solution.dnn.pathsAndFiles.pathToAssemblies, context.Solution.dnn.pathsAndFiles.packageAssembliesFolder, files, true);
131+
addedDlls.Add(a);
132+
}
133+
}
134+
if (!string.IsNullOrEmpty(p.pathsAndFiles.pathToScripts))
135+
{
136+
var files = context.GetFiles(p.pathsAndFiles.pathToScripts + "/*.SqlDataProvider");
137+
context.AddFilesToZip(packagePath, p.pathsAndFiles.pathToScripts, context.Solution.dnn.pathsAndFiles.packageScriptsFolder + "/" + p.packageName, files, true);
138+
}
139+
}
140+
if (context.Solution.dnn.pathsAndFiles.licenseFile != "")
141+
{
142+
var license = context.GetTextOrMdFile(System.IO.Path.GetFileNameWithoutExtension(context.Solution.dnn.pathsAndFiles.licenseFile));
143+
if (license != "")
144+
{
145+
context.AddTextFileToZip(packagePath, license, "License.txt", true);
146+
}
147+
}
148+
if (context.Solution.dnn.pathsAndFiles.releaseNotesFile != "")
149+
{
150+
var releaseNotes = context.GetTextOrMdFile(System.IO.Path.GetFileNameWithoutExtension(context.Solution.dnn.pathsAndFiles.releaseNotesFile));
151+
if (releaseNotes != "")
152+
{
153+
context.AddTextFileToZip(packagePath, releaseNotes, "ReleaseNotes.txt", true);
154+
}
155+
}
156+
var m = new Manifest(context.Solution);
157+
context.AddXmlFileToZip(packagePath, m, context.Solution.name + ".dnn", true);
158+
}
159+
}
160+
161+
[TaskName("Default")]
162+
[IsDependentOn(typeof(PackageTask))]
163+
public class DefaultTask : FrostingTask
164+
{
165+
}

Connect.Conference.sln

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.23107.0
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.1.32328.378
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Connect.Conference", "Server\Conference\Connect.Conference.csproj", "{B972A864-16D9-4F71-AD12-21582057A004}"
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Connect.Conference.Core", "Server\Connect.Conference.Core\Connect.Conference.Core.csproj", "{4A405599-4ECF-4C72-B30B-95334C5E5891}"
99
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "Build\Build.csproj", "{4805F3C2-4796-4E16-9A1A-5D0F1EA383FC}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|Any CPU = Debug|Any CPU
@@ -21,8 +23,15 @@ Global
2123
{4A405599-4ECF-4C72-B30B-95334C5E5891}.Debug|Any CPU.Build.0 = Debug|Any CPU
2224
{4A405599-4ECF-4C72-B30B-95334C5E5891}.Release|Any CPU.ActiveCfg = Release|Any CPU
2325
{4A405599-4ECF-4C72-B30B-95334C5E5891}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{4805F3C2-4796-4E16-9A1A-5D0F1EA383FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{4805F3C2-4796-4E16-9A1A-5D0F1EA383FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{4805F3C2-4796-4E16-9A1A-5D0F1EA383FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{4805F3C2-4796-4E16-9A1A-5D0F1EA383FC}.Release|Any CPU.Build.0 = Release|Any CPU
2430
EndGlobalSection
2531
GlobalSection(SolutionProperties) = preSolution
2632
HideSolutionNode = FALSE
2733
EndGlobalSection
34+
GlobalSection(ExtensibilityGlobals) = postSolution
35+
SolutionGuid = {5F25540F-E5EC-42A9-8C90-C8B9E7C7ACF0}
36+
EndGlobalSection
2837
EndGlobal

build.cake

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)