Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.

Commit b77af64

Browse files
authored
Use company Azure Pipelines Template for NuGet Packages (#39)
* Change GitVersion to GitHubFlow * Use company template for NuGet packages * Fix xUnit for multi-targeting with non-Windows OSes * Fix Xunit Tests when targeting .Net Framework * Update documentation * Add icon file and license file to package * Add deterministic build indicator * Embed untracked sources * Add Code Signing
1 parent 6d539e4 commit b77af64

File tree

6 files changed

+170
-61
lines changed

6 files changed

+170
-61
lines changed

GitVersion.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
assembly-versioning-scheme: MajorMinorPatchTag
21
mode: Mainline
3-
branches: {}
4-
ignore:
5-
sha: []
2+
assembly-versioning-scheme: MajorMinorPatch
3+
assembly-file-versioning-format: '{Major}.{Minor}.{Patch}.{env:BUILD_BUILDID ?? 0}'
4+
assembly-informational-format: '{SemVer}+{ShortSha}'
5+
branches:
6+
main:
7+
regex: ^main$
8+
develop:
9+
regex: ^dev$
10+
pull-request:
11+
tag: pr

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![GitHub License](https://img.shields.io/github/license/solidtoken/SpecFlow.DependencyInjection.svg)](https://github.com/solidtoken/SpecFlow.DependencyInjection/blob/main/LICENSE)
44
[![GitHub Issues](https://img.shields.io/github/issues/solidtoken/SpecFlow.DependencyInjection.svg)](https://github.com/solidtoken/SpecFlow.DependencyInjection/issues)
5-
[![Azure Build](https://img.shields.io/azure-devops/build/solidtoken/GitHub/8.svg)](https://solidtoken.visualstudio.com/GitHub/_build/latest?definitionId=8&branchName=main)
5+
[![Azure Build](https://img.shields.io/azure-devops/build/solidtoken/GitHub/20.svg)](https://solidtoken.visualstudio.com/GitHub/_build/latest?definitionId=20&branchName=main)
66
[![NuGet Package](https://img.shields.io/nuget/v/SolidToken.SpecFlow.DependencyInjection.svg)](https://www.nuget.org/packages/SolidToken.SpecFlow.DependencyInjection)
77

88
SpecFlow plugin that enables to use Microsoft.Extensions.DependencyInjection for resolving test dependencies.
@@ -11,8 +11,8 @@ Currently supports:
1111
* [SpecFlow v3.3.30 or later](https://www.nuget.org/packages/SpecFlow/3.3.30)
1212
* [Microsoft.Extensions.DependencyInjection v3.1.5 or later](https://www.nuget.org/packages/Microsoft.Extensions.DependencyInjection/3.1.5)
1313

14+
Based on [SpecFlow.Autofac](https://github.com/gasparnagy/SpecFlow.Autofac).
1415
Listed on [Available Plugins for SpecFlow](https://specflow.org/documentation/Available-Plugins/).
15-
Based on https://github.com/gasparnagy/SpecFlow.Autofac (now [part of SpecFlow](https://github.com/SpecFlowOSS/SpecFlow/tree/master/Plugins/SpecFlow.Autofac.SpecFlowPlugin)).
1616

1717
## Usage
1818

@@ -35,7 +35,6 @@ public static IServiceCollection CreateServices()
3535
var services = new ServiceCollection();
3636

3737
// TODO: add your test dependencies here
38-
// NOTE: since v0.4.0 it's no longer necessary to manually add your [Binding] classes
3938
4039
return services;
4140
}

SpecFlow.DependencyInjection.Tests/SpecFlow.DependencyInjection.Tests.csproj

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,30 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="GitVersionTask" Version="5.5.0" PrivateAssets="All" />
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
12+
<PackageReference Include="GitVersion.MsBuild" Version="5.6.6">
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14+
<PrivateAssets>all</PrivateAssets>
15+
</PackageReference>
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
17+
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="16.7.1" Condition="$(TargetFramework.StartsWith('net4')) AND '$(OS)' == 'Unix'" />
1418
<PackageReference Include="xunit" Version="2.4.1" />
15-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" PrivateAssets="All" />
19+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
20+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21+
<PrivateAssets>all</PrivateAssets>
22+
</PackageReference>
1623
<PackageReference Include="SpecFlow.xUnit" Version="3.4.31" />
24+
<PackageReference Include="coverlet.collector" Version="1.3.0">
25+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
26+
<PrivateAssets>all</PrivateAssets>
27+
</PackageReference>
28+
</ItemGroup>
29+
30+
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">
31+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
1732
</ItemGroup>
1833

1934
<ItemGroup>
2035
<ProjectReference Include="..\SpecFlow.DependencyInjection\SpecFlow.DependencyInjection.csproj" />
2136
</ItemGroup>
2237

23-
</Project>
38+
</Project>

SpecFlow.DependencyInjection/SpecFlow.DependencyInjection.csproj

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,33 @@
66
<RootNamespace>SolidToken.SpecFlow.DependencyInjection</RootNamespace>
77
<AssemblyName>SolidToken.SpecFlow.DependencyInjection.SpecFlowPlugin</AssemblyName>
88
<Description>SpecFlow plugin that enables to use Microsoft.Extensions.DependencyInjection for resolving test dependencies.</Description>
9+
910
<Authors>Solid Token</Authors>
1011
<Company>Solid Token</Company>
1112
<Copyright>Copyright © Solid Token</Copyright>
13+
<PackageIcon>icon.png</PackageIcon>
14+
<PackageIconUrl>https://avatars0.githubusercontent.com/u/413381</PackageIconUrl>
1215
<PackageLicenseExpression>BSD-3-Clause</PackageLicenseExpression>
1316
<PackageProjectUrl>https://github.com/solidtoken/SpecFlow.DependencyInjection</PackageProjectUrl>
14-
<PackageIconUrl>https://avatars0.githubusercontent.com/u/413381</PackageIconUrl>
1517
<PackageTags>microsoft;dependencyinjection;di;specflow;plugin</PackageTags>
18+
1619
<PublishRepositoryUrl>true</PublishRepositoryUrl>
17-
<DebugType>Embedded</DebugType>
18-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
20+
<IncludeSymbols>true</IncludeSymbols>
21+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
22+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
23+
</PropertyGroup>
24+
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">
25+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
1926
</PropertyGroup>
2027
<ItemGroup>
21-
<PackageReference Include="GitVersionTask" Version="5.5.0" PrivateAssets="All" />
28+
<None Include="icon.png" Pack="true" Visible="false" PackagePath="" />
29+
<None Include="../LICENSE" Pack="true" Visibile="false" PackagePath="" />
30+
</ItemGroup>
31+
<ItemGroup>
32+
<PackageReference Include="GitVersion.MsBuild" Version="5.6.6">
33+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
34+
<PrivateAssets>all</PrivateAssets>
35+
</PackageReference>
2236
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.5" />
2337
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
2438
<PackageReference Include="SpecFlow" Version="3.3.30" />
3.63 KB
Loading

azure-pipelines.yml

Lines changed: 121 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,127 @@
1-
# DotNetCore Restore/Build/Test/Pack/Publish
1+
# Azure Pipelines Template for NuGet Packages
2+
# Copyright © Solid Token (https://www.solidtoken.nl)
23

34
variables:
4-
BuildConfiguration: Release
5-
5+
- name: ProjectName
6+
value: 'SpecFlow.DependencyInjection'
7+
- name: TestProjectName
8+
value: 'SpecFlow.DependencyInjection.Tests'
9+
- name: NuGetPackageName
10+
value: 'SolidToken.SpecFlow.DependencyInjection'
11+
- name: NuGetDescription
12+
value: 'SpecFlow plugin that enables to use Microsoft.Extensions.DependencyInjection for resolving test dependencies.'
13+
- name: BuildConfiguration
14+
value: 'Release'
15+
- name: GitHubConnection
16+
value: 'Solid Token GitHub'
17+
- name: NuGetConnection
18+
value: 'Solid Token NuGet'
19+
- group: CodeSigning
20+
621
trigger:
722
- main
823

9-
pool:
10-
vmImage: 'windows-latest'
24+
stages:
25+
- stage: CI
26+
jobs:
27+
- job: Build
28+
steps:
29+
- task: gitversion/setup@0
30+
displayName: 'Prepare'
31+
inputs:
32+
versionSpec: '5.x'
33+
- task: gitversion/execute@0
34+
name: 'Version'
35+
- task: DotNetCoreCLI@2
36+
displayName: 'Build'
37+
inputs:
38+
command: 'build'
39+
projects: '$(ProjectName)'
40+
arguments: '--configuration $(BuildConfiguration)'
41+
- task: DotNetCoreCLI@2
42+
displayName: 'Test'
43+
inputs:
44+
command: 'test'
45+
projects: '$(TestProjectName)'
46+
arguments: '--configuration $(BuildConfiguration) --collect "XPlat Code Coverage"'
47+
- task: DotNetCoreCLI@2
48+
displayName: 'Pack'
49+
inputs:
50+
command: 'pack'
51+
packagesToPack: '$(ProjectName)'
52+
configuration: '$(BuildConfiguration)'
53+
nobuild: true
54+
includesymbols: true
55+
- task: PublishPipelineArtifact@1
56+
displayName: 'Publish'
57+
inputs:
58+
targetPath: '$(Build.ArtifactStagingDirectory)'
59+
artifactName: '$(ProjectName)'
60+
- task: PublishCodeCoverageResults@1
61+
displayName: 'Report'
62+
inputs:
63+
codeCoverageTool: 'Cobertura'
64+
summaryFileLocation: '$(Agent.TempDirectory)/*/coverage.cobertura.xml'
65+
66+
- stage: CD
67+
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
68+
jobs:
69+
- job: Release
70+
variables:
71+
SemVer: $[stageDependencies.CI.Build.outputs['Version.GitVersion.SemVer']]
72+
FullSemVer: $[stageDependencies.CI.Build.outputs['Version.GitVersion.FullSemVer']]
73+
NuGetVersion: $[stageDependencies.CI.Build.outputs['Version.GitVersion.NuGetVersion']]
74+
InformationalVersion: $[stageDependencies.CI.Build.outputs['Version.GitVersion.InformationalVersion']]
75+
steps:
76+
- task: DotNetCoreCLI@2
77+
displayName: 'Prepare'
78+
inputs:
79+
command: 'custom'
80+
custom: 'tool'
81+
arguments: 'install --tool-path . NuGetKeyVaultSignTool'
82+
- task: DownloadPipelineArtifact@2
83+
displayName: 'Download'
84+
inputs:
85+
artifactName: '$(ProjectName)'
86+
- task: PowerShell@2
87+
displayName: 'Sign'
88+
inputs:
89+
targetType: 'inline'
90+
script: |
91+
.\NuGetKeyVaultSignTool sign $(Pipeline.Workspace)/*.nupkg `
92+
--file-digest "sha256" `
93+
--timestamp-rfc3161 "http://timestamp.sectigo.com" `
94+
--timestamp-digest "sha256" `
95+
--azure-key-vault-url "$(azure-key-vault-url)" `
96+
--azure-key-vault-tenant-id "$(azure-key-vault-tenant-id)" `
97+
--azure-key-vault-client-id "$(azure-key-vault-client-id)" `
98+
--azure-key-vault-client-secret "$(azure-key-vault-client-secret)" `
99+
--azure-key-vault-certificate "$(azure-key-vault-certificate)"
100+
- task: NuGetCommand@2
101+
displayName: 'Push'
102+
inputs:
103+
command: 'push'
104+
packagesToPush: '$(Pipeline.Workspace)/*.nupkg'
105+
nuGetFeedType: 'external'
106+
publishFeedCredentials: '$(NuGetConnection)'
107+
includeSymbols: true
108+
- task: GitHubRelease@1
109+
displayName: 'Release'
110+
inputs:
111+
gitHubConnection: '$(GitHubConnection)'
112+
repositoryName: '$(Build.Repository.Name)'
113+
action: 'edit'
114+
target: '$(Build.SourceVersion)'
115+
tagSource: 'userSpecifiedTag'
116+
tag: 'v$(SemVer)'
117+
title: 'v$(FullSemVer)'
118+
assets: '$(Pipeline.Workspace)/*'
119+
releaseNotesSource: 'inline'
120+
releaseNotesInline: |
121+
$(NuGetDescription)
122+
https://www.nuget.org/packages/$(NuGetPackageName)/$(NuGetVersion)
11123
12-
steps:
13-
- task: DotNetCoreCLI@2
14-
displayName: Restore
15-
inputs:
16-
command: restore
17-
- task: DotNetCoreCLI@2
18-
displayName: Build
19-
inputs:
20-
command: build
21-
projects: 'SpecFlow.DependencyInjection'
22-
arguments: '--configuration $(BuildConfiguration)'
23-
- task: DotNetCoreCLI@2
24-
displayName: Test .NET Framework 4.6.1
25-
inputs:
26-
command: test
27-
projects: 'SpecFlow.DependencyInjection.Tests'
28-
arguments: '--configuration $(BuildConfiguration) --framework net461'
29-
- task: DotNetCoreCLI@2
30-
displayName: Test .NET Core 2.1
31-
inputs:
32-
command: test
33-
projects: 'SpecFlow.DependencyInjection.Tests'
34-
arguments: '--configuration $(BuildConfiguration) --framework netcoreapp2.1'
35-
- task: DotNetCoreCLI@2
36-
displayName: Test .NET Core 3.1
37-
inputs:
38-
command: test
39-
projects: 'SpecFlow.DependencyInjection.Tests'
40-
arguments: '--configuration $(BuildConfiguration) --framework netcoreapp3.1'
41-
- task: DotNetCoreCLI@2
42-
displayName: Pack
43-
inputs:
44-
command: pack
45-
packagesToPack: 'SpecFlow.DependencyInjection'
46-
nobuild: true
47-
- task: PublishBuildArtifacts@1
48-
displayName: Publish
49-
inputs:
50-
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
51-
ArtifactName: 'NuGet'
52-
publishLocation: 'Container'
124+
`$(informationalVersion)`
125+
changeLogCompareToRelease: 'lastFullRelease'
126+
changeLogType: 'commitBased'
127+
isDraft: false

0 commit comments

Comments
 (0)