Skip to content

Commit 2ac2d72

Browse files
committed
Work CI-CD
- Move projects to package reference. - Add SourceLink to project. - Update nuspec. - Rework Azure Pipelines yaml to use PR labels to flag build options. - Rework update dependencies PS1 to use dotnet tool.
1 parent 8e59558 commit 2ac2d72

File tree

10 files changed

+135
-107
lines changed

10 files changed

+135
-107
lines changed
File renamed without changes.

MetadataProcessor.Console/MetadataProcessor.Console.csproj

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,6 @@
3939
</PropertyGroup>
4040
<ItemGroup>
4141
<Reference Include="Microsoft.CSharp" />
42-
<Reference Include="Mono.Cecil, Version=0.11.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
43-
<HintPath>..\packages\Mono.Cecil.0.11.1\lib\net40\Mono.Cecil.dll</HintPath>
44-
</Reference>
45-
<Reference Include="Mono.Cecil.Mdb, Version=0.11.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
46-
<HintPath>..\packages\Mono.Cecil.0.11.1\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
47-
</Reference>
48-
<Reference Include="Mono.Cecil.Pdb, Version=0.11.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
49-
<HintPath>..\packages\Mono.Cecil.0.11.1\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
50-
</Reference>
51-
<Reference Include="Mono.Cecil.Rocks, Version=0.11.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
52-
<HintPath>..\packages\Mono.Cecil.0.11.1\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
53-
</Reference>
5442
<Reference Include="System" />
5543
<Reference Include="System.XML" />
5644
</ItemGroup>
@@ -61,12 +49,16 @@
6149
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
6250
<ItemGroup>
6351
<None Include="app.config" />
64-
<None Include="packages.config" />
6552
</ItemGroup>
6653
<ItemGroup>
6754
<ProjectReference Include="..\MetadataProcessor.Core\MetadataProcessor.Core.csproj">
6855
<Project>{e32f7d15-2499-440c-8026-4d5ee1c5ec3a}</Project>
6956
<Name>MetadataProcessor.Core</Name>
7057
</ProjectReference>
7158
</ItemGroup>
59+
<ItemGroup>
60+
<PackageReference Include="Mono.Cecil">
61+
<Version>0.11.1</Version>
62+
</PackageReference>
63+
</ItemGroup>
7264
</Project>

MetadataProcessor.Console/packages.config

Lines changed: 0 additions & 4 deletions
This file was deleted.

MetadataProcessor.Core/MetadataProcessor.Core.csproj

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
34
<PropertyGroup>
45
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
56
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,6 +12,10 @@
1112
<TargetFrameworkProfile />
1213
<NuGetPackageImportStamp>
1314
</NuGetPackageImportStamp>
15+
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
16+
<Deterministic>true</Deterministic>
17+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
18+
<ContinuousIntegrationBuild Condition="'$(TF_BUILD)' == 'true'">True</ContinuousIntegrationBuild>
1419
</PropertyGroup>
1520
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1621
<DebugSymbols>true</DebugSymbols>
@@ -40,21 +45,6 @@
4045
</PropertyGroup>
4146
<ItemGroup>
4247
<Reference Include="Microsoft.CSharp" />
43-
<Reference Include="Mono.Cecil, Version=0.11.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
44-
<HintPath>..\packages\Mono.Cecil.0.11.1\lib\net40\Mono.Cecil.dll</HintPath>
45-
</Reference>
46-
<Reference Include="Mono.Cecil.Mdb, Version=0.11.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
47-
<HintPath>..\packages\Mono.Cecil.0.11.1\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
48-
</Reference>
49-
<Reference Include="Mono.Cecil.Pdb, Version=0.11.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
50-
<HintPath>..\packages\Mono.Cecil.0.11.1\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
51-
</Reference>
52-
<Reference Include="Mono.Cecil.Rocks, Version=0.11.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
53-
<HintPath>..\packages\Mono.Cecil.0.11.1\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
54-
</Reference>
55-
<Reference Include="mustache-sharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5885df51f4df0041, processorArchitecture=MSIL">
56-
<HintPath>..\packages\mustache-sharp.1.0.0\lib\net45\mustache-sharp.dll</HintPath>
57-
</Reference>
5848
<Reference Include="System" />
5949
<Reference Include="System.Drawing" />
6050
<Reference Include="System.Numerics" />
@@ -127,16 +117,26 @@
127117
</ItemGroup>
128118
<ItemGroup>
129119
<None Include="key.snk" />
130-
<None Include="packages.config" />
131120
<Compile Include="SkeletonGenerator\SkeletonTemplates.cs" />
121+
<None Include="packages.lock.json" />
122+
</ItemGroup>
123+
<ItemGroup>
124+
<PackageReference Include="Microsoft.SourceLink.GitHub">
125+
<Version>1.0.0</Version>
126+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
127+
<PrivateAssets>all</PrivateAssets>
128+
</PackageReference>
129+
<PackageReference Include="Mono.Cecil">
130+
<Version>0.11.1</Version>
131+
</PackageReference>
132+
<PackageReference Include="mustache-sharp">
133+
<Version>1.0.0</Version>
134+
</PackageReference>
135+
<PackageReference Include="Nerdbank.GitVersioning">
136+
<Version>3.3.37</Version>
137+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
138+
<PrivateAssets>all</PrivateAssets>
139+
</PackageReference>
132140
</ItemGroup>
133-
<ItemGroup />
134141
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
135-
<Import Project="..\packages\Nerdbank.GitVersioning.3.3.37\build\Nerdbank.GitVersioning.targets" Condition="Exists('..\packages\Nerdbank.GitVersioning.3.3.37\build\Nerdbank.GitVersioning.targets')" />
136-
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
137-
<PropertyGroup>
138-
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
139-
</PropertyGroup>
140-
<Error Condition="!Exists('..\packages\Nerdbank.GitVersioning.3.3.37\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Nerdbank.GitVersioning.3.3.37\build\Nerdbank.GitVersioning.targets'))" />
141-
</Target>
142142
</Project>

MetadataProcessor.Core/package.nuspec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111
</description>
1212
<releaseNotes>
1313
</releaseNotes>
14-
<summary>
15-
Metadata Processor tool to be used internally by the VS nanoFramework extension.
16-
</summary>
1714
<projectUrl>https://github.com/nanoframework/metadata-processor</projectUrl>
18-
<iconUrl>https://secure.gravatar.com/avatar/97d0e092247f0716db6d4b47b7d1d1ad</iconUrl>
15+
<icon>images\nf-logo.png</icon>
16+
<license type="file">LICENSE.md</license>
1917
<requireLicenseAcceptance>false</requireLicenseAcceptance>
20-
<licenseUrl>https://github.com/nanoframework/metadata-processor/LICENSE</licenseUrl>
18+
<repository type="git" url="https://github.com/nanoframework/metadata-processor" commit="$commit$" />
2119
<copyright>Copyright (c) .NET Foundation and Contributors</copyright>
2220
<references></references>
2321
<tags>nanoFramework, nano Framework, NETNF, NETMF, Micro Framework, .net</tags>
@@ -29,5 +27,7 @@
2927
<files>
3028
<file src="bin\Release\nanoFramework.Tools.MetadataProcessor.Core.dll" target="lib/net461" />
3129
<file src="nanoFramework.Tools.MetaDataProcessor.Core.targets" target="build" />
30+
<file src="..\nf-logo.png" target="images\" />
31+
<file src="..\LICENSE.md" target="" />
3232
</files>
3333
</package>

MetadataProcessor.Core/packages.config

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"version": 1,
3+
"dependencies": {
4+
".NETFramework,Version=v4.7.2": {
5+
"Microsoft.SourceLink.GitHub": {
6+
"type": "Direct",
7+
"requested": "[1.0.0, )",
8+
"resolved": "1.0.0",
9+
"contentHash": "aZyGyGg2nFSxix+xMkPmlmZSsnGQ3w+mIG23LTxJZHN+GPwTQ5FpPgDo7RMOq+Kcf5D4hFWfXkGhoGstawX13Q==",
10+
"dependencies": {
11+
"Microsoft.Build.Tasks.Git": "1.0.0",
12+
"Microsoft.SourceLink.Common": "1.0.0"
13+
}
14+
},
15+
"Mono.Cecil": {
16+
"type": "Direct",
17+
"requested": "[0.11.1, )",
18+
"resolved": "0.11.1",
19+
"contentHash": "RWBcccuMn8gxAasJxBBAb848qkt3S2t/7bEaEXtxQU6ROv1v0p7kk3+Xga4G+k+bKbLBla1bsrUt+8pAccaDwQ=="
20+
},
21+
"mustache-sharp": {
22+
"type": "Direct",
23+
"requested": "[1.0.0, )",
24+
"resolved": "1.0.0",
25+
"contentHash": "+RTxWGLH5p0ibl7XDbb8pOznAdqwxH3zic40eL1gq5xl8jZt3CFc04KSLLFWM3PgvlTzfbzDJfjzF7rCglqGAA=="
26+
},
27+
"Nerdbank.GitVersioning": {
28+
"type": "Direct",
29+
"requested": "[3.3.37, )",
30+
"resolved": "3.3.37",
31+
"contentHash": "YlDKV/gSHQGDThWSGqVyPfKeNP/kx1fj/NPFFgGc/cxzgIbXv4jtYOcbFOz3ZIeAKtpCcSAmVNDOikBs3OxI/A=="
32+
},
33+
"Microsoft.Build.Tasks.Git": {
34+
"type": "Transitive",
35+
"resolved": "1.0.0",
36+
"contentHash": "z2fpmmt+1Jfl+ZnBki9nSP08S1/tbEOxFdsK1rSR+LBehIJz1Xv9/6qOOoGNqlwnAGGVGis1Oj6S8Kt9COEYlQ=="
37+
},
38+
"Microsoft.SourceLink.Common": {
39+
"type": "Transitive",
40+
"resolved": "1.0.0",
41+
"contentHash": "G8DuQY8/DK5NN+3jm5wcMcd9QYD90UV7MiLmdljSJixi3U/vNaeBKmmXUqI4DJCOeWizIUEh4ALhSt58mR+5eg=="
42+
}
43+
},
44+
".NETFramework,Version=v4.7.2/win": {},
45+
".NETFramework,Version=v4.7.2/win-x64": {},
46+
".NETFramework,Version=v4.7.2/win-x86": {}
47+
}
48+
}

azure-pipelines.yml

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ resources:
1919
jobs:
2020

2121
##############################
22-
- job: Get_Build_Options
22+
- job: Get_Build_Flags
2323
pool:
2424
vmImage: 'VS2017-Win2016'
2525

@@ -30,44 +30,48 @@ jobs:
3030
# get commit message
3131
- powershell: |
3232
33-
if($env:System_PullRequest_PullRequestId -ne $null)
34-
{
35-
# PR build, get PR message
36-
37-
# need to get PR number from branch as the Azure Pipeline var can't be trusted
38-
if($env:Build_SourceBranch -match '(?<=(pull\/))\w*(?=(\/))')
39-
{
40-
$prNumber = $matches[0]
41-
42-
$prUrl = "https://api.github.com/repos/$env:Build_Repository_Name/pulls/$prNumber"
43-
44-
$commit = Invoke-RestMethod -Uri $prUrl -ContentType "application/json" -Method GET
33+
# default to false
34+
$update = $false
4535
46-
$commitMessage = $commit.body
47-
}
36+
if($env:Build_Reason -eq 'PullRequest')
37+
{
38+
# PR build, nothing interesting in commit message
4839
}
4940
else
5041
{
51-
# not a PR, get subject and commit message for commit
52-
$commitMessage = git log --format='%B' -1
53-
}
42+
# build is not from a PR
43+
44+
# get commit ID
45+
$commitId = git rev-parse HEAD
46+
47+
# get PR associate with commit
48+
$prUrl = "https://api.github.com/repos/nanoframework/metadata-processor/commits/$commitId/pulls"
49+
$commit = Invoke-RestMethod -Uri $prUrl -ContentType "application/json" -Headers @{"Accept"="application/vnd.github.groot-preview+json"} -Method GET
5450
55-
# need to flatten message by removing new lines
56-
$commitMessage = $commitMessage -replace "`r`n", " "
51+
if($commit -ne $null)
52+
{
53+
# there is a PR, check labels
54+
$updateDependents = $commit.labels | where {$_.Name -eq 'CI: Update Dependents'}
55+
if($updateDependents -ne $null)
56+
{
57+
$update = $true
58+
}
59+
}
60+
}
5761
5862
# set variable to foward to jobs
59-
echo "##vso[task.setvariable variable=COMMIT_MESSAGE;isOutput=true]$commitMessage"
63+
echo "##vso[task.setvariable variable=RUN_UPDATE_DEPENDENTS;isOutput=true]$update"
6064
name: GetCommitMessage
61-
displayName: grab commit message
65+
displayName: Check build labels
6266
6367
##############################
6468

6569
# build MDP
6670
- job: Build_MDP
67-
condition: not( or( contains(dependencies.Get_Build_Options.outputs['GetCommitMessage.COMMIT_MESSAGE'], '***UPDATE_DEPENDENTS***'), eq(variables['UPDATE_DEPENDENTS'], 'true') ) )
71+
condition: not( or( eq(dependencies.Get_Build_Flags.outputs['RUN_UPDATE_DEPENDENTS'], 'true'), eq(variables['UPDATE_DEPENDENTS'], 'true') ) )
6872

6973
dependsOn:
70-
- Get_Build_Options
74+
- Get_Build_Flags
7175

7276
pool:
7377
vmImage: 'VS2017-Win2016'
@@ -91,17 +95,17 @@ jobs:
9195
displayName: Setup git identity
9296
9397
- task: NuGetToolInstaller@0
94-
inputs:
95-
versionSpec: '5.4.0'
9698
condition: not(variables['StartReleaseCandidate'])
9799
displayName: 'Install specific version of NuGet'
100+
inputs:
101+
versionSpec: '5.4.0'
98102

99103
- task: NuGetCommand@2
104+
displayName: NuGet restore
100105
inputs:
101106
restoreSolution: '$(solution)'
102107
feedsToUse: config
103108
nugetConfigPath: 'NuGet.config'
104-
displayName: NuGet restore
105109

106110
- task: VSBuild@1
107111
inputs:
@@ -111,48 +115,48 @@ jobs:
111115
configuration: '$(buildConfiguration)'
112116

113117
- task: CopyFiles@1
118+
condition: succeeded()
119+
displayName: Collecting deployable artifacts
114120
inputs:
115121
sourceFolder: $(Build.SourcesDirectory)
116122
Contents: |
117123
**\bin\Release\nanoFramework.Tools.MetaDataProcessor.exe
118124
TargetFolder: '$(Build.ArtifactStagingDirectory)'
119125
flattenFolders: true
120-
condition: succeeded()
121-
displayName: Collecting deployable artifacts
122126

123127
# update could build number (only possible if this is not a PR from a fork)
124128
- task: PowerShell@2
129+
condition: and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
130+
displayName: Update cloud build number
125131
inputs:
126132
targetType: 'inline'
127133
script: Write-Host "$("##vso[build.updatebuildnumber]")$env:NBGV_NuGetPackageVersion"
128-
condition: and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
129-
displayName: Update cloud build number
130134

131135
- task: NuGetCommand@2
136+
condition: succeeded()
137+
displayName: Pack NuGet witj MDP tool
132138
inputs:
133139
command: 'custom'
134-
arguments: 'pack MetadataProcessor.Core\package.nuspec -Version $(NBGV_NuGetPackageVersion)'
135-
condition: succeeded()
136-
displayName: Pack NuGet for MDP tool
140+
arguments: 'pack MetadataProcessor.Core\package.nuspec -Version $(NBGV_NuGetPackageVersion) -properties commit="$(Build.SourceVersion)"'
137141

138142
- task: CopyFiles@1
143+
condition: succeeded()
144+
displayName: Collecting NuGet package artifact
139145
inputs:
140146
sourceFolder: $(Build.SourcesDirectory)
141147
Contents: |
142148
**\nanoFramework*.nupkg
143149
TargetFolder: '$(Build.ArtifactStagingDirectory)'
144150
flattenFolders: true
145-
condition: succeeded()
146-
displayName: Collecting NuGet package artifact
147151

148152
# publish artifacts (only possible if this is not a PR originated on a fork)
149153
- task: PublishBuildArtifacts@1
154+
condition: and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
155+
displayName: Publish deployables artifacts
150156
inputs:
151157
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
152158
ArtifactName: deployables
153159
ArtifactType: Container
154-
condition: and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
155-
displayName: Publish deployables artifacts
156160

157161
# push NuGet packages to Azure Artifacts feed (always happens except on PR builds)
158162
- task: NuGetCommand@2
@@ -188,10 +192,10 @@ jobs:
188192

189193
##############################
190194
- job: Update_Dependents
191-
condition: or( contains(dependencies.Get_Build_Options.outputs['GetCommitMessage.COMMIT_MESSAGE'], '***UPDATE_DEPENDENTS***'), eq(variables['UPDATE_DEPENDENTS'], 'true') )
195+
condition: or( eq(dependencies.Get_Build_Flags.outputs['RUN_UPDATE_DEPENDENTS'], 'true'), eq(variables['UPDATE_DEPENDENTS'], 'true') )
192196

193197
dependsOn:
194-
- Get_Build_Options
198+
- Get_Build_Flags
195199
- Build_MDP
196200

197201
pool:

0 commit comments

Comments
 (0)