2
2
using Nuke . Common . Tools . DocFx ;
3
3
using Nuke . Common . Tools . DotNet ;
4
4
using Nuke . Common . Tools . GitVersion ;
5
- using Nuke . Core ;
6
- using Nuke . Core . Utilities ;
7
- using Nuke . Core . Utilities . Collections ;
5
+ using Nuke . Common ;
6
+ using Nuke . Common . Utilities ;
7
+ using Nuke . Common . Utilities . Collections ;
8
8
using Nuke . GitHub ;
9
9
using Nuke . WebDocu ;
10
10
using System ;
15
15
using static Nuke . Common . ChangeLog . ChangelogTasks ;
16
16
using static Nuke . Common . Tools . DocFx . DocFxTasks ;
17
17
using static Nuke . Common . Tools . DotNet . DotNetTasks ;
18
- using static Nuke . Core . EnvironmentInfo ;
19
- using static Nuke . Core . IO . FileSystemTasks ;
20
- using static Nuke . Core . IO . PathConstruction ;
18
+ using static Nuke . Common . EnvironmentInfo ;
19
+ using static Nuke . Common . IO . FileSystemTasks ;
20
+ using static Nuke . Common . IO . PathConstruction ;
21
21
using static Nuke . GitHub . ChangeLogExtensions ;
22
22
using static Nuke . GitHub . GitHubTasks ;
23
23
using static Nuke . WebDocu . WebDocuTasks ;
24
+ using Nuke . Common . Tooling ;
24
25
25
26
class Build : NukeBuild
26
27
{
@@ -42,6 +43,9 @@ class Build : NukeBuild
42
43
[ Parameter ] string GitHubAuthenticationToken ;
43
44
44
45
string DocFxFile => SolutionDirectory / "docfx.json" ;
46
+
47
+ // This is used to to infer which dotnet sdk version to use when generating DocFX metadata
48
+ string DocFxDotNetSdkVersion = "2.1.4" ;
45
49
string ChangeLogFile => RootDirectory / "CHANGELOG.md" ;
46
50
47
51
Target Clean => _ => _
@@ -63,7 +67,8 @@ class Build : NukeBuild
63
67
. Executes ( ( ) =>
64
68
{
65
69
DotNetBuild ( s => DefaultDotNetBuild
66
- . SetFileVersion ( GitVersion . AssemblySemVer ) ) ;
70
+ . SetFileVersion ( GitVersion . GetNormalizedFileVersion ( ) )
71
+ . SetAssemblyVersion ( GitVersion . AssemblySemVer ) ) ;
67
72
} ) ;
68
73
69
74
Target Pack => _ => _
@@ -98,13 +103,12 @@ class Build : NukeBuild
98
103
. DependsOn ( Restore )
99
104
. Executes ( ( ) =>
100
105
{
101
- if ( IsLocalBuild )
102
- {
103
- SetVariable ( "VSINSTALLDIR" , @"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional" ) ;
104
- SetVariable ( "VisualStudioVersion" , "15.0" ) ;
105
- }
106
-
107
- DocFxMetadata ( DocFxFile , s => s . SetLogLevel ( DocFxLogLevel . Verbose ) ) ;
106
+ // So it uses a fixed, known version of MsBuild to generate the metadata. Otherwise,
107
+ // updates of dotnet or Visual Studio could introduce incompatibilities and generation failures
108
+ var dotnetPath = Path . GetDirectoryName ( ToolPathResolver . GetPathExecutable ( "dotnet.exe" ) ) ;
109
+ var msBuildPath = Path . Combine ( dotnetPath , "sdk" , DocFxDotNetSdkVersion , "MSBuild.dll" ) ;
110
+ SetVariable ( "MSBUILD_EXE_PATH" , msBuildPath ) ;
111
+ DocFxMetadata ( DocFxFile , s => s . SetLogLevel ( DocFxLogLevel . Warning ) ) ;
108
112
} ) ;
109
113
110
114
Target BuildDocumentation => _ => _
@@ -122,7 +126,7 @@ class Build : NukeBuild
122
126
123
127
DocFxBuild ( DocFxFile , s => s
124
128
. ClearXRefMaps ( )
125
- . SetLogLevel ( DocFxLogLevel . Verbose ) ) ;
129
+ . SetLogLevel ( DocFxLogLevel . Warning ) ) ;
126
130
127
131
File . Delete ( SolutionDirectory / "index.md" ) ;
128
132
Directory . Delete ( SolutionDirectory / "api" , true ) ;
@@ -148,7 +152,7 @@ class Build : NukeBuild
148
152
. DependsOn ( Pack )
149
153
. Requires ( ( ) => GitHubAuthenticationToken )
150
154
. OnlyWhen ( ( ) => GitVersion . BranchName . Equals ( "master" ) || GitVersion . BranchName . Equals ( "origin/master" ) )
151
- . Executes < Task > ( async ( ) =>
155
+ . Executes ( ( ) =>
152
156
{
153
157
var releaseTag = $ "v{ GitVersion . MajorMinorPatch } ";
154
158
@@ -159,23 +163,26 @@ class Build : NukeBuild
159
163
160
164
var repositoryInfo = GetGitHubRepositoryInfo ( GitRepository ) ;
161
165
162
- await PublishRelease ( new GitHubReleaseSettings ( )
163
- . SetArtifactPaths ( GlobFiles ( OutputDirectory , "*.nupkg" ) . NotEmpty ( ) . ToArray ( ) )
164
- . SetCommitSha ( GitVersion . Sha )
165
- . SetReleaseNotes ( completeChangeLog )
166
- . SetRepositoryName ( repositoryInfo . repositoryName )
167
- . SetRepositoryOwner ( repositoryInfo . gitHubOwner )
168
- . SetTag ( releaseTag )
169
- . SetToken ( GitHubAuthenticationToken )
170
- ) ;
166
+ PublishRelease ( new GitHubReleaseSettings ( )
167
+ . SetArtifactPaths ( GlobFiles ( OutputDirectory , "*.nupkg" ) . NotEmpty ( ) . ToArray ( ) )
168
+ . SetCommitSha ( GitVersion . Sha )
169
+ . SetReleaseNotes ( completeChangeLog )
170
+ . SetRepositoryName ( repositoryInfo . repositoryName )
171
+ . SetRepositoryOwner ( repositoryInfo . gitHubOwner )
172
+ . SetTag ( releaseTag )
173
+ . SetToken ( GitHubAuthenticationToken )
174
+ )
175
+ . ConfigureAwait ( false )
176
+ . GetAwaiter ( )
177
+ . GetResult ( ) ;
171
178
} ) ;
172
179
173
180
Target Generate => _ => _
174
181
. DependsOn ( Restore )
175
182
. Executes ( ( ) =>
176
183
{
177
184
GenerateCode (
178
- metadataDirectory : RootDirectory / "src" / "Nuke.GitHub" / "MetaData" ,
185
+ specificationDirectory : RootDirectory / "src" / "Nuke.GitHub" / "MetaData" ,
179
186
generationBaseDirectory : RootDirectory / "src" / "Nuke.GitHub" ,
180
187
baseNamespace : "Nuke.GitHub"
181
188
) ;
0 commit comments