@@ -36,23 +36,36 @@ void SetRubyGemPushApiKey(string apiKey)
36
36
37
37
GitVersion GetVersion ( BuildParameters parameters )
38
38
{
39
- var dllFile = GetFiles ( $ "**/GitVersionExe/bin/{ parameters . Configuration } /{ parameters . CoreFxVersion } /GitVersion.dll") . FirstOrDefault ( ) ;
40
- var settings = new GitVersionSettings
41
- {
42
- OutputType = GitVersionOutput . Json ,
43
- ToolPath = FindToolInPath ( IsRunningOnUnix ( ) ? "dotnet" : "dotnet.exe" ) ,
44
- ArgumentCustomization = args => dllFile + " " + args . Render ( )
45
- } ;
46
-
47
- var gitVersion = GitVersion ( settings ) ;
48
-
49
- if ( ! parameters . IsLocalBuild && ! ( parameters . IsRunningOnAzurePipeline && parameters . IsPullRequest ) )
50
- {
51
- settings . UpdateAssemblyInfo = true ;
52
- settings . LogFilePath = "console" ;
53
- settings . OutputType = GitVersionOutput . BuildServer ;
54
-
55
- GitVersion ( settings ) ;
39
+ GitVersion gitVersion ;
40
+ var gitVersionFile = ( ( DirectoryPath ) Directory ( "./artifacts" ) ) . CombineWithFilePath ( "GitVersion.json" ) ;
41
+ if ( FileExists ( gitVersionFile ) ) {
42
+ Warning ( "Using GitVersion information from {0}" , gitVersionFile ) ;
43
+ gitVersion = DeserializeJsonFromFile < GitVersion > ( gitVersionFile ) ;
44
+ }
45
+ else {
46
+ Warning ( "Dogfood GitVersion to get information" ) ;
47
+
48
+ Build ( parameters . Configuration ) ;
49
+ var dllFile = GetFiles ( $ "**/GitVersionExe/bin/{ parameters . Configuration } /{ parameters . CoreFxVersion } /GitVersion.dll") . FirstOrDefault ( ) ;
50
+
51
+ var settings = new GitVersionSettings
52
+ {
53
+ OutputType = GitVersionOutput . Json ,
54
+ ToolPath = FindToolInPath ( IsRunningOnUnix ( ) ? "dotnet" : "dotnet.exe" ) ,
55
+ ArgumentCustomization = args => dllFile + " " + args . Render ( )
56
+ } ;
57
+
58
+ gitVersion = GitVersion ( settings ) ;
59
+ SerializeJsonToPrettyFile ( gitVersionFile , gitVersion ) ;
60
+
61
+ if ( ! parameters . IsLocalBuild && ! ( parameters . IsRunningOnAzurePipeline && parameters . IsPullRequest ) )
62
+ {
63
+ settings . UpdateAssemblyInfo = true ;
64
+ settings . LogFilePath = "console" ;
65
+ settings . OutputType = GitVersionOutput . BuildServer ;
66
+
67
+ GitVersion ( settings ) ;
68
+ }
56
69
}
57
70
return gitVersion ;
58
71
}
0 commit comments