Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit 71e5447

Browse files
authored
Dotnet tool (#312)
* Add nuget dotnet tool pipeline
1 parent fd75568 commit 71e5447

File tree

8 files changed

+293
-29
lines changed

8 files changed

+293
-29
lines changed

.azure-pipelines/powershell/BuildTools.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ function Compress-BuildOutput {
372372
if ($Cleanup) {
373373
foreach ($path in $Source) {
374374
Write-Verbose "Compress-BuildOutput: Cleaning up $path"
375-
Remove-Item $path -Force
375+
Remove-Item $path -Force -Recurse
376376
}
377377
}
378378

.azure-pipelines/release-cli.yaml

Lines changed: 212 additions & 19 deletions
Large diffs are not rendered by default.

.azure-pipelines/templates/compliance-checks.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,27 @@ steps:
5050
path: $(artifactsDownloadLocation)
5151
displayName: Download binaries
5252

53+
- pwsh: |
54+
Write-Verbose 'Checking if there are files matching $(artifactsDownloadLocation)/build-output-*/*.zip'
55+
$hasArtifacts = Test-Path $(artifactsDownloadLocation)/build-output-*/*.zip -PathType Leaf
56+
Write-Verbose "Result $hasArtifacts"
57+
Write-Host "##vso[task.setvariable variable=HAS_ARTIFACTS]$hasArtifacts"
58+
displayName: Checking for binaries
59+
5360
- ${{ if gt(length(parameters.artifactsDownloadLocation), 0) }}:
5461
- pwsh: |
5562
Get-ChildItem $(artifactsDownloadLocation)/build-output-*/*.zip | ForEach-Object -Begin $null -End $null -Process { Write-Host "Extracting $($_.FullName)" }, { Expand-Archive -LiteralPath "$($_.FullName)" -PassThru }, { Remove-Item "$($_.FullName)" }
5663
Get-ChildItem $(artifactsDownloadLocation)/build-output-* -Recurse
5764
workingDirectory: $(artifactsDownloadLocation)
5865
displayName: Extracting binaries
66+
condition: and(succeeded(), eq(variables['HAS_ARTIFACTS'], 'true'))
5967
- ${{ else }}:
6068
- pwsh: |
6169
Get-ChildItem $(Pipeline.Workspace)/build-output-*/*.zip | ForEach-Object -Begin $null -End $null -Process { Write-Host "Extracting $($_.FullName)" }, { Expand-Archive -LiteralPath "$($_.FullName)" -PassThru }, { Remove-Item "$($_.FullName)" }
6270
Get-ChildItem $(Pipeline.Workspace)/build-output-* -Recurse
6371
workingDirectory: $(artifactsDownloadLocation)
6472
displayName: Extracting binaries
65-
73+
condition: and(succeeded(), eq(variables['HAS_ARTIFACTS'], 'true'))
6674
6775
- task: AntiMalware@4
6876
displayName: 'Run MpCmdRun.exe - Product Binaries'
@@ -72,7 +80,7 @@ steps:
7280
FileDirPath: $(artifactsDownloadLocation)
7381
${{ else }}:
7482
FileDirPath: $(Pipeline.Workspace)
75-
83+
condition: and(succeeded(), eq(variables['HAS_ARTIFACTS'], 'true'))
7684

7785
- task: BinSkim@4
7886
displayName: 'Run BinSkim - Product Binaries'
@@ -88,16 +96,19 @@ steps:
8896
AnalyzeHashes: true
8997
AnalyzeRecurse: true
9098
AnalyzeStatistics: true
99+
condition: and(succeeded(), eq(variables['HAS_ARTIFACTS'], 'true'))
91100

92101
- task: PublishSecurityAnalysisLogs@3
93102
displayName: 'Publish Security Analysis Logs'
94103
enabled: true
95104
inputs:
96105
ArtifactName: CodeAnalysisLogs
97106
AllTools: true
107+
condition: and(succeeded(), eq(variables['HAS_ARTIFACTS'], 'true'))
98108

99109
- task: PostAnalysis@2
100110
displayName: 'Post Analysis'
101111
enabled: true
102112
inputs:
103113
GdnBreakAllTools: true
114+
condition: and(succeeded(), eq(variables['HAS_ARTIFACTS'], 'true'))

.azure-pipelines/templates/nuget-packages.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,22 @@ parameters:
1111
- name: extraRestoreArgs
1212
type: "string"
1313
default:
14+
- name: enabled
15+
type: string
16+
default: 'true'
1417

1518
steps:
1619
- pwsh: |
1720
Write-Verbose -Verbose "useCache = '${{parameters.useCache}}'"
1821
Write-Verbose -Verbose "restorePath = '${{parameters.restorePath}}'"
1922
Write-Verbose -Verbose "extraRestoreArgs = '${{parameters.extraRestoreArgs}}'"
23+
Write-Verbose -Verbose "enabled = '${{parameters.enabled}}'"
2024
displayName: Testing parameters
2125
26+
- pwsh: |
27+
Write-Host "##vso[task.setvariable variable=IS_ENABLED]${{ parameters.enabled }}"
28+
displayName: Initialize parameters
29+
2230
- ${{ if eq(parameters.useCache, true) }}:
2331
- task: Cache@2
2432
displayName: 'Load NuGet Cache'
@@ -28,6 +36,7 @@ steps:
2836
nuget | "$(Agent.OS)"
2937
nuget
3038
path: '${{parameters.restorePath}}'
39+
condition: and(succeeded(), eq(variables['IS_ENABLED'], 'true'))
3140
- task: DotNetCoreCLI@2
3241
displayName: Restore packages (Cache enabled)
3342
inputs:
@@ -39,6 +48,7 @@ steps:
3948
workingDirectory: $(Build.SourcesDirectory)
4049
restoreArguments: --use-lock-file --locked-mode ${{parameters.extraRestoreArgs}}
4150
restoreDirectory: ${{parameters.restorePath}}
51+
condition: and(succeeded(), eq(variables['IS_ENABLED'], 'true'))
4252
- ${{ else }}:
4353
- task: DotNetCoreCLI@2
4454
displayName: Restore packages (No cache)
@@ -50,4 +60,5 @@ steps:
5060
includeNuGetOrg: true
5161
workingDirectory: $(Build.SourcesDirectory)
5262
noCache: true
53-
restoreArguments: --use-lock-file --locked-mode ${{parameters.extraRestoreArgs}}
63+
restoreArguments: --use-lock-file --locked-mode ${{parameters.extraRestoreArgs}}
64+
condition: and(succeeded(), eq(variables['IS_ENABLED'], 'true'))

.azure-pipelines/templates/prepare-unsigned-executable-darwin.yaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,27 @@ parameters:
1414
- name: targetRuntime
1515
type: "string"
1616
default: ''
17+
- name: enabled
18+
type: string
19+
default: 'false'
1720

1821
# Assumptions:
1922
# The built zip has been downloaded already
2023
steps:
24+
- pwsh: |
25+
Write-Host "##vso[task.setvariable variable=IS_ENABLED]${{ parameters.enabled }}"
26+
displayName: Check enabled
27+
condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'True'))
28+
2129
- pwsh: |
2230
Write-Host "##vso[task.setvariable variable=TARGET_RUNTIME]${{ parameters.targetRuntime }}"
2331
Write-Host "##vso[task.setvariable variable=CERTIFICATE_NAME]${{ parameters.certificateName }}"
2432
Write-Host "##vso[task.setvariable variable=EXECUTABLE_PATH]${{ parameters.executablePath }}"
2533
Write-Host "##vso[task.setvariable variable=EXECUTABLE_NAME]${{ parameters.executableName }}"
2634
Write-Host "##vso[task.setvariable variable=ZIP_NAME]${{ parameters.zipName }}"
2735
displayName: Resolve parameters
36+
condition: and(succeeded(), eq(variables['IS_ENABLED'], 'true'), eq(variables['SHOULD_SIGN'], 'True'))
37+
2838
- task: PowerShell@2
2939
inputs:
3040
pwsh: true
@@ -39,15 +49,15 @@ steps:
3949
debugPreference: '$(OUTPUT_PREFERENCE)'
4050
informationPreference: '$(OUTPUT_PREFERENCE)'
4151
displayName: Validate executable path location
42-
condition: and(succeeded(), startsWith(variables['TARGET_RUNTIME'], 'osx'))
52+
condition: and(succeeded(), eq(variables['IS_ENABLED'], 'true'), eq(variables['SHOULD_SIGN'], 'True'), startsWith(variables['TARGET_RUNTIME'], 'osx'))
4353

4454
- task: AzureKeyVault@2
4555
displayName: "Azure Key Vault: Get Secrets"
4656
inputs:
4757
azureSubscription: "MicrosofGraphKeyVault connection"
4858
KeyVaultName: MicrosofGraphKeyVault
4959
SecretsFilter: "graph-cli-apple-developer-certificate,graph-cli-apple-developer-certificate-password"
50-
condition: and(succeeded(), startsWith(variables['TARGET_RUNTIME'], 'osx'))
60+
condition: and(succeeded(), eq(variables['IS_ENABLED'], 'true'), eq(variables['SHOULD_SIGN'], 'True'), startsWith(variables['TARGET_RUNTIME'], 'osx'))
5161

5262
# Setting hardened entitlements is a requirement for Apple notarization
5363
- script: |
@@ -60,10 +70,10 @@ steps:
6070
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k pwd $(agent.tempdirectory)/buildagent.keychain
6171
codesign -s $(CERTIFICATE_NAME) --deep --force --options runtime --entitlements .azure-pipelines/darwin/entitlements.plist $(EXECUTABLE_PATH)/$(EXECUTABLE_NAME)
6272
displayName: Set Hardened Entitlements
63-
condition: and(succeeded(), startsWith(variables['TARGET_RUNTIME'], 'osx'))
73+
condition: and(succeeded(), eq(variables['IS_ENABLED'], 'true'), eq(variables['SHOULD_SIGN'], 'True'), startsWith(variables['TARGET_RUNTIME'], 'osx'))
6474
6575
- script: |
6676
set -e
6777
pushd $(EXECUTABLE_PATH) && zip -r -X $(EXECUTABLE_PATH)/$(ZIP_NAME) * && rm $(EXECUTABLE_NAME) && popd
6878
displayName: Archive build for submission
69-
condition: and(succeeded(), startsWith(variables['TARGET_RUNTIME'], 'osx'))
79+
condition: and(succeeded(), eq(variables['IS_ENABLED'], 'true'), eq(variables['SHOULD_SIGN'], 'True'), startsWith(variables['TARGET_RUNTIME'], 'osx'))

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ insert_final_newline = true
1414
[*.{y[a]ml,json}]
1515
indent_size = 2
1616

17+
[*.csproj]
18+
indent_size = 2
19+
1720
# VSCode generates files with 4 spaces
1821
[.vscode/*.json]
1922
indent_size = 4

src/35MSSharedLib1024.snk

160 Bytes
Binary file not shown.

src/msgraph-cli.csproj

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,44 @@
1111
</PropertyGroup>
1212

1313
<PropertyGroup>
14-
<PublishSingleFile>true</PublishSingleFile>
14+
<PublishSingleFile>false</PublishSingleFile>
1515
<SelfContained>false</SelfContained>
16-
<PublishReadyToRun>true</PublishReadyToRun>
16+
<PublishReadyToRun>false</PublishReadyToRun>
1717
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64;osx-arm64</RuntimeIdentifiers>
1818
<PublishAot>false</PublishAot>
1919
</PropertyGroup>
2020

21+
<PropertyGroup>
22+
<Description>
23+
Microsoft Graph CLI SDK provides convenient methods to access Microsoft
24+
Graph capabilities using a simplistic command line interface experience on any operating
25+
system and any shell.
26+
</Description>
27+
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
28+
<AssemblyTitle>Microsoft Graph CLI tool</AssemblyTitle>
29+
<PackAsTool>true</PackAsTool>
30+
<PackageIconUrl>https://go.microsoft.com/fwlink/?LinkID=288890</PackageIconUrl>
31+
<PackageProjectUrl>https://github.com/microsoftgraph/msgraph-cli</PackageProjectUrl>
32+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
33+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
34+
<PackageReadmeFile>README.md</PackageReadmeFile>
35+
<ToolCommandName>mgc</ToolCommandName>
36+
<Authors>Microsoft</Authors>
37+
<Company>Microsoft</Company>
38+
<PackageId>Microsoft.Graph.Cli</PackageId>
39+
<PackageOutputPath>./nupkg</PackageOutputPath>
40+
<Deterministic>true</Deterministic>
41+
<AssemblyOriginatorKeyFile>../35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
42+
<SignAssembly>false</SignAssembly>
43+
<DelaySign>false</DelaySign>
44+
45+
<PackageReleaseNotes>
46+
https://github.com/microsoftgraph/msgraph-cli/releases
47+
</PackageReleaseNotes>
48+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
49+
<RepositoryUrl>https://github.com/microsoftgraph/msgraph-cli</RepositoryUrl>
50+
</PropertyGroup>
51+
2152
<PropertyGroup>
2253
<DefaultExcludesInProjectFolder>$(DefaultItemExcludes);**/*.sample.*</DefaultExcludesInProjectFolder>
2354
</PropertyGroup>
@@ -29,4 +60,9 @@
2960
<PackageReference Include="Microsoft.Graph.Cli.Core" Version="1.0.0-preview.1" />
3061
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
3162
</ItemGroup>
63+
64+
<ItemGroup>
65+
<None Include="../LICENSE" Pack="true" PackagePath="" />
66+
<None Include="../README.md" Pack="true" PackagePath="" />
67+
</ItemGroup>
3268
</Project>

0 commit comments

Comments
 (0)