1818using static Nuke . Common . IO . FileSystemTasks ;
1919using static Nuke . Common . IO . PathConstruction ;
2020using static Nuke . Common . Tools . DotNet . DotNetTasks ;
21+ // ReSharper disable ArrangeThisQualifier
2122
2223class Build : NukeBuild
2324{
@@ -27,25 +28,20 @@ class Build : NukeBuild
2728 /// - Microsoft VisualStudio https://nuke.build/visualstudio
2829 /// - Microsoft VSCode https://nuke.build/vscode
2930
30- public static int Main ( ) => Execute < Build > ( x => x . RunUnitTests ) ;
31+ public static int Main ( ) => Execute < Build > ( x => x . RunUnitTests ) ;
3132
3233 [ Nuke . Common . Parameter ( "Configuration to build - Default is 'Debug' (local) or 'Release' (server)" ) ]
3334 readonly Configuration Configuration = IsLocalBuild ? Configuration . Debug : Configuration . Release ;
3435
35- [ Nuke . Common . Parameter ( "ReleaseNotesFilePath - To determine the SemanticVersion " ) ]
36+ [ Nuke . Common . Parameter ( "ReleaseNotesFilePath - To determine the lates changelog version " ) ]
3637 readonly AbsolutePath ReleaseNotesFilePath = RootDirectory / "Changelog.md" ;
3738
39+ [ Nuke . Common . Parameter ( "common.props file path - to determine the configured version" ) ]
40+ readonly AbsolutePath CommonPropsFilePath = RootDirectory / "src" / "common.props" ;
41+
3842 [ Solution ]
3943 readonly Solution Solution ;
4044
41- string TargetProjectName => "ElectronNET" ;
42-
43- string ApiTargetLibName => $ "{ TargetProjectName } .API";
44-
45- string CliTargetLibName => $ "{ TargetProjectName } .CLI";
46-
47- string DemoTargetLibName => $ "{ TargetProjectName } .WebApp";
48-
4945 AbsolutePath SourceDirectory => RootDirectory / "src" ;
5046
5147 AbsolutePath ResultDirectory => RootDirectory / "artifacts" ;
@@ -60,18 +56,7 @@ class Build : NukeBuild
6056
6157 string Version { get ; set ; }
6258
63- AbsolutePath [ ] Projects
64- {
65- get
66- {
67- var api = SourceDirectory / ApiTargetLibName / $ "{ ApiTargetLibName } .csproj";
68- var cli = SourceDirectory / CliTargetLibName / $ "{ CliTargetLibName } .csproj";
69- var projects = new [ ] { api , cli } ;
70- return projects ;
71- }
72- }
73-
74- string Framework => Solution . GetProject ( DemoTargetLibName ) . GetProperty ( "TargetFramework" ) ;
59+ string VersionPostFix { get ; set ; }
7560
7661 protected override void OnBuildInitialized ( )
7762 {
@@ -84,9 +69,19 @@ protected override void OnBuildInitialized()
8469 LatestReleaseNotes = ChangeLog . First ( ) ;
8570 LatestReleaseNotes . NotNull ( "LatestVersion could not be read!" ) ;
8671
87- Log . Debug ( "Using LastestVersion from ChangeLog: {LatestVersion}" , LatestReleaseNotes . Version ) ;
72+ var propsParser = new CommonPropsParser ( ) ;
73+
74+ var propsVersion = propsParser . Parse ( CommonPropsFilePath ) ;
75+
76+ propsVersion . NotNull ( "Version from common.props could not be read!" ) ;
77+
78+ Assert . True ( propsVersion == LatestReleaseNotes . Version ,
79+ $ "The version in common.props ({ propsVersion } ) does not " +
80+ $ "equal the latest version in the changelog ({ LatestReleaseNotes . Version } )") ;
81+
82+ Log . Debug ( "Using version: {LatestVersion}" , propsVersion ) ;
8883 SemVersion = LatestReleaseNotes . SemVersion ;
89- Version = LatestReleaseNotes . Version . ToString ( ) ;
84+ Version = propsVersion . ToString ( ) ;
9085
9186 if ( GitHubActions != null )
9287 {
@@ -96,13 +91,17 @@ protected override void OnBuildInitialized()
9691
9792 if ( ScheduledTargets . Contains ( Default ) )
9893 {
99- Version = $ "{ Version } -ci.{ buildNumber } ";
94+ VersionPostFix = $ "-ci.{ buildNumber } ";
10095 }
10196 else if ( ScheduledTargets . Contains ( PrePublish ) )
10297 {
103- Version = $ "{ Version } -alpha .{ buildNumber } ";
98+ VersionPostFix = $ "-pre .{ buildNumber } ";
10499 }
105100 }
101+ else if ( ScheduledTargets . Contains ( PrePublish ) )
102+ {
103+ VersionPostFix = $ "-pre";
104+ }
106105
107106 Log . Information ( "Building version: {Version}" , Version ) ;
108107 }
@@ -117,130 +116,32 @@ protected override void OnBuildInitialized()
117116 Target Restore => _ => _
118117 . Executes ( ( ) =>
119118 {
120- Projects . ForEach ( project =>
121- {
122- DotNetRestore ( s => s
123- . SetProjectFile ( project ) ) ;
124- } ) ;
119+ DotNetRestore ( s => s . SetProjectFile ( Solution . Path ) ) ;
125120 } ) ;
126121
127122 Target Compile => _ => _
128123 . DependsOn ( Restore )
129124 . Executes ( ( ) =>
130125 {
131- Projects . ForEach ( project =>
132- {
133- DotNetBuild ( s => s
134- . SetProjectFile ( project )
135- . SetVersion ( Version )
136- . SetConfiguration ( Configuration )
137- . EnableNoRestore ( ) ) ;
138- } ) ;
126+ DotNetBuild ( s => s
127+ . SetProjectFile ( Solution . Path )
128+ . SetConfiguration ( Configuration )
129+ . SetProperty ( "GeneratePackageOnBuild" , "True" )
130+ . SetProperty ( "VersionPostFix" , VersionPostFix ?? string . Empty ) ) ;
139131 } ) ;
140132
141133 Target RunUnitTests => _ => _
142134 . DependsOn ( Compile )
143135 . Executes ( ( ) =>
144136 {
145- Projects . ForEach ( project =>
146- {
147- DotNetTest ( s => s
148- . SetProjectFile ( project )
149- . SetConfiguration ( Configuration )
150- . EnableNoRestore ( )
151- . EnableNoBuild ( ) ) ;
152- } ) ;
137+ // There aren't any yet
153138 } ) ;
154139
155140 Target CreatePackages => _ => _
156141 . DependsOn ( Compile )
157142 . Executes ( ( ) =>
158143 {
159- Projects . ForEach ( project =>
160- {
161- DotNetPack ( s => s
162- . SetProject ( project )
163- . SetVersion ( Version )
164- . SetConfiguration ( Configuration )
165- . SetOutputDirectory ( ResultDirectory )
166- . SetIncludeSymbols ( true )
167- . SetSymbolPackageFormat ( "snupkg" )
168- . EnableNoRestore ( )
169- ) ;
170- } ) ;
171- } ) ;
172-
173- Target CompileSample => _ => _
174- . DependsOn ( Compile )
175- . Executes ( ( ) =>
176- {
177- var sample = SourceDirectory / DemoTargetLibName / $ "{ DemoTargetLibName } .csproj";
178- DotNetBuild ( s => s . SetProjectFile ( sample ) . SetConfiguration ( Configuration ) ) ;
179- } ) ;
180-
181- Target ElectronizeGenericTargetSample => _ => _
182- . DependsOn ( CompileSample )
183- . Executes ( ( ) =>
184- {
185- var sample = SourceDirectory / DemoTargetLibName ;
186- var cli = SourceDirectory / CliTargetLibName / $ "{ CliTargetLibName } .csproj";
187- var args = "build /target custom win7-x86;win /dotnet-configuration Debug /electron-arch ia32 /electron-params \" --publish never\" " ;
188-
189- var cmd = $ "run --project { cli } --framework { Framework } -- { args } ";
190- Log . Debug ( cmd ) ;
191- DotNet ( cmd , sample ) ;
192- } ) ;
193-
194- Target ElectronizeWindowsTargetSample => _ => _
195- . DependsOn ( CompileSample )
196- . Executes ( ( ) =>
197- {
198- var sample = SourceDirectory / DemoTargetLibName ;
199- var cli = SourceDirectory / CliTargetLibName / $ "{ CliTargetLibName } .csproj";
200- var args = "build /target win /electron-params \" --publish never\" " ;
201-
202- var cmd = $ "run --project { cli } --framework { Framework } -- { args } ";
203- Log . Debug ( cmd ) ;
204- DotNet ( cmd , sample ) ;
205- } ) ;
206-
207- Target ElectronizeCustomWin7TargetSample => _ => _
208- . DependsOn ( CompileSample )
209- . Executes ( ( ) =>
210- {
211- var sample = SourceDirectory / DemoTargetLibName ;
212- var cli = SourceDirectory / CliTargetLibName / $ "{ CliTargetLibName } .csproj";
213- var args = "build /target custom win7-x86;win /electron-params \" --publish never\" " ;
214-
215- var cmd = $ "run --project { cli } --framework { Framework } -- { args } ";
216- Log . Debug ( cmd ) ;
217- DotNet ( cmd , sample ) ;
218- } ) ;
219-
220- Target ElectronizeMacOsTargetSample => _ => _
221- . DependsOn ( CompileSample )
222- . Executes ( ( ) =>
223- {
224- var sample = SourceDirectory / DemoTargetLibName ;
225- var cli = SourceDirectory / CliTargetLibName / $ "{ CliTargetLibName } .csproj";
226- var args = "build /target osx /electron-params \" --publish never\" " ;
227-
228- var cmd = $ "run --project { cli } --framework { Framework } -- { args } ";
229- Log . Debug ( cmd ) ;
230- DotNet ( cmd , sample ) ;
231- } ) ;
232-
233- Target ElectronizeLinuxTargetSample => _ => _
234- . DependsOn ( CompileSample )
235- . Executes ( ( ) =>
236- {
237- var sample = SourceDirectory / DemoTargetLibName ;
238- var cli = SourceDirectory / CliTargetLibName / $ "{ CliTargetLibName } .csproj";
239- var args = "build /target linux /electron-params \" --publish never\" " ;
240-
241- var cmd = $ "run --project { cli } --framework { Framework } -- { args } ";
242- Log . Debug ( cmd ) ;
243- DotNet ( cmd , sample ) ;
144+ // Packages are created on build
244145 } ) ;
245146
246147 Target PublishPackages => _ => _
@@ -292,9 +193,9 @@ protected override void OnBuildInitialized()
292193 new InMemoryCredentialStore ( credentials ) ) ;
293194
294195 GitHubTasks . GitHubClient . Repository . Release
295- . Create ( "ElectronNET" , "Electron.NET" , new NewRelease ( Version )
196+ . Create ( "ElectronNET" , "Electron.NET" , new NewRelease ( Version + VersionPostFix )
296197 {
297- Name = Version ,
198+ Name = "ElectronNET.Core " + Version + VersionPostFix ,
298199 Body = String . Join ( Environment . NewLine , LatestReleaseNotes . Notes ) ,
299200 Prerelease = true ,
300201 TargetCommitish = "develop" ,
@@ -330,7 +231,7 @@ protected override void OnBuildInitialized()
330231 GitHubTasks . GitHubClient . Repository . Release
331232 . Create ( "ElectronNET" , "Electron.NET" , new NewRelease ( Version )
332233 {
333- Name = Version ,
234+ Name = "ElectronNET.Core " + Version ,
334235 Body = String . Join ( Environment . NewLine , LatestReleaseNotes . Notes ) ,
335236 Prerelease = false ,
336237 TargetCommitish = "main" ,
0 commit comments