1919# #############################
2020- job : Check_Build_Options
2121 pool :
22- vmImage : ' VS2017-Win2016 '
22+ vmImage : ' windows-2019 '
2323
2424 steps :
2525
@@ -47,68 +47,74 @@ jobs:
4747 condition : or( eq( variables['StartReleaseCandidate'], true ), ne(variables['system.pullrequest.isfork'], true) )
4848 displayName : Install NBGV tool
4949
50- - powershell : |
51-
52- # compute authorization header in format "AUTHORIZATION: basic 'encoded token'"
53- # 'encoded token' is the Base64 of the string "nfbot:personal-token"
54- $auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nfbot:$(GitHubToken)"))))"
55-
56- cd "$env:Agent_TempDirectory" > $null
57-
58- git init "$env:Agent_TempDirectory\repo"
59- cd repo > $null
60- git remote add origin "$env:Build_Repository_Uri"
61- git config --global gc.auto 0
62- git config --global user.name nfbot
63- git config --global user.email [email protected] 64- git config --global core.autocrlf true
65- git -c http.extraheader="AUTHORIZATION: $auth" fetch --progress origin
66-
67- git checkout develop
68-
69- cd source
70-
71- # prepare release and capture output
72- $release = nbgv prepare-release
73-
74- # get commit message for the merge
75- $commitMessage = git log -1 --pretty=%B
76-
77- # amend commit message to skip build
78- git commit --amend -m "$commitMessage" -m "***NO_CI***" > $null
79-
80- # push all changes to github
81- git -c http.extraheader="AUTHORIZATION: $auth" push --all origin
82-
83- # get release branch name
84- $branch = $release.Split(' ')[0]
85-
86- # start PR for release
87- $prRequestBody = @{title="Release $branch";body="";head="$branch";base="master"} | ConvertTo-Json
88- $githubApiEndpoint = "https://api.github.com/repos/$env:Build_Repository_Name/pulls"
89- [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
90-
91- $headers = @{}
92- $headers.Add("Authorization","$auth")
93- $headers.Add("Accept","application/vnd.github.symmetra-preview+json")
94-
95- try
96- {
97- $result = Invoke-RestMethod -Method Post -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer -Uri $githubApiEndpoint -Header $headers -ContentType "application/json" -Body $prRequestBody
98- 'Started PR for new release...' | Write-Host -NoNewline
99- 'OK' | Write-Host -ForegroundColor Green
100- }
101- catch
102- {
103- $result = $_.Exception.Response.GetResponseStream()
104- $reader = New-Object System.IO.StreamReader($result)
105- $reader.BaseStream.Position = 0
106- $reader.DiscardBufferedData()
107- $responseBody = $reader.ReadToEnd();
108-
109- "Error starting PR: $responseBody" | Write-Host -ForegroundColor Red
110- }
111-
50+ - task : PowerShell@2
51+ inputs :
52+ targetType : ' inline'
53+ script : |
54+ # compute authorization header in format "AUTHORIZATION: basic 'encoded token'"
55+ # 'encoded token' is the Base64 of the string "nfbot:personal-token"
56+ $auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nfbot:$(GitHubToken)"))))"
57+
58+ cd "$env:Agent_TempDirectory" > $null
59+
60+ Write-Host "Cloning from: $env:BUILD_REPOSITORY_URI"
61+
62+ git clone $env:BUILD_REPOSITORY_URI repo
63+ cd repo > $null
64+ git config --global gc.auto 0
65+ git config --global user.name nfbot
66+ git config --global user.email [email protected] 67+ git config --global core.autocrlf true
68+
69+ Write-Host "Checkout develop branch..."
70+ git checkout --quiet develop > $null
71+
72+ # prepare release and capture output
73+ Write-Host "Prepare release with NBGV..."
74+ $release = nbgv prepare-release -p source
75+
76+ Write-Host "Prepare commit..."
77+ # get commit message for the merge
78+ $commitMessage = git log -1 --pretty=%B
79+
80+ # amend commit message to skip build
81+ git commit --amend -m "$commitMessage" -m "***NO_CI***" > $null
82+
83+ Write-Host "Pushing changes to GitHub..."
84+ # push all changes to github
85+ git -c http.extraheader="AUTHORIZATION : $auth" push --quiet --all origin
86+
87+ # get release branch name
88+ $branch = $release.Split(' ')[0]
89+
90+ Write-Host "Prepare PR..."
91+ # start PR for release
92+ $prRequestBody = @{title="Release $branch";body="";head="$branch";base="master"} | ConvertTo-Json
93+ $githubApiEndpoint = "https://api.github.com/repos/$env:BUILD_REPOSITORY_NAME/pulls"
94+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
95+
96+ $headers = @{}
97+ $headers.Add("Authorization","$auth")
98+ $headers.Add("Accept","application/vnd.github.symmetra-preview+json")
99+
100+ try
101+ {
102+ $result = Invoke-RestMethod -Method Post -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer -Uri $githubApiEndpoint -Header $headers -ContentType "application/json" -Body $prRequestBody
103+ ' Started PR for new release...' | Write-Host -NoNewline
104+ ' OK' | Write-Host -ForegroundColor Green
105+ }
106+ catch
107+ {
108+ $result = $_.Exception.Response.GetResponseStream()
109+ $reader = New-Object System.IO.StreamReader($result)
110+ $reader.BaseStream.Position = 0
111+ $reader.DiscardBufferedData()
112+ $responseBody = $reader.ReadToEnd();
113+
114+ " Error starting PR: $responseBody" | Write-Host -ForegroundColor Red
115+ }
116+ workingDirectory : $(Agent.TempDirectory)
117+ ignoreLASTEXITCODE : true
112118 condition : eq( variables['StartReleaseCandidate'], true )
113119 displayName : NBGV prepare release
114120
@@ -120,13 +126,13 @@ jobs:
120126 - Check_Build_Options
121127
122128 pool :
123- vmImage : ' VS2017-Win2016 '
129+ vmImage : ' windows-2019 '
124130
125131 variables :
126132 DOTNET_SKIP_FIRST_TIME_EXPERIENCE : true
127- buildPlatform : ' Any CPU '
133+ buildPlatform : ' x64 '
128134 buildConfiguration : ' Release'
129- solution : ' source\ nanoFirmwareFlasher.sln'
135+ solution : ' nanoFirmwareFlasher.sln'
130136
131137 steps :
132138
@@ -144,10 +150,10 @@ jobs:
144150 versionSpec : ' 4.9.3'
145151 displayName : ' Install specifc version of NuGet'
146152
147- - task : DotNetCoreInstaller@0
153+ - task : UseDotNet@2
148154 inputs :
149155 packageType : sdk
150- version : 2 .1.500
156+ version : 3 .1.101
151157 displayName : Install .NET Core SDK
152158
153159 - task : DotNetCoreCLI@2
@@ -160,11 +166,11 @@ jobs:
160166 workingDirectory : source
161167 displayName : Restore NuGet packages
162168
163- - script : dotnet build -c $(BuildConfiguration) /p:PublicRelease=true --no-restore /t:build,pack
169+ - script : dotnet build -r win-x64 - c $(BuildConfiguration) /p:PublicRelease=true --no-restore /t:build,pack
164170 workingDirectory : source
165171 displayName : Build NuGet package
166172
167- - script : dotnet build - c $(BuildConfiguration) / p:PublicRelease=true / p:PackGlobalTool=true --no-restore /t:build,pack"
173+ - script : dotnet pack --runtime win-x64 - c $(BuildConfiguration) - p:PublicRelease=true - p:PackGlobalTool=true --no-restore
168174 workingDirectory : source
169175 displayName : Build .NET Core Tool NuGet package
170176
@@ -327,7 +333,7 @@ jobs:
327333 condition : or( failed('Check_Build_Options'), failed('Build_tool') )
328334
329335 pool :
330- vmImage : ' VS2017-Win2016 '
336+ vmImage : ' windows-2019 '
331337
332338 steps :
333339
0 commit comments