Skip to content

Commit

Permalink
Merge pull request #1190 from microsoft/dm/vsext
Browse files Browse the repository at this point in the history
Visual Studio Build Targets for OpenAPI Reference
  • Loading branch information
baywet authored May 5, 2022
2 parents 550b1d6 + db57259 commit 8dba4cf
Show file tree
Hide file tree
Showing 36 changed files with 623 additions and 546 deletions.
299 changes: 299 additions & 0 deletions .azure-pipelines/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)

trigger:
tags:
include:
- v*

pool:
name: Azure Pipelines
vmImage: windows-latest

variables:
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
ProductBinPath: '$(Build.SourcesDirectory)\src\kiota\bin\$(BuildConfiguration)'


stages:

- stage: build
jobs:
- job: build
steps:
- task: UseDotNet@2
displayName: 'Use .NET 6'
inputs:
version: 6.x

- task: PoliCheck@1
displayName: 'Run PoliCheck "/src"'
inputs:
inputType: CmdLine
cmdLineArgs: '/F:$(Build.SourcesDirectory)/src /T:9 /Sev:"1|2" /PE:2 /O:poli_result_src.xml'

- task: PoliCheck@1
displayName: 'Run PoliCheck "/tests"'
inputs:
inputType: CmdLine
cmdLineArgs: '/F:$(Build.SourcesDirectory)/tests /T:9 /Sev:"1|2" /PE:2 /O:poli_result_test.xml'

# Install the nuget tool.
- task: NuGetToolInstaller@0
displayName: 'Use NuGet >=6.1.0'
inputs:
versionSpec: '>=6.1.0'
checkLatest: true

# Build the Product project
- task: DotNetCoreCLI@2
displayName: 'build'
inputs:
projects: '$(Build.SourcesDirectory)\kiota.sln'
arguments: '--configuration $(BuildConfiguration) --no-incremental'

# Run the Unit test
- task: DotNetCoreCLI@2
displayName: 'test'
inputs:
command: test
projects: '$(Build.SourcesDirectory)\kiota.sln'
arguments: '--configuration $(BuildConfiguration) --no-build'

# CredScan
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
displayName: 'Run CredScan - Src'
inputs:
toolMajorVersion: 'V2'
scanFolder: '$(Build.SourcesDirectory)\src'
debugMode: false

- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
displayName: 'Run CredScan - Tests'
inputs:
toolMajorVersion: 'V2'
scanFolder: '$(Build.SourcesDirectory)\tests'
debugMode: false

- task: AntiMalware@3
displayName: 'Run MpCmdRun.exe - ProductBinPath'
inputs:
FileDirPath: '$(ProductBinPath)'
enabled: false

- task: BinSkim@3
displayName: 'Run BinSkim - Product Binaries'
inputs:
InputType: Basic
AnalyzeTarget: '$(ProductBinPath)\**\kiota.dll'
AnalyzeSymPath: '$(ProductBinPath)'
AnalyzeVerbose: true
AnalyzeHashes: true
AnalyzeEnvironment: true

- task: PublishSecurityAnalysisLogs@2
displayName: 'Publish Security Analysis Logs'
inputs:
ArtifactName: SecurityLogs

- task: PostAnalysis@1
displayName: 'Post Analysis'
inputs:
BinSkim: true
CredScan: true
PoliCheck: true

- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
displayName: 'ESRP CodeSigning'
inputs:
ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)'
FolderPath: src
signConfigType: inlineSignParams
inlineOperation: |
[
{
"keyCode": "CP-230012",
"operationSetCode": "SigntoolSign",
"parameters": [
{
"parameterName": "OpusName",
"parameterValue": "Microsoft"
},
{
"parameterName": "OpusInfo",
"parameterValue": "http://www.microsoft.com"
},
{
"parameterName": "FileDigest",
"parameterValue": "/fd \"SHA256\""
},
{
"parameterName": "PageHash",
"parameterValue": "/NPH"
},
{
"parameterName": "TimeStamp",
"parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
}
],
"toolName": "sign",
"toolVersion": "1.0"
},
{
"keyCode": "CP-230012",
"operationSetCode": "SigntoolVerify",
"parameters": [ ],
"toolName": "sign",
"toolVersion": "1.0"
}
]
SessionTimeout: 20

# Pack
- pwsh: dotnet pack $(Build.SourcesDirectory)/src/kiota/kiota.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg
displayName: 'pack kiota'

# Pack
- pwsh: nuget pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.Kiota.ApiDescription.Client/Microsoft.OpenApi.Kiota.ApiDescription.Client.nuspec -OutputDirectory $(Build.ArtifactStagingDirectory)
displayName: 'pack targets'

- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
displayName: 'ESRP CodeSigning Nuget Packages'
inputs:
ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)'
FolderPath: '$(Build.ArtifactStagingDirectory)'
Pattern: '*.nupkg'
signConfigType: inlineSignParams
inlineOperation: |
[
{
"keyCode": "CP-401405",
"operationSetCode": "NuGetSign",
"parameters": [ ],
"toolName": "sign",
"toolVersion": "1.0"
},
{
"keyCode": "CP-401405",
"operationSetCode": "NuGetVerify",
"parameters": [ ],
"toolName": "sign",
"toolVersion": "1.0"
}
]
SessionTimeout: 20

- task: PowerShell@2
displayName: "Get Kiota's version-number from .csproj"
inputs:
targetType: 'inline'
script: |
$xml = [Xml] (Get-Content .\src\kiota\kiota.csproj)
$version = $xml.Project.PropertyGroup.Version
echo $version
echo "##vso[task.setvariable variable=kiotaversion]$version"
# publish kiota as an .exe
- pwsh: dotnet publish src/kiota/kiota.csproj -c Release --runtime win-x64 /p:PublishSingleFile=true --self-contained --output $(Build.ArtifactStagingDirectory)/kiota-v$(kiotaversion)
displayName: publish kiota as executable

- task: CopyFiles@2
displayName: Prepare staging folder for upload
inputs:
targetFolder: $(Build.ArtifactStagingDirectory)/Nugets
sourceFolder: $(Build.ArtifactStagingDirectory)
content: '*.nupkg'

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: Nugets'
inputs:
ArtifactName: Nugets
PathtoPublish: '$(Build.ArtifactStagingDirectory)/Nugets'

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: Kiota'
inputs:
ArtifactName: Kiota-v$(kiotaversion)
PathtoPublish: '$(Build.ArtifactStagingDirectory)/Kiota-v$(kiotaversion)'

- stage: deploy
condition: and(contains(variables['build.sourceBranch'], 'refs/tags/v'), succeeded())
dependsOn: build
jobs:
- deployment: deploy_kiota
dependsOn: []
environment: nuget-org
strategy:
runOnce:
deploy:
pool:
vmImage: ubuntu-latest
steps:
- task: DownloadPipelineArtifact@2
displayName: Download nupkg from artifacts
inputs:
artifact: Nugets
source: current
- task: DownloadPipelineArtifact@2
displayName: Download kiota executable from artifacts
inputs:
source: current
- powershell: |
rm "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Kiota.ApiDescription.*.nupkg" -Verbose
displayName: remove other nupkgs to avoid duplication
# - pwsh: |
# $artifactName = Get-ChildItem -Path $(Pipeline.Workspace)\Nugets -Filter Microsoft.OpenApi.Kiota.*.nupkg -recurse | select -First 1
# $artifactVersion= $artifactName.Name -replace "Microsoft.OpenApi.Kiota.", "" -replace ".nupkg", ""
# #Set Variable $artifactName and $artifactVersion
# Write-Host "##vso[task.setvariable variable=artifactVersion; isSecret=false; isOutput=true]$artifactVersion"
# Write-Host "##vso[task.setvariable variable=artifactName; isSecret=false; isOutput=true]$artifactName.FullName"
# echo "$artifactName"
# echo "$artifactVersion"
# displayName: 'Fetch Artifact Name'

- task: NuGetCommand@2
displayName: 'NuGet push'
inputs:
command: push
packagesToPush: '$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Kiota.*.nupkg'
nuGetFeedType: external
publishFeedCredentials: 'OpenAPI Nuget Connection'
# - task: GitHubRelease@1
# displayName: 'GitHub release (create)'
# inputs:
# gitHubConnection: 'Github-MaggieKimani1'
# tagSource: userSpecifiedTag
# tag: '$(artifactVersion)'
# title: '$(artifactVersion)'
# releaseNotesSource: inline
# assets: '$(Pipeline.Workspace)\**\*.exe'
# changeLogType: issueBased

- deployment: deploy_targets
dependsOn: []
environment: nuget-org
strategy:
runOnce:
deploy:
pool:
vmImage: ubuntu-latest
steps:
- task: DownloadPipelineArtifact@2
displayName: Download nupkg from artifacts
inputs:
artifact: Nugets
source: current
- powershell: |
rm "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Kiota.*.nupkg" -Verbose -Exclude "*.ApiDescription.*"
displayName: remove other nupkgs to avoid duplication
- task: NuGetCommand@2
displayName: 'NuGet push'
inputs:
command: push
packagesToPush: '$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Kiota.ApiDescription.*.nupkg'
nuGetFeedType: external
publishFeedCredentials: 'OpenAPI Nuget Connection'

12 changes: 6 additions & 6 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ on:
tags: ['v*']
paths: ['src/**', '.github/workflows/**']
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/generator
REGISTRY: msgraphprod.azurecr.io
IMAGE_NAME: public/${{ github.repository }}/generator
jobs:
push_to_registry:
environment:
name: staging_feeds
name: Push Docker image to GitHub Packages
name: acr
name: Push Docker image
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Login to GitHub package feed
uses: docker/[email protected]
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
registry: ${{ env.REGISTRY }}
- run: |
$version = $Env:BRANCH_NAME -replace "refs/tags/v",""
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

### [0.1.0] - 2022-05-04

### Added

- The dotnet tool is now available on the public feed `dotnet tool install -g Microsoft.OpenApi.Kiota --prerelease`.
- The dotnet OpenApi reference package is now available `Microsoft.OpenApi.Kiota.ApiDescription.Client`.
- The container image is now available on mcr. `docker pull mcr.microsoft.com/kiota/generator:latest`.

### Changed

- Revamped the api surface for request configuration. [#1494](https://github.com/microsoft/kiota/issues/1494)
- Fixed a bug in methods naming in Go after request configuration revamp.
- Fixes a bug where reserved names would not be updated for inheritance.
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ VOLUME /app/output
VOLUME /app/openapi.yml
ENTRYPOINT ["dotnet", "kiota.dll"]
LABEL description="# Welcome to Kiota Generator \
To start generating SDKs checkout [the getting started documentation](https://github.com/microsoft/kiota/#running-kiota-with-docker) \
[Source dockerfile](https://github.com/microsoft/kiota/blob/main/releases/Dockerfile)"
To start generating SDKs checkout [the getting started documentation](https://microsoft.github.io/kiota/get-started/#run-in-docker) \
[Source dockerfile](https://github.com/microsoft/kiota/blob/main/Dockerfile)"
2 changes: 1 addition & 1 deletion docs/get-started/dotnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ parent: Get started

## Target project requirements

Before you can compile and run the generated files, you will need to make sure they are part of a project with the required dependencies. After creating a new project, or reusing an existing one, you will need to add references to the [abstraction](https://github.com/microsoft/kiota/tree/main/abstractions/dotnet), [authentication](https://github.com/microsoft/kiota/tree/main/authentication/dotnet/azure), [http](https://github.com/microsoft/kiota/tree/main/http/dotnet/httpclient), and [serialization](https://github.com/microsoft/kiota/tree/main/serialization/dotnet/json) packages from the GitHub feed.
Before you can compile and run the generated files, you will need to make sure they are part of a project with the required dependencies. After creating a new project, or reusing an existing one, you will need to add references to the [abstraction](https://github.com/microsoft/kiota-abstractions-dotnet), [authentication](https://github.com/microsoft/kiota-authentication-azure-dotnet), [http](https://github.com/microsoft/kiota-http-dotnet), and [JSON](https://github.com/microsoft/kiota-serialization-json-dotnet) and [text](https://github.com/microsoft/kiota-serialization-text-dotnet) serialization packages from the GitHub feed.

## Creating target projects

Expand Down
Loading

0 comments on commit 8dba4cf

Please sign in to comment.