Skip to content

Commit

Permalink
Changes needed to sign nuget packages (#230)
Browse files Browse the repository at this point in the history
* Switch to Nerdbank.GitVersioning
* Modify pipeline to sign packages
* Make separate build pipeline for CI which signs
  • Loading branch information
mconnew committed Sep 30, 2020
1 parent b24d178 commit 96b3ed2
Show file tree
Hide file tree
Showing 14 changed files with 435 additions and 277 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Expand Up @@ -268,3 +268,9 @@ Session.vim
# Private test configuration and binaries.
config.ps1
**/IISApplications

#dotnet local tool install folder
.store/

#SignClient - prevent adding the signing client if locally installed
SignClient.exe
23 changes: 11 additions & 12 deletions Directory.Build.props
Expand Up @@ -4,15 +4,14 @@
<ProjectDir>$(MSBuildThisFileDirectory)</ProjectDir>
<SourceDir>$(ProjectDir)src/</SourceDir>
<ConfigPathSegment>Debug</ConfigPathSegment>
<ConfigPathSegment Condition="'$(Configuration)'!=''">$(Configuration)</ConfigPathSegment>
<ConfigPathSegment Condition="'$(Configuration)'!=''">$(Configuration)</ConfigPathSegment>
<!-- Output directories -->
<BinDir Condition="'$(BinDir)'==''">$(ProjectDir)bin/</BinDir>
<ObjDir Condition="'$(ObjDir)'==''">$(ProjectDir)bin/obj/</ObjDir>
<BaseIntermediateOutputPath>$(ObjDir)/$(MSBuildProjectName)/</BaseIntermediateOutputPath>
<MSBuildProjectExtensionsPath>$(BaseIntermediateOutputPath)</MSBuildProjectExtensionsPath>
<ProjectAssetsFile>$(BaseIntermediateOutputPath)/project.assets.json</ProjectAssetsFile>
</PropertyGroup>

<!-- Set up some common paths -->
<PropertyGroup>
<CommonPath>$(SourceDir)Common/src</CommonPath>
Expand All @@ -21,27 +20,30 @@
<IsSampleProject>$(ParentFolder.EndsWith(`Samples`, true, null))</IsSampleProject>
<IsTestProject>$(MSBuildProjectName.EndsWith(`Tests`, true, null))</IsTestProject>
</PropertyGroup>

<!-- Set up the default output and intermediate paths -->
<PropertyGroup>
<OutputPath Condition="'$(OutputPath)'==''">$(BinDir)$(ConfigPathSegment)/$(MSBuildProjectName)/</OutputPath>
<IntermediateOutputRootPath Condition="'$(IntermediateOutputRootPath)' == ''">$(BaseIntermediateOutputPath)</IntermediateOutputRootPath>
<IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == ''">$(IntermediateOutputRootPath)$(MSBuildProjectName)/</IntermediateOutputPath>
</PropertyGroup>

<!-- Disable the default embedded resource behavior as we have a naming convention which is different than what the SDK uses -->
<PropertyGroup>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
</PropertyGroup>


<!-- Git versioning related items and properties -->
<PropertyGroup>
<GitVersionBaseDirectory>$(MSBuildThisFileDirectory)</GitVersionBaseDirectory>
</PropertyGroup>
<ItemGroup Condition="!($(IsTestProject) OR $(IsSampleProject))">
<PackageReference Include="GitVersionTask" Version="5.3.7">
<PrivateAssets>All</PrivateAssets>
<PackageReference Include="Nerdbank.GitVersioning">
<Version>3.2.31</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<!-- Include license file in packages -->
<Content Include="$(ProjectDir)LICENSE" Pack="true" PackagePath="\" />
</ItemGroup>

<PropertyGroup Condition="!($(IsTestProject) OR $(IsSampleProject))">
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
Expand All @@ -50,13 +52,10 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<RepositoryUrl>https://github.com/CoreWCF/CoreWCF</RepositoryUrl>
</PropertyGroup>

<PropertyGroup Condition="$(IsTestProject) AND '$(CollectCoverage)' == 'true'">
<CoverletOutput Condition="'$(CoverletOutputDir)' != '' AND '$(CoverletOutput)' == ''">$(CoverletOutputDir)/$(MSBuildProjectName).xml</CoverletOutput>
<CoverletOutputFormat Condition="'$(CoverletOutputFormat)' == ''">cobertura</CoverletOutputFormat>
<CoverletOutputFormat Condition="'$(CoverletOutputFormat)' == ''">cobertura</CoverletOutputFormat>
</PropertyGroup>

<Import Project="$(ProjectDir)resources.props" Condition="Exists('$(ProjectDir)resources.props')" />

<Import Project="$(ProjectDir)nuspec.props" Condition="!($(IsTestProject) OR $(IsSampleProject)) AND Exists('$(ProjectDir)nuspec.props')" />
</Project>
8 changes: 0 additions & 8 deletions GitVersion.yml

This file was deleted.

31 changes: 31 additions & 0 deletions azure-pipelines-ci.yml
@@ -0,0 +1,31 @@
trigger:
branches:
include:
- master
- release/*
paths:
include:
- src/
exclude:
- src/Samples/

variables:
_solution: 'src/CoreWCF.sln'
_libraryProjects: 'src/CoreWCF.*/src/CoreWCF.*.csproj'
_testProjects: '**/*.Tests.csproj'
disable.coverage.autogenerate: 'true'

stages:
- template: templates/BuildStage.yml
parameters:
buildProjects: $(_libraryProjects)

- template: templates/TestStage.yml
parameters:
testProjects: $(_testProjects)

- template: templates/PackStage.yml
parameters:
packProjects: $(_libraryProjects)

- template: templates/PublishStage.yml
266 changes: 10 additions & 256 deletions azure-pipelines.yml
@@ -1,5 +1,8 @@
trigger:
trigger: none

pr:
- master
- release/*

variables:
_solution: 'src/CoreWCF.sln'
Expand All @@ -8,259 +11,10 @@ variables:
disable.coverage.autogenerate: 'true'

stages:
- stage: Build
displayName: Build
jobs:
- job: Build
strategy:
matrix:
Release:
_buildConfig: 'Release'
Debug:
_buildConfig: 'Debug'
pool:
vmImage: 'windows-latest'
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: 3.1.x
installationPath: $(Agent.ToolsDirectory)/dotnet

# GitVersion task broken as of 2019-12-10. See https://github.com/GitTools/GitVersion/issues/1855
# Installing the GitVersion tool and running it directly as a workaround
- task: DotNetCoreCLI@2
displayName: 'Install gitversion'
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install -g gitversion.tool --version 5.3.7'

- task: DotNetCoreCLI@2
displayName: 'Gitversion setup'
inputs:
command: 'custom'
custom: 'gitversion'
arguments: '/output buildserver'

- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: 'build'
projects: $(_libraryProjects)
arguments: '--configuration $(_buildConfig) /t:restore'
- template: templates/BuildStage.yml
parameters:
buildProjects: $(_libraryProjects)

- task: DotNetCoreCLI@2
displayName: Build $(_buildConfig)
inputs:
command: 'build'
projects: $(_libraryProjects)
arguments: '--no-restore --configuration $(_buildConfig)'
- publish: $(System.DefaultWorkingDirectory)/bin
artifact: $(_buildConfig)Build

- stage: Test
displayName: Run Tests
dependsOn: Build
jobs:
- job: TestRelease
strategy:
matrix:
Windows_netcore2.1:
imageName: 'windows-latest'
targetFramework: 'netcoreapp2.1'
testArgs: ''
Windows_netcore3.1:
imageName: 'windows-latest'
targetFramework: 'netcoreapp3.1'
testArgs: ''
Windows_netfx:
imageName: 'windows-latest'
targetFramework: 'net472'
testArgs: ''
Linux_netcore2.1:
imageName: 'ubuntu-latest'
targetFramework: 'netcoreapp2.1'
testArgs: '--filter Category!=WindowsOnly'
Linux_netcore3.1:
imageName: 'ubuntu-latest'
targetFramework: 'netcoreapp3.1'
testArgs: '--filter Category!=WindowsOnly'
displayName: Test Release
pool:
vmImage: $(imageName)
steps:
- task: DownloadPipelineArtifact@2
displayName: Download build artifacts
inputs:
source: current
artifact: ReleaseBuild
path: $(System.DefaultWorkingDirectory)/bin
- task: DotNetCoreCLI@2
displayName: Restore packages
inputs:
command: 'build'
projects: $(_testProjects)
arguments: '--configuration Release /t:restore'
- task: DotNetCoreCLI@2
displayName: Build test projects
inputs:
command: 'build'
projects: $(_testProjects)
arguments: '--configuration Release --framework $(targetFramework)'
- task: DotNetCoreCLI@2
displayName: Run Tests
timeoutInMinutes: 5
inputs:
command: 'test'
projects: $(_testProjects)
publishTestResults: true
arguments: '--no-restore --no-build --configuration Release --framework $(targetFramework) $(testArgs)'
- job: TestDebug
strategy:
matrix:
Windows_netcore2.1:
imageName: 'windows-latest'
targetFramework: 'netcoreapp2.1'
testArgs: ''
Windows_netcore3.1:
imageName: 'windows-latest'
targetFramework: 'netcoreapp3.1'
testArgs: ''
Windows_netfx:
imageName: 'windows-latest'
targetFramework: 'net472'
testArgs: ''
Linux_netcore2.1:
imageName: 'ubuntu-latest'
targetFramework: 'netcoreapp2.1'
testArgs: '--filter Category!=WindowsOnly'
Linux_netcore3.1:
imageName: 'ubuntu-latest'
targetFramework: 'netcoreapp3.1'
testArgs: '--filter Category!=WindowsOnly'
displayName: Test Debug
pool:
vmImage: $(imageName)
steps:
- task: DownloadPipelineArtifact@2
displayName: Download build artifacts
inputs:
source: current
artifact: DebugBuild
path: $(System.DefaultWorkingDirectory)/bin
- task: DotNetCoreCLI@2
displayName: Restore packages
inputs:
command: 'build'
projects: $(_testProjects)
arguments: '--configuration Debug /t:restore'
- task: DotNetCoreCLI@2
displayName: Build test projects
inputs:
command: 'build'
projects: $(_testProjects)
arguments: '--configuration Debug --framework $(targetFramework)'
- task: DotNetCoreCLI@2
displayName: Run Tests
timeoutInMinutes: 5
inputs:
command: 'test'
projects: $(_testProjects)
publishTestResults: true
arguments: '--no-restore --no-build --configuration Debug --framework $(targetFramework) $(testArgs)'
- job: CodeCoverage
displayName: Code Coverage
pool:
vmImage: 'windows-latest'
dependsOn:
- TestDebug
- TestRelease
steps:
- script: set PATH=%PATH%;%USERPROFILE%\.dotnet\tools
displayName: Add dotnet tools folder to path
- task: DotNetCoreCLI@2
displayName: 'Install ReportGenerator'
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install -g dotnet-reportgenerator-globaltool --version 4.6.1'
- task: DownloadPipelineArtifact@2
displayName: Download build artifacts
inputs:
source: current
artifact: ReleaseBuild
path: $(System.DefaultWorkingDirectory)/bin
- task: DotNetCoreCLI@2
displayName: Restore packages
inputs:
command: 'build'
projects: $(_testProjects)
arguments: '--configuration Release /t:restore'
- task: DotNetCoreCLI@2
displayName: Build test projects
inputs:
command: 'build'
projects: $(_testProjects)
arguments: '--configuration Release --framework netcoreapp3.1'
- task: DotNetCoreCLI@2
displayName: Run Tests with Coverage
timeoutInMinutes: 10
inputs:
command: 'test'
projects: $(_testProjects)
publishTestResults: true
arguments: '--no-restore --no-build --configuration Release --framework netcoreapp3.1 /p:CollectCoverage=true /p:CoverletOutputDir=$(Build.ArtifactStagingDirectory)/Coverage'
- script: reportgenerator "-reports:$(Build.ArtifactStagingDirectory)/Coverage/*.xml" "-targetdir:$(Build.ArtifactStagingDirectory)/Coverage/Report" -reporttypes:HtmlInline_AzurePipelines;Cobertura;Badges
displayName: 'Generate Coverage Report'
- task: PublishCodeCoverageResults@1
displayName: Publish Code Coverage report
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: $(Build.ArtifactStagingDirectory)/Coverage/Report/Cobertura.xml
# To make the task not regenerate the report an environment variable was added to the pipeline in Azure DevOps; "disable.coverage.autogenerate: 'true'"
# see: https://github.com/danielpalme/ReportGenerator/wiki/Integration#attention
reportDirectory: $(Build.ArtifactStagingDirectory)/Coverage/Report/
- stage: Pack
dependsOn: Test
displayName: Create Packages
condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual'))
jobs:
- job: Pack
pool:
vmImage: 'windows-latest'
steps:
- task: DownloadPipelineArtifact@2
displayName: Download build artifacts
inputs:
source: current
artifact: ReleaseBuild
path: $(System.DefaultWorkingDirectory)/bin
- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: 'build'
projects: $(_libraryProjects)
arguments: '--configuration Release /t:restore'
- task: DotNetCoreCLI@2
displayName: Create packages
inputs:
command: 'pack'
configurationToPack: Release
searchPatternPack: $(_libraryProjects)
outputDir: '$(Build.ArtifactStagingDirectory)/Packages'
nobuild: true
includesymbols: true
arguments: '--no-restore'
- task: NuGetAuthenticate@0
displayName: NuGet Authenticate
- task: NuGetCommand@2
displayName: 'NuGet push'
inputs:
command: push
feedPublish: 'CoreWCF/CoreWCF'
verbosityPush: Detailed
packagesToPush: '$(Build.ArtifactStagingDirectory)/Packages/*.*'
allowPackageConflicts: true
publishPackageMetadata: true
- template: templates/TestStage.yml
parameters:
testProjects: $(_testProjects)

0 comments on commit 96b3ed2

Please sign in to comment.