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

Commit f5f0dd9

Browse files
authored
Merge pull request #255 from microsoftgraph/fix/logging-configuration
Fix/logging configuration
2 parents b1433d3 + de5ce71 commit f5f0dd9

4 files changed

Lines changed: 17 additions & 11 deletions

File tree

.azure-pipelines/powershell/BuildTools.psm1

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function Get-ZipName {
1919
[string]
2020
$RuntimeIdentifier = "unknown"
2121
)
22-
$version = Get-Version $BranchOrTagName
22+
$version = Get-Version $BranchOrTagName
2323
return "$FileNameTemplate" -f "$RuntimeIdentifier","$version"
2424
}
2525

@@ -137,11 +137,15 @@ function Compress-SignedFiles {
137137
return
138138
}
139139

140-
if ($ReportDir -and (Test-Path -Path "$ReportDir/*.md")) {
140+
if ($ReportDir -and (Test-Path -Path "$SourceDir/*.md")) {
141+
if (-Not (Test-Path -Path $ReportDir)) {
142+
New-Item $ReportDir -ItemType Directory
143+
}
144+
141145
Write-Information "Moving signing report to $ReportDir"
142-
Move-Item -Path "$SourceDir/*.md" -Destination $ReportDir
146+
Move-Item -Path "$SourceDir/*.md" -Destination $ReportDir/
143147
}
144-
148+
145149
$parentDir = Split-Path -Path $SourceDir -Parent -Resolve
146150
$backupDir = Join-Path -Path $parentDir -ChildPath backup
147151

.azure-pipelines/release-cli.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ stages:
9595
parameters:
9696
vstsFeedName: ${{variables.internalFeed}}
9797

98-
- pwsh: dotnet publish --no-restore --runtime $(rid) --self-contained true --configuration $(buildConfiguration) --output $(outputDir)
98+
- pwsh: dotnet publish ./src/msgraph-cli.csproj --no-restore --runtime $(rid) --self-contained true --configuration $(buildConfiguration) --output $(outputDir)
9999
workingDirectory: $(Build.SourcesDirectory)
100100
displayName: DotNet publish
101101

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ steps:
5252
security import $(agent.tempdirectory)/cert.p12 -k $(agent.tempdirectory)/buildagent.keychain -P "$(graph-cli-apple-developer-certificate-password)" -T /usr/bin/codesign
5353
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k pwd $(agent.tempdirectory)/buildagent.keychain
5454
codesign -s $(CERTIFICATE_NAME) --deep --force --options runtime --entitlements .azure-pipelines/darwin/entitlements.plist $(EXECUTABLE_PATH)/$(EXECUTABLE_NAME)
55+
chmod u+x $(EXECUTABLE_PATH)/$(EXECUTABLE_NAME)
5556
displayName: Set Hardened Entitlements
5657
condition: and(succeeded(), startsWith(variables['TARGET_RUNTIME'], 'osx'))
57-
58+
5859
- script: |
5960
set -e
6061
pushd $(EXECUTABLE_PATH) && zip -r -X $(EXECUTABLE_PATH)/$(ZIP_NAME) * && rm $(EXECUTABLE_NAME) && popd
6162
displayName: Archive build for submission
62-
condition: and(succeeded(), startsWith(variables['TARGET_RUNTIME'], 'osx'))
63+
condition: and(succeeded(), startsWith(variables['TARGET_RUNTIME'], 'osx'))

src/Program.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ static async Task<int> Main(string[] args)
6666

6767
builder.AddMiddleware(async (ic, next) =>
6868
{
69-
var op = ic.GetHost().Services.GetService<IOptions<ExtraOptions>>();
69+
var op = ic.GetHost().Services.GetService<IOptions<ExtraOptions>>()?.Value;
7070
// Show Azure Identity logs if the --debug option is set
71-
using AzureEventSourceListener? listener = AzureEventSourceListener.CreateConsoleLogger(op?.Value?.DebugEnabled == true ? EventLevel.LogAlways : EventLevel.Warning);
71+
using AzureEventSourceListener? listener = op?.DebugEnabled == true ? AzureEventSourceListener.CreateConsoleLogger(EventLevel.LogAlways) : null;
7272
await next(ic);
7373
});
7474
builder.AddMiddleware(async (ic, next) =>
@@ -201,8 +201,9 @@ static IHostBuilder CreateHostBuilder(string[] args) =>
201201
{
202202
logBuilder.SetMinimumLevel(LogLevel.Warning);
203203
// If a config is unavailable, troubleshoot using (ctx.Configuration as IConfigurationRoot)?.GetDebugView();
204-
var options = ctx.GetInvocationContext().BindingContext.GetService<IOptions<ExtraOptions>>()?.Value;
205-
if (options?.DebugEnabled == true)
204+
// At this point, the host isn't ready. Get the config option directly.
205+
var debugEnabled = ctx.Configuration.GetValue<bool>("Debug");
206+
if (debugEnabled == true)
206207
{
207208
logBuilder.AddFilter("Microsoft.Graph.Cli", LogLevel.Debug);
208209
}

0 commit comments

Comments
 (0)