Skip to content

Commit 8d0f5cb

Browse files
Auto update solution adding relevant configuration files to the solution (#749)
1 parent 199bafb commit 8d0f5cb

8 files changed

+350
-25
lines changed

.build/Build.cs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
[MSBuildVerbosityMapping]
2020
[NuGetVerbosityMapping]
2121
[ShutdownDotNetAfterServerBuild]
22+
[LocalBuildConventions]
2223
public partial class Pipeline : NukeBuild,
2324
ICanRestoreWithDotNetCore,
2425
ICanBuildWithDotNetCore,

.nuke/build.schema.json

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"AppVeyor",
3838
"AzurePipelines",
3939
"Bamboo",
40+
"Bitbucket",
4041
"Bitrise",
4142
"GitHubActions",
4243
"GitLab",
@@ -99,6 +100,7 @@
99100
"GenerateReadme",
100101
"Pack",
101102
"Restore",
103+
"T",
102104
"Test",
103105
"Trigger_Code_Coverage_Reports",
104106
"TriggerCodeCoverageReports"
@@ -135,6 +137,7 @@
135137
"GenerateReadme",
136138
"Pack",
137139
"Restore",
140+
"T",
138141
"Test",
139142
"Trigger_Code_Coverage_Reports",
140143
"TriggerCodeCoverageReports"

Directory.Packages.props

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<ItemGroup>
44
<!-- <PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="2.9.8" /> -->
5-
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" />
5+
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" />
66
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
77
<PackageVersion Include="Rocket.Surgery.MSBuild.CI" Version="1.1.1" />
88
<PackageVersion Include="Rocket.Surgery.MSBuild.GitVersion" Version="1.1.1" />
@@ -25,12 +25,16 @@
2525
<PackageVersion Include="ReportGenerator" Version="5.1.9" />
2626
<PackageVersion Include="YamlDotNet" Version="11.2.1" />
2727
<PackageVersion Include="JetBrains.ReSharper.GlobalTools" Version="2022.1.2" />
28-
<!-- <PackageVersion Include="JetBrains.ReSharper.GlobalTools" Version="2020.3.0-eap05"/>-->
29-
<PackageVersion Include="Microsoft.Build" Version="17.0.0" />
28+
<!-- <PackageVersion Include="JetBrains.ReSharper.GlobalTools" Version="2020.3.0-eap05"/>-->
29+
<PackageVersion Include="Microsoft.Build" Version="17.0.0" />
3030
<PackageVersion Include="Microsoft.Build.Framework" Version="17.0.0" />
3131
<PackageVersion Include="Microsoft.Build.Tasks.Core" Version="17.0.0" />
3232
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.0.0" />
3333
<PackageVersion Include="LiquidTestReports.Core" Version="1.3.2-beta" />
34+
<PackageVersion Include="System.Collections.Immutable" Version="6.0.0" />
35+
<PackageVersion Include="System.Interactive" Version="6.0.1" />
36+
<PackageVersion Include="System.Interactive.Async" Version="6.0.1" />
37+
3438
</ItemGroup>
3539
<ItemGroup>
3640
<PackageVersion Include="Bogus" Version="34.0.2" />

Nuke.sln

+53-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
Microsoft Visual Studio Solution File, Format Version 12.00
1+
Microsoft Visual Studio Solution File, Format Version 12.00
32
# Visual Studio Version 16
43
VisualStudioVersion = 16.0.29006.145
54
MinimumVisualStudioVersion = 15.0.26124.0
@@ -19,26 +18,64 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{DF33E0FB-9
1918
EndProject
2019
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = ".build", ".build\.build.csproj", "{55EFAE2F-A7CA-4917-A381-4A6EF5E79610}"
2120
EndProject
22-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{E3DCB78E-EE06-4EA3-88AC-762D8910387C}"
23-
EndProject
2421
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rocket.Surgery.Nuke", "src\Nuke\Rocket.Surgery.Nuke.csproj", "{C33C63CF-8760-4305-B9AC-14456930C867}"
2522
EndProject
2623
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rocket.Surgery.Nuke.Tests", "test\Nuke.Tests\Rocket.Surgery.Nuke.Tests.csproj", "{29950FB4-8A41-4C83-9FE0-FEA9C8D0BF67}"
2724
EndProject
28-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".solution", ".solution", "{096E2487-547C-4DCF-977A-DA9E1C75B6BC}"
25+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config", "config", "{AE7B2AE7-C209-4B7F-B1B8-AF150FA27A8F}"
2926
ProjectSection(SolutionItems) = preProject
30-
azure-pipelines.yml = azure-pipelines.yml
31-
build.ps1 = build.ps1
32-
build.sh = build.sh
27+
.config\dotnet-tools.json = .config\dotnet-tools.json
3328
Directory.Build.props = Directory.Build.props
29+
Directory.Packages.props = Directory.Packages.props
30+
Directory.Packages.support.props = Directory.Packages.support.props
3431
Directory.Build.targets = Directory.Build.targets
32+
.editorconfig = .editorconfig
33+
build.cmd = build.cmd
34+
build.ps1 = build.ps1
35+
build.sh = build.sh
3536
GitReleaseManager.yaml = GitReleaseManager.yaml
37+
.appveyor.yml = .appveyor.yml
38+
.codecov.yml = .codecov.yml
3639
GitVersion.yml = GitVersion.yml
3740
LICENSE = LICENSE
38-
NuGet.config = NuGet.config
39-
omnisharp.json = omnisharp.json
40-
Packages.props = Packages.props
4141
Readme.md = Readme.md
42+
.gitattributes = .gitattributes
43+
.gitignore = .gitignore
44+
.gitmodules = .gitmodules
45+
.prettierignore = .prettierignore
46+
.prettierrc = .prettierrc
47+
.lintstagedrc.js = .lintstagedrc.js
48+
NuGet.config = NuGet.config
49+
package.json = package.json
50+
EndProjectSection
51+
EndProject
52+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{C9A77903-FD53-44D1-AADB-E46BD36188C3}"
53+
ProjectSection(SolutionItems) = preProject
54+
.github\labels.yml = .github\labels.yml
55+
.github\release.yml = .github\release.yml
56+
.github\renovate.json = .github\renovate.json
57+
EndProjectSection
58+
EndProject
59+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{D92D8A6D-4ED9-4F7B-B43D-26BEE3F110C2}"
60+
ProjectSection(SolutionItems) = preProject
61+
.github\workflows\auto-label.yml = .github\workflows\auto-label.yml
62+
.github\workflows\ci-ignore.yml = .github\workflows\ci-ignore.yml
63+
.github\workflows\ci.yml = .github\workflows\ci.yml
64+
.github\workflows\close-milestone.yml = .github\workflows\close-milestone.yml
65+
.github\workflows\dependabot-merge.yml = .github\workflows\dependabot-merge.yml
66+
.github\workflows\draft-release.yml = .github\workflows\draft-release.yml
67+
.github\workflows\sync-labels.yml = .github\workflows\sync-labels.yml
68+
.github\workflows\update-milestone.yml = .github\workflows\update-milestone.yml
69+
EndProjectSection
70+
EndProject
71+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".husky", ".husky", "{39F6D15D-2627-4749-9B1D-EB7C9C656465}"
72+
ProjectSection(SolutionItems) = preProject
73+
.husky\pre-commit = .husky\pre-commit
74+
EndProjectSection
75+
EndProject
76+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".vscode", ".vscode", "{B3A06ADD-1DA1-4B79-98C6-2527B8842984}"
77+
ProjectSection(SolutionItems) = preProject
78+
.vscode\settings.json = .vscode\settings.json
4279
EndProjectSection
4380
EndProject
4481
Global
@@ -53,14 +90,10 @@ Global
5390
GlobalSection(ProjectConfigurationPlatforms) = postSolution
5491
{55EFAE2F-A7CA-4917-A381-4A6EF5E79610}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5592
{55EFAE2F-A7CA-4917-A381-4A6EF5E79610}.Debug|x64.ActiveCfg = Debug|Any CPU
56-
{55EFAE2F-A7CA-4917-A381-4A6EF5E79610}.Debug|x64.Build.0 = Debug|Any CPU
5793
{55EFAE2F-A7CA-4917-A381-4A6EF5E79610}.Debug|x86.ActiveCfg = Debug|Any CPU
58-
{55EFAE2F-A7CA-4917-A381-4A6EF5E79610}.Debug|x86.Build.0 = Debug|Any CPU
5994
{55EFAE2F-A7CA-4917-A381-4A6EF5E79610}.Release|Any CPU.ActiveCfg = Release|Any CPU
6095
{55EFAE2F-A7CA-4917-A381-4A6EF5E79610}.Release|x64.ActiveCfg = Release|Any CPU
61-
{55EFAE2F-A7CA-4917-A381-4A6EF5E79610}.Release|x64.Build.0 = Release|Any CPU
6296
{55EFAE2F-A7CA-4917-A381-4A6EF5E79610}.Release|x86.ActiveCfg = Release|Any CPU
63-
{55EFAE2F-A7CA-4917-A381-4A6EF5E79610}.Release|x86.Build.0 = Release|Any CPU
6497
{C33C63CF-8760-4305-B9AC-14456930C867}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
6598
{C33C63CF-8760-4305-B9AC-14456930C867}.Debug|Any CPU.Build.0 = Debug|Any CPU
6699
{C33C63CF-8760-4305-B9AC-14456930C867}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -90,9 +123,13 @@ Global
90123
HideSolutionNode = FALSE
91124
EndGlobalSection
92125
GlobalSection(NestedProjects) = preSolution
93-
{55EFAE2F-A7CA-4917-A381-4A6EF5E79610} = {E3DCB78E-EE06-4EA3-88AC-762D8910387C}
126+
{55EFAE2F-A7CA-4917-A381-4A6EF5E79610} = {AE7B2AE7-C209-4B7F-B1B8-AF150FA27A8F}
94127
{C33C63CF-8760-4305-B9AC-14456930C867} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3}
95128
{29950FB4-8A41-4C83-9FE0-FEA9C8D0BF67} = {DF33E0FB-9790-4654-B60F-8AB22E0CC3D1}
129+
{C9A77903-FD53-44D1-AADB-E46BD36188C3} = {AE7B2AE7-C209-4B7F-B1B8-AF150FA27A8F}
130+
{D92D8A6D-4ED9-4F7B-B43D-26BEE3F110C2} = {C9A77903-FD53-44D1-AADB-E46BD36188C3}
131+
{39F6D15D-2627-4749-9B1D-EB7C9C656465} = {AE7B2AE7-C209-4B7F-B1B8-AF150FA27A8F}
132+
{B3A06ADD-1DA1-4B79-98C6-2527B8842984} = {AE7B2AE7-C209-4B7F-B1B8-AF150FA27A8F}
96133
EndGlobalSection
97134
GlobalSection(ExtensibilityGlobals) = postSolution
98135
SolutionGuid = {439897C2-CCBD-44FE-B2DC-A3E4670ADA59}
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using Nuke.Common.Execution;
2+
using Nuke.Common.IO;
3+
4+
namespace Rocket.Surgery.Nuke;
5+
6+
/// <summary>
7+
/// Attribute is used for conventions that will only run on a local build
8+
/// Used an extension point to ensure the local build environment is configured correctly.
9+
/// </summary>
10+
[AttributeUsage(AttributeTargets.Class)]
11+
public sealed class LocalBuildConventionsAttribute : BuildExtensionAttributeBase, IOnBuildFinished, IOnBuildInitialized
12+
{
13+
/// <inheritdoc />
14+
public void OnBuildFinished(NukeBuild build)
15+
{
16+
if (build is not (INukeBuild nukeBuild and IHaveSolution haveSolution)) return;
17+
if (nukeBuild.IsServerBuild) return;
18+
19+
// EnsureSolutionIsUptoDate(nukeBuild, haveSolution);
20+
}
21+
22+
private static void EnsureSolutionIsUptoDate(INukeBuild nukeBuild, IHaveSolution haveSolution)
23+
{
24+
var path = nukeBuild.TemporaryDirectory / "solution-last-updated-at";
25+
if (!path.FileExists())
26+
{
27+
using var _ = File.Create(path);
28+
_.Close();
29+
}
30+
31+
if (File.GetLastWriteTime(path) + TimeSpan.FromHours(1) > DateTime.Now) return;
32+
33+
var attributes = nukeBuild.GetType().GetCustomAttributes(true)
34+
.OfType<SolutionUpdaterConfigurationAttribute>()
35+
.ToArray();
36+
SolutionUpdater.UpdateSolution(
37+
haveSolution.Solution,
38+
attributes.SelectMany(z => z.AdditionalRelativeFolderFilePatterns),
39+
attributes.SelectMany(z => z.AdditionalConfigFolderFilePatterns)
40+
);
41+
File.SetLastWriteTime(path, DateTime.Now);
42+
}
43+
44+
/// <inheritdoc />
45+
public void OnBuildInitialized(
46+
NukeBuild build, IReadOnlyCollection<ExecutableTarget> executableTargets, IReadOnlyCollection<ExecutableTarget> executionPlan
47+
)
48+
{
49+
if (build is not (INukeBuild nukeBuild and IHaveSolution haveSolution)) return;
50+
if (nukeBuild.IsServerBuild) return;
51+
52+
EnsureSolutionIsUptoDate(nukeBuild, haveSolution);
53+
}
54+
}

0 commit comments

Comments
 (0)