12
12
using Nuke . Common . Tools . DotNet ;
13
13
using Nuke . Common . Tools . MSBuild ;
14
14
using Nuke . Common . Tools . Npm ;
15
- using Nuke . Common . Tools . VSTest ;
16
15
using Nuke . Common . Utilities . Collections ;
17
16
18
17
using static Nuke . Common . IO . FileSystemTasks ;
@@ -76,7 +75,7 @@ string DetermineVersionPrefix()
76
75
}
77
76
else
78
77
{
79
- var propsDocument = XDocument . Parse ( TextTasks . ReadAllText ( SourceDirectory / "Directory.Build.props" ) ) ;
78
+ var propsDocument = XDocument . Parse ( ( SourceDirectory / "Directory.Build.props" ) . ReadAllText ( ) ) ;
80
79
versionPrefix = propsDocument . Element ( "Project" ) . Element ( "PropertyGroup" ) . Element ( "VersionPrefix" ) . Value ;
81
80
Serilog . Log . Information ( "Version prefix {VersionPrefix} read from Directory.Build.props" , versionPrefix ) ;
82
81
}
@@ -117,19 +116,15 @@ protected override void OnBuildInitialized()
117
116
. Before ( Restore )
118
117
. Executes ( ( ) =>
119
118
{
120
- SourceDirectory . GlobDirectories ( "**/bin" , "**/obj" ) . ForEach ( DeleteDirectory ) ;
121
- EnsureCleanDirectory ( ArtifactsDirectory ) ;
119
+ SourceDirectory . GlobDirectories ( "**/bin" , "**/obj" ) . ForEach ( x => x . DeleteDirectory ( ) ) ;
120
+ ArtifactsDirectory . CreateOrCleanDirectory ( ) ;
122
121
} ) ;
123
122
124
-
125
123
Target InstallDependencies => _ => _
126
124
. Before ( Restore , Compile )
127
125
. Executes ( ( ) =>
128
126
{
129
127
Chocolatey ( "install wixtoolset -y" ) ;
130
- Chocolatey ( "install dotnetcore-3.1-sdk -y" ) ;
131
- Chocolatey ( "install netfx-4.6.2-devpack -y" ) ;
132
- Chocolatey ( "install dotnet-7.0-sdk -y" ) ;
133
128
NpmInstall ( x => x
134
129
. EnableGlobal ( )
135
130
. AddPackages ( "dotnettools" )
@@ -157,18 +152,19 @@ protected override void OnBuildInitialized()
157
152
) ;
158
153
} ) ;
159
154
155
+ // logic from 01_Build.bat
160
156
Target Compile => _ => _
161
157
. DependsOn ( Restore )
162
158
. Executes ( ( ) =>
163
159
{
164
- EnsureCleanDirectory ( SourceDirectory / "NSwag.Npm" / "bin" / "binaries" ) ;
165
- EnsureCleanDirectory ( NSwagStudioBinaries ) ;
160
+ ( SourceDirectory / "NSwag.Npm" / "bin" / "binaries" ) . CreateOrCleanDirectory ( ) ;
161
+ NSwagStudioBinaries . CreateOrCleanDirectory ( ) ;
166
162
167
163
Serilog . Log . Information ( "Build and copy full .NET command line with configuration {Configuration}" , Configuration ) ;
168
164
169
165
// TODO: Fix build here
170
166
MSBuild ( x => x
171
- . SetProjectFile ( Solution . GetProject ( "NSwagStudio" ) )
167
+ . SetProjectFile ( GetProject ( "NSwagStudio" ) )
172
168
. SetTargets ( "Build" )
173
169
. SetAssemblyVersion ( VersionPrefix )
174
170
. SetFileVersion ( VersionPrefix )
@@ -215,9 +211,9 @@ protected override void OnBuildInitialized()
215
211
216
212
void PublishAndCopyConsoleProjects ( )
217
213
{
218
- var consoleCoreProject = Solution . GetProject ( "NSwag.ConsoleCore" ) ;
219
- var consoleX86Project = Solution . GetProject ( "NSwag.Console.x86" ) ;
220
- var consoleProject = Solution . GetProject ( "NSwag.Console" ) ;
214
+ var consoleCoreProject = GetProject ( "NSwag.ConsoleCore" ) ;
215
+ var consoleX86Project = GetProject ( "NSwag.Console.x86" ) ;
216
+ var consoleProject = GetProject ( "NSwag.Console" ) ;
221
217
222
218
Serilog . Log . Information ( "Publish command line projects" ) ;
223
219
@@ -240,7 +236,7 @@ void PublishConsoleProject(Project project, string[] targetFrameworks)
240
236
241
237
PublishConsoleProject ( consoleX86Project , new [ ] { "net462" } ) ;
242
238
PublishConsoleProject ( consoleProject , new [ ] { "net462" } ) ;
243
- PublishConsoleProject ( consoleCoreProject , new [ ] { "netcoreapp3.1" , " net6.0", "net7.0" } ) ;
239
+ PublishConsoleProject ( consoleCoreProject , new [ ] { "net6.0" , "net7.0" } ) ;
244
240
245
241
void CopyConsoleBinaries ( AbsolutePath target )
246
242
{
@@ -252,7 +248,6 @@ void CopyConsoleBinaries(AbsolutePath target)
252
248
CopyDirectoryRecursively ( consoleProject . Directory / "bin" / Configuration / "net462" / "publish" , target / "Win" , DirectoryExistsPolicy . Merge ) ;
253
249
254
250
var consoleCoreDirectory = consoleCoreProject . Directory / "bin" / Configuration ;
255
- CopyDirectoryRecursively ( consoleCoreDirectory / "netcoreapp3.1" / "publish" , target / "NetCore31" ) ;
256
251
CopyDirectoryRecursively ( consoleCoreDirectory / "net6.0" / "publish" , target / "Net60" ) ;
257
252
CopyDirectoryRecursively ( consoleCoreDirectory / "net7.0" / "publish" , target / "Net70" ) ;
258
253
}
@@ -276,4 +271,8 @@ DotNetBuildSettings BuildDefaults(DotNetBuildSettings s)
276
271
. SetDeterministic ( IsServerBuild )
277
272
. SetContinuousIntegrationBuild ( IsServerBuild ) ;
278
273
}
274
+
275
+ // Solution.GetProject only returns solution's direct descendants since NUKE 7.0.1
276
+ private Project GetProject ( string projectName ) =>
277
+ Solution . AllProjects . FirstOrDefault ( x => x . Name == projectName ) ?? throw new ArgumentException ( $ "Could not find project { projectName } from solution") ;
279
278
}
0 commit comments