Skip to content

Commit baea193

Browse files
Merge pull request #1036 from WildGums/GitHubSync/20260717-203133
GitHubSync update
2 parents 9d7cb11 + 6ee0f7d commit baea193

4 files changed

Lines changed: 118 additions & 7 deletions

File tree

deployment/cake/docker-tasks.cake

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,29 @@ public class DockerImagesProcessor : ProcessorBase
3737

3838
private string GetDockerImageName(string projectName)
3939
{
40-
var name = projectName.Replace(".", "-");
41-
return name.ToLower();
40+
var imageName = string.Empty;
41+
42+
var appName = BuildContext.DockerImages.DockerAppName;
43+
if (!string.IsNullOrWhiteSpace(appName))
44+
{
45+
imageName = appName.ToLower() + "/";
46+
47+
if (projectName.StartsWith(appName, StringComparison.OrdinalIgnoreCase))
48+
{
49+
projectName = projectName.Substring(appName.Length);
50+
}
51+
}
52+
53+
projectName = projectName.Trim('.', '-');
54+
55+
imageName += projectName.Replace(".", "-");
56+
57+
if (imageName.EndsWith("service", StringComparison.OrdinalIgnoreCase))
58+
{
59+
imageName = imageName.Substring(0, imageName.Length - "service".Length);
60+
}
61+
62+
return imageName.ToLower();
4263
}
4364

4465
private string GetDockerImageTag(string projectName, string version)

deployment/cake/docker-variables.cake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class DockerImagesContext : BuildContextWithItemsBase
1313
public string DockerRegistryUrl { get; set; }
1414
public string DockerRegistryUserName { get; set; }
1515
public string DockerRegistryPassword { get; set; }
16+
public string DockerAppName { get; set; } = string.Empty;
1617

1718
protected override void ValidateContext()
1819
{
@@ -34,7 +35,8 @@ private DockerImagesContext InitializeDockerImagesContext(BuildContext buildCont
3435
DockerEngineUrl = buildContext.BuildServer.GetVariable("DockerEngineUrl", showValue: true),
3536
DockerRegistryUrl = buildContext.BuildServer.GetVariable("DockerRegistryUrl", showValue: true),
3637
DockerRegistryUserName = buildContext.BuildServer.GetVariable("DockerRegistryUserName", showValue: false),
37-
DockerRegistryPassword = buildContext.BuildServer.GetVariable("DockerRegistryPassword", showValue: false)
38+
DockerRegistryPassword = buildContext.BuildServer.GetVariable("DockerRegistryPassword", showValue: false),
39+
DockerAppName = buildContext.BuildServer.GetVariable("DockerAppName", showValue: true)
3840
};
3941

4042
return data;

deployment/cake/generic-tasks.cake

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Task("UpdateNuGet")
113113

114114
//-------------------------------------------------------------
115115

116-
Task("RestorePackages")
116+
Task("RestorePackagesForBuild")
117117
.IsDependentOn("Prepare")
118118
.IsDependentOn("UpdateNuGet")
119119
.ContinueOnError()
@@ -179,6 +179,94 @@ Task("RestorePackages")
179179

180180
//-------------------------------------------------------------
181181

182+
Task("RestorePackagesForPackage")
183+
.IsDependentOn("Prepare")
184+
.IsDependentOn("UpdateNuGet")
185+
.ContinueOnError()
186+
.Does<BuildContext>(buildContext =>
187+
{
188+
if (buildContext.General.IsLocalBuild && buildContext.General.MaximizePerformance)
189+
{
190+
Information("Local build with maximized performance detected, skipping package restore");
191+
return;
192+
}
193+
194+
var csharpProjects = new List<FilePath>();
195+
196+
foreach (var project in buildContext.AllProjects)
197+
{
198+
if (!ShouldPackageProject(buildContext, project) ||
199+
IsTestProject(buildContext, project))
200+
{
201+
continue;
202+
}
203+
204+
var projectFileName = GetProjectFileName(buildContext, project);
205+
if (projectFileName.EndsWith(".csproj"))
206+
{
207+
Information("Adding '{0}' as C# specific project to restore", project);
208+
209+
csharpProjects.Add(projectFileName);
210+
}
211+
}
212+
213+
var allFiles = new List<FilePath>();
214+
allFiles.AddRange(csharpProjects);
215+
216+
Information($"Found '{allFiles.Count}' projects to restore");
217+
218+
foreach (var file in allFiles)
219+
{
220+
RestoreNuGetPackages(buildContext, file);
221+
}
222+
});
223+
224+
//-------------------------------------------------------------
225+
226+
Task("RestorePackagesForDeploy")
227+
.IsDependentOn("Prepare")
228+
.IsDependentOn("UpdateNuGet")
229+
.ContinueOnError()
230+
.Does<BuildContext>(buildContext =>
231+
{
232+
if (buildContext.General.IsLocalBuild && buildContext.General.MaximizePerformance)
233+
{
234+
Information("Local build with maximized performance detected, skipping package restore");
235+
return;
236+
}
237+
238+
var csharpProjects = new List<FilePath>();
239+
240+
foreach (var project in buildContext.AllProjects)
241+
{
242+
if (!ShouldDeployProject(buildContext, project) ||
243+
IsTestProject(buildContext, project))
244+
{
245+
continue;
246+
}
247+
248+
var projectFileName = GetProjectFileName(buildContext, project);
249+
if (projectFileName.EndsWith(".csproj"))
250+
{
251+
Information("Adding '{0}' as C# specific project to restore", project);
252+
253+
csharpProjects.Add(projectFileName);
254+
}
255+
}
256+
257+
var allFiles = new List<FilePath>();
258+
allFiles.AddRange(csharpProjects);
259+
260+
Information($"Found '{allFiles.Count}' projects to restore");
261+
262+
foreach (var file in allFiles)
263+
{
264+
RestoreNuGetPackages(buildContext, file);
265+
}
266+
});
267+
268+
//-------------------------------------------------------------
269+
182270
// Note: it might look weird that this is dependent on restore packages,
183271
// but to clean, the msbuild projects must be able to load. However, they need
184272
// some targets files that come in via packages

deployment/cake/tasks.cake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ Task("UpdateInfo")
347347

348348
Task("Build")
349349
.IsDependentOn("Clean")
350-
.IsDependentOn("RestorePackages")
350+
.IsDependentOn("RestorePackagesForBuild")
351351
.IsDependentOn("UpdateInfo")
352352
//.IsDependentOn("VerifyDependencies")
353353
.IsDependentOn("CleanupCode")
@@ -624,7 +624,7 @@ Task("Package")
624624
.IsDependentOn("UpdateInfo")
625625
// Note: no dependency on 'build' since we might have already built the solution
626626
// Make sure we have the temporary "project.assets.json" in case we need to package with Visual Studio
627-
.IsDependentOn("RestorePackages")
627+
.IsDependentOn("RestorePackagesForPackage")
628628
// Make sure to update if we are running on a new agent so we can sign nuget packages
629629
.IsDependentOn("UpdateNuGet")
630630
.IsDependentOn("CodeSign")
@@ -689,7 +689,7 @@ Task("PackageLocal")
689689
Task("Deploy")
690690
// Note: no dependency on 'package' since we might have already packaged the solution
691691
// Make sure we have the temporary "project.assets.json" in case we need to package with Visual Studio
692-
.IsDependentOn("RestorePackages")
692+
.IsDependentOn("RestorePackagesForDeploy")
693693
.Does<BuildContext>(async buildContext =>
694694
{
695695
await buildContext.BuildServer.BeforeDeployAsync();

0 commit comments

Comments
 (0)