Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 99 additions & 88 deletions .azuredevops/pipelines/publish.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
pool:
vmImage: 'windows-latest'

parameters:
- name: PublishPackage
displayName: 'Confirm Publish Package to nuget'
type: boolean
default: false
- name: pushEnvironment
displayName: 'Push to which environment?'
displayName: 'Nuget Environment'
type: string
values:
- Test
- Production
default: Test
- dev
- prod
default: dev

# The build configuration is defined, in this case we are building Release packages
# Based on 'pushEnvironment' parameter, we set other variables and variable groups to use test vs prod settings
variables:
- name: buildConfiguration
value: 'Release'
- name : apiKey
${{ if eq(parameters.pushEnvironment, 'Production') }}:
value: $(nuget-mock-solution-test-automation-api-key)
${{ if ne(parameters.pushEnvironment, 'Production') }}:
value: $(int-nugettest-mock-solution-test-automation-api-key)
- name : nugetOrgSource
${{ if eq(parameters.pushEnvironment, 'Production') }}:
value: 'https://api.nuget.org/v3/index.json'
${{ if ne(parameters.pushEnvironment, 'Production') }}:
value: 'https://apiint.nugettest.org/v3/index.json'
- ${{ if eq(parameters.pushEnvironment, 'Production') }}:
- group: nuget_package_deployment
- ${{ if ne(parameters.pushEnvironment, 'Production') }}:
- group: int_nugettest_package_deployment

# The github-ref-prefix should be either 'tags/' (for a tagged release) or 'heads/' (for a branch). Release number is either the tag name or branch name
# The standard release process would use a tagged release where the tag name is the version number (e.g 1.0.0) so prefix is default 'tags/' and release-number would be '1.0.0'
Expand All @@ -40,72 +23,100 @@ resources:
endpoint: github.com_CDR-CI
ref: refs/$(github-ref-prefix)$(release-number)

# The build has 3 seperate tasks run under 1 step
steps:
- checkout: GitHubRepo
fetchDepth: 0

# Build the project by running the dotnet command build, pointing to our csproj file
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
command: 'build'
versioningScheme: byBuildNumber
arguments: '--configuration $(buildConfiguration) /p:UsingGitHubSource=true'
projects: '$(System.DefaultWorkingDirectory)\Source\**\*.csproj'
stages:
- stage: ${{parameters.pushEnvironment}}
variables:
- group: nuget_package_deployment_${{parameters.pushEnvironment}}
- group: nuget_package_deployment_certificate
- name: buildConfiguration
value: 'Release'
- name : nuget-server-url
${{ if eq(parameters.pushEnvironment, 'prod') }}:
value: 'https://api.nuget.org/v3/index.json'
${{ else }}:
value: 'https://apiint.nugettest.org/v3/index.json'


# Create the package by running the dotnet pack command again pointing to the csproj file
# The nobuild means the project will not be compiled before running pack, because its already built in above step
- task: DotNetCoreCLI@2
displayName: "dotnet pack"
inputs:
command: 'pack'
configuration: $(BuildConfiguration)
packagesToPack: '$(System.DefaultWorkingDirectory)\Source\**\*.csproj'
nobuild: true
versioningScheme: 'off'

- task: PublishSymbols@2
displayName: Publish symbols path
continueOnError: True
inputs:
SearchPattern: '**\bin\**\*.pdb'
PublishSymbols: false
SymbolServerType: TeamServices
pool:
vmImage: 'windows-latest'
jobs:
- job : deploy_${{parameters.pushEnvironment}}

# The build has 3 seperate tasks run under 1 step
steps:
- checkout: GitHubRepo
fetchDepth: 0

- task: DotNetCoreCLI@2
displayName: Install NuGetKeyVaultSignTool
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install --tool-path . NuGetKeyVaultSignTool'
# Build the project by running the dotnet command build, pointing to our csproj file
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
command: 'build'
versioningScheme: byBuildNumber
arguments: '--configuration $(buildConfiguration) /p:UsingGitHubSource=true'
projects: '$(System.DefaultWorkingDirectory)\Source\**\*.csproj'

# Create the package by running the dotnet pack command again pointing to the csproj file
# The nobuild means the project will not be compiled before running pack, because its already built in above step
- task: DotNetCoreCLI@2
displayName: "dotnet pack"
inputs:
command: 'pack'
configuration: $(BuildConfiguration)
packagesToPack: '$(System.DefaultWorkingDirectory)\Source\**\*.csproj'
nobuild: true
versioningScheme: 'off'

- task: PublishSymbols@2
displayName: Publish symbols path
continueOnError: True
inputs:
SearchPattern: '**\bin\**\*.pdb'
PublishSymbols: false
SymbolServerType: TeamServices

- task: DotNetCoreCLI@2
displayName: Install NuGetKeyVaultSignTool
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install --tool-path . NuGetKeyVaultSignTool'

# WARNING: This will not throw an error if it can't find the file and will close silently (false positive)
- task: PowerShell@2
displayName: Signing with NuGetKeyVaultSignTool
inputs:
targetType: 'inline'
script: |
.\NuGetKeyVaultSignTool sign $(Build.ArtifactStagingDirectory)\*.nupkg `
--file-digest "sha256" `
--timestamp-rfc3161 "http://timestamp.digicert.com" `
--timestamp-digest "sha256" `
--azure-key-vault-url $(code-signing-kv-url) `
--azure-key-vault-tenant-id $(code-signing-kv-tenant-id) `
--azure-key-vault-client-id $(sp-code-signing-prod-client-id) `
--azure-key-vault-client-secret $(sp-code-signing-prod-client-secret) `
--azure-key-vault-certificate $(code-signing-cert-name)
# WARNING: This will not throw an error if it can't find the file and will close silently (false positive)
- task: PowerShell@2
displayName: Signing with NuGetKeyVaultSignTool
inputs:
targetType: 'inline'
script: |
.\NuGetKeyVaultSignTool sign $(Build.ArtifactStagingDirectory)\*.nupkg `
--file-digest "sha256" `
--timestamp-rfc3161 "http://timestamp.digicert.com" `
--timestamp-digest "sha256" `
--azure-key-vault-url $(code-signing-kv-url) `
--azure-key-vault-tenant-id $(code-signing-kv-tenant-id) `
--azure-key-vault-client-id $(sp-code-signing-prod-client-id) `
--azure-key-vault-client-secret $(sp-code-signing-prod-client-secret) `
--azure-key-vault-certificate $(code-signing-cert-name)

# NOTE: Avoiding verifying with NuGetKeyVaultSignTool as it is rather faulty. Will give false positive for a file that doesn't exist.
# Use dotnet nuget verify instead
- task: PowerShell@2
displayName: Verifying NuGetKeyVaultSign
inputs:
targetType: 'inline'
script: 'dotnet nuget verify $(Build.ArtifactStagingDirectory)\*.nupkg'

# NOTE: Avoiding verifying with NuGetKeyVaultSignTool as it is rather faulty. Will give false positive for a file that doesn't exist.
# Use dotnet nuget verify instead
- task: PowerShell@2
displayName: Verifying NuGetKeyVaultSign
inputs:
targetType: 'inline'
script: 'dotnet nuget verify $(Build.ArtifactStagingDirectory)\*.nupkg'
- task: PowerShell@2
displayName: 'Publishing to $(nuget-server-url)'
condition: and(succeeded(), eq(${{parameters.PublishPackage}} , true))
inputs:
targetType: 'inline'
script: 'dotnet nuget push $(Build.ArtifactStagingDirectory)\*.nupkg --api-key $(nuget-server-api-key) -n --source $(nuget-server-url)'

- task: PowerShell@2
displayName: Publishing signed package
inputs:
targetType: 'inline'
script: 'dotnet nuget push $(Build.ArtifactStagingDirectory)\*.nupkg --api-key $(apiKey) -n --source $(nugetOrgSource)'
- task: PublishPipelineArtifact@1
displayName: Publish Signed Package
condition: succeeded()
inputs:
path: $(Build.ArtifactStagingDirectory)
artifact: mock-test-automation-solution
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [3.0.0] - 2025-03-19
### Changed
- Fixed multiple build warnings to improve code quality and maintainability.

### Removed
- Removed all OIDC Hybrid Flow related code and functionality.

## [2.0.0] - 2024-08-06
### Changed
- Updated nuget package versions.
Expand Down
3 changes: 2 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Visit our [Responsible disclosure of security vulnerabilities policy](https://ww

| Version | Supported |
| ------- | ------------------ |
| 2.0.x | :white_check_mark: |
| 3.0.x | :white_check_mark: |
| 2.x.x | :x: |
| 1.x.x | :x: |


Expand Down
120 changes: 120 additions & 0 deletions Source/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,123 @@ tab_width = 4
indent_size = 4
end_of_line = crlf
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion

[*.cs]
# complete the task associated to this 'TODO'
dotnet_diagnostic.S1135.severity = none

# documentation missing for a parameter
dotnet_diagnostic.SA1611.severity = none

# Filename should match first type name
dotnet_diagnostic.SA1649.severity = none

# element parameter should have text
dotnet_diagnostic.SA1614.severity = none

# enumeration elements should be documented
dotnet_diagnostic.SA1602.severity = none

# partial elements should be documented
dotnet_diagnostic.SA1601.severity = none

# elements should be documented
dotnet_diagnostic.SA1600.severity = none

# file may only contain a single type
dotnet_diagnostic.SA1402.severity = none

# The public modifier should appear before static
dotnet_diagnostic.SA1206.severity = none

# static members should appear before non-static members
dotnet_diagnostic.SA1204.severity = none

# public members should come before private
dotnet_diagnostic.SA1202.severity = none

# a filed should not follow a property
dotnet_diagnostic.SA1201.severity = none

# code should not contain blank lines at end
dotnet_diagnostic.SA1518.severity = none

# closing brace should be followed by blank line
dotnet_diagnostic.SA1513.severity = none

# element should not be on a single line
dotnet_diagnostic.SA1502.severity = none

# use trailing comma in multi-line intializers
dotnet_diagnostic.SA1413.severity = none

# variable should begin with lower case letter
dotnet_diagnostic.SA1312.severity = none

# field should be private
dotnet_diagnostic.SA1401.severity = none

# element should declare access modifier
dotnet_diagnostic.SA1400.severity = none

# parameter should being with lower-case
dotnet_diagnostic.SA1313.severity = none

# field should begin with upper case
dotnet_diagnostic.SA1307.severity = none

# readonly fields should appear before non-readonly
dotnet_diagnostic.SA1214.severity = none

# constant fields should appear before non-constant fields
dotnet_diagnostic.SA1203.severity = none

# do not use regions
dotnet_diagnostic.SA1124.severity = none

# generic type constraints should be on their own line
dotnet_diagnostic.SA1127.severity = none

# use built-in type alias
dotnet_diagnostic.SA1121.severity = none

# parameters should all be placed on the same line
dotnet_diagnostic.SA1117.severity = none

# parameter spans multiple lines
dotnet_diagnostic.SA1118.severity = none

# parameter should begin on the line after the previous parameter
dotnet_diagnostic.SA1115.severity = none

# code should not contain trailing whitespace
dotnet_diagnostic.SA1028.severity = none

# closing square bracket should be followed by a space
dotnet_diagnostic.SA1011.severity = none

# keyword new should be followed by a space
dotnet_diagnostic.SA1000.severity = none

# opening square brackets should not be preceded by a space
dotnet_diagnostic.SA1010.severity = none

[DataRecipientConsentCallback*.cs]
# remove the unused private method
dotnet_diagnostic.S1144.severity = none

[JwksEndpoint.cs]
# remove the unused private method
dotnet_diagnostic.S1144.severity = none

[Test*.cs]
# Missing xml comment for publicly visible type
dotnet_diagnostic.CS1591.severity = none

[RegisterSSAService.cs]
# remove this useless conditional
dotnet_diagnostic.S3440.severity = none

[DateTimeExtensions.cs]
# use string.Empty for empty strings
dotnet_diagnostic.SA1122.severity = none
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Remove="TestResults\**" />
Expand All @@ -17,6 +18,14 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.5.0.109200">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ public class TestClass1
{
public class Startup
{
//A default startup is required due to the test project inheriting Xunit.DependencyInjection from the Nuget project.
public void ConfigureServices(IServiceCollection services) { }
// A default startup is required due to the test project inheriting Xunit.DependencyInjection from the Nuget project.
public void ConfigureServices(IServiceCollection services)
{
// Method intentionally left empty.
}
}

[Fact]
Expand Down
Loading
Loading