3
3
using GitVersion . OutputVariables ;
4
4
using GitVersion . Logging ;
5
5
using System . Text ;
6
+ using GitVersion . Helpers ;
6
7
7
8
namespace GitVersion . BuildServers
8
9
{
@@ -22,9 +23,12 @@ public override string GenerateSetVersionMessage(VersionVariables variables)
22
23
23
24
using var httpClient = GetHttpClient ( ) ;
24
25
25
- var body = $ "{{\" version\" :\" { variables . FullSemVer } .build.{ buildNumber } \" }}";
26
+ var body = new
27
+ {
28
+ version = $ "{ variables . FullSemVer } .build.{ buildNumber } ",
29
+ } ;
26
30
27
- var stringContent = new StringContent ( body , Encoding . UTF8 , "application/json" ) ;
31
+ var stringContent = new StringContent ( JsonSerializer . Serialize ( body ) , Encoding . UTF8 , "application/json" ) ;
28
32
var response = httpClient . PutAsync ( "api/build" , stringContent ) . GetAwaiter ( ) . GetResult ( ) ;
29
33
response . EnsureSuccessStatusCode ( ) ;
30
34
@@ -35,9 +39,13 @@ public override string[] GenerateSetParameterMessage(string name, string value)
35
39
{
36
40
var httpClient = GetHttpClient ( ) ;
37
41
38
- var body = $ "{{\" name\" : \" GitVersion_{ name } \" ,\" value\" : \" { value } \" }}";
42
+ var body = new
43
+ {
44
+ name = $ "GitVersion_{ name } ",
45
+ value = $ "{ value } "
46
+ } ;
39
47
40
- var stringContent = new StringContent ( body , Encoding . UTF8 , "application/json" ) ;
48
+ var stringContent = new StringContent ( JsonSerializer . Serialize ( body ) , Encoding . UTF8 , "application/json" ) ;
41
49
var response = httpClient . PostAsync ( "api/build/variables" , stringContent ) . GetAwaiter ( ) . GetResult ( ) ;
42
50
response . EnsureSuccessStatusCode ( ) ;
43
51
0 commit comments