@@ -16,10 +16,14 @@ namespace DotNetNuke.Build.Tasks
1616 using Cake . Common ;
1717 using Cake . Common . Build ;
1818 using Cake . Common . Diagnostics ;
19+ using Cake . Common . IO ;
1920 using Cake . Core ;
2021 using Cake . Core . IO ;
22+ using Cake . FileHelpers ;
2123 using Cake . Frosting ;
2224
25+ using Dnn . CakeUtils ;
26+
2327 using Microsoft . IdentityModel . JsonWebTokens ;
2428 using Microsoft . IdentityModel . Tokens ;
2529
@@ -48,8 +52,6 @@ namespace DotNetNuke.Build.Tasks
4852 public sealed class CreateGitHubPullRequest : FrostingTask < Context >
4953 {
5054 private const string TargetBranch = "develop" ;
51- private const string BugReportPath = ".github/ISSUE_TEMPLATE/bug-report.yml" ;
52- private const string SolutionInfoPath = "SolutionInfo.cs" ;
5355 private const string GitUserName = "DNN Platform CI Bot" ;
5456 private const string GitUserEmail = "noreply@dnncommunity.org" ;
5557
@@ -62,6 +64,9 @@ public override void Run(Context context)
6264 return ;
6365 }
6466
67+ var solutionInfoPath = context . File ( "SolutionInfo.cs" ) ;
68+ var bugReportPath = context . File ( ".github/ISSUE_TEMPLATE/bug-report.yml" ) ;
69+
6570 var sourceBranch = context . AzurePipelines ( ) . IsRunningOnAzurePipelines
6671 ? context . AzurePipelines ( ) . Environment . Repository . SourceBranch
6772 : context . GitHubActions ( ) . IsRunningOnGitHubActions
@@ -109,11 +114,11 @@ public override void Run(Context context)
109114 context . Information ( "Authenticated as GitHub App installation." ) ;
110115
111116 // Update bug-report.yml with version info from GitHub releases
112- UpdateBugReportVersions ( context , client , owner , repo ) ;
117+ UpdateBugReportVersions ( context , client , owner , repo , bugReportPath ) ;
113118
114119 // Reset SolutionInfo.cs if only the commit count/SHA changed (not the major.minor.patch)
115120 // to avoid creating a PR for every single commit.
116- ResetSolutionInfoIfVersionUnchanged ( context ) ;
121+ ResetSolutionInfoIfVersionUnchanged ( context , solutionInfoPath ) ;
117122
118123 // Only proceed with the PR if there are actual changes
119124 if ( ! HasUncommittedChanges ( context ) )
@@ -282,7 +287,7 @@ private static string NormalizePem(string pem)
282287 return sb . ToString ( ) ;
283288 }
284289
285- private static void UpdateBugReportVersions ( Context context , GitHubClient client , string owner , string repo )
290+ private static void UpdateBugReportVersions ( Context context , GitHubClient client , string owner , string repo , FilePath bugReportPath )
286291 {
287292 context . Information ( "Fetching GitHub releases to update bug report template..." ) ;
288293 var releases = client . Repository . Release . GetAll ( owner , repo ) . GetAwaiter ( ) . GetResult ( ) ;
@@ -322,7 +327,7 @@ private static void UpdateBugReportVersions(Context context, GitHubClient client
322327
323328 // Parse the YAML template and update the affected-versions options
324329 var yaml = new YamlStream ( ) ;
325- using ( var reader = new StreamReader ( BugReportPath ) )
330+ using ( var reader = new StreamReader ( bugReportPath . FullPath ) )
326331 {
327332 yaml . Load ( reader ) ;
328333 }
@@ -341,7 +346,7 @@ private static void UpdateBugReportVersions(Context context, GitHubClient client
341346
342347 if ( optionsNode == null )
343348 {
344- context . Warning ( "Could not locate affected-versions options in {0}, skipping update." , BugReportPath ) ;
349+ context . Warning ( "Could not locate affected-versions options in {0}, skipping update." , bugReportPath ) ;
345350 return ;
346351 }
347352
@@ -355,8 +360,8 @@ private static void UpdateBugReportVersions(Context context, GitHubClient client
355360 yaml . Save ( stringWriter , false ) ;
356361
357362 // YamlStream.Save wraps output in document markers (--- / ...) that the original file doesn't use
358- File . WriteAllText ( BugReportPath , StripDocumentMarkers ( stringWriter . ToString ( ) ) ) ;
359- context . Information ( "Updated {0} with {1} version option(s)." , BugReportPath , options . Count ) ;
363+ context . FileWriteText ( bugReportPath , StripDocumentMarkers ( stringWriter . ToString ( ) ) ) ;
364+ context . Information ( "Updated {0} with {1} version option(s)." , bugReportPath , options . Count ) ;
360365 }
361366
362367 private static string StripDocumentMarkers ( string yaml )
@@ -415,25 +420,25 @@ private static bool HasStagedChanges(ICakeContext context)
415420 return process . GetExitCode ( ) != 0 ;
416421 }
417422
418- private static void ResetSolutionInfoIfVersionUnchanged ( Context context )
423+ private static void ResetSolutionInfoIfVersionUnchanged ( Context context , FilePath solutionInfoPath )
419424 {
420425 var committedProcess = context . StartAndReturnProcess (
421426 "git" ,
422427 new ProcessSettings
423428 {
424- Arguments = $ "show HEAD:{ SolutionInfoPath } ",
429+ Arguments = $ "show HEAD:{ solutionInfoPath } ",
425430 RedirectStandardOutput = true ,
426431 } ) ;
427432 committedProcess . WaitForExit ( ) ;
428433
429434 if ( committedProcess . GetExitCode ( ) != 0 )
430435 {
431- context . Information ( "Could not read committed {0}, skipping reset check." , SolutionInfoPath ) ;
436+ context . Information ( "Could not read committed {0}, skipping reset check." , solutionInfoPath ) ;
432437 return ;
433438 }
434439
435440 var committedContent = string . Join ( "\n " , committedProcess . GetStandardOutput ( ) ) ;
436- var currentContent = File . ReadAllText ( SolutionInfoPath ) ;
441+ var currentContent = context . ReadFile ( solutionInfoPath ) ;
437442
438443 var committedVersion = ExtractAssemblyVersion ( committedContent ) ;
439444 var currentVersion = ExtractAssemblyVersion ( currentContent ) ;
@@ -442,12 +447,12 @@ private static void ResetSolutionInfoIfVersionUnchanged(Context context)
442447
443448 if ( string . Equals ( committedVersion , currentVersion , StringComparison . Ordinal ) )
444449 {
445- context . Information ( "Major.Minor.Patch has not changed. Resetting {0} to avoid a noisy PR." , SolutionInfoPath ) ;
446- Git ( context , $ "checkout -- { SolutionInfoPath } ") ;
450+ context . Information ( "Major.Minor.Patch has not changed. Resetting {0} to avoid a noisy PR." , solutionInfoPath ) ;
451+ Git ( context , $ "checkout -- { solutionInfoPath } ") ;
447452 }
448453 else
449454 {
450- context . Information ( "Major.Minor.Patch changed ({0} → {1}). Keeping {2} modifications." , committedVersion , currentVersion , SolutionInfoPath ) ;
455+ context . Information ( "Major.Minor.Patch changed ({0} → {1}). Keeping {2} modifications." , committedVersion , currentVersion , solutionInfoPath ) ;
451456 }
452457 }
453458
0 commit comments