AZ-400 · Question #535
AZ-400 Question #535: Real Exam Question with Answer & Explanation
This question tests knowledge of how to publish a .NET NuGet package to GitHub Packages using the dotnet CLI. The command must be constructed correctly to authenticate and push the package to the GitHub Packages registry.
Question
Hotspot Question You have a .NET app named App1. You need to upload App1 to GitHub Packages. How should you complete the command? To answer, select the appropriate options in the answer area. NOTE: Each correct selection is worth one point. Answer:
Options
- __typehotspot
- variantdropdown
Explanation
This question tests knowledge of how to publish a .NET NuGet package to GitHub Packages using the dotnet CLI. The command must be constructed correctly to authenticate and push the package to the GitHub Packages registry.
Approach. To upload a .NET app/package to GitHub Packages, you use the 'dotnet nuget push' command. The full command structure is: 'dotnet nuget push <package>.nupkg --api-key <YOUR_GITHUB_TOKEN> --source github'. First, you must add the GitHub Packages source using 'dotnet nuget add source' with the URL 'https://nuget.pkg.github.com/OWNER/index.json', authenticating with your GitHub Personal Access Token (PAT) that has the 'write:packages' scope. The push subcommand targets the named source (e.g., 'github') and uses the PAT as the API key. The correct command is: 'dotnet nuget push' for the action, 'https://nuget.pkg.github.com/OWNER/index.json' or the named source for the destination, and the PAT token for authentication.
Concept tested. Publishing .NET NuGet packages to GitHub Packages using the dotnet CLI, including proper use of 'dotnet nuget push', GitHub Packages registry URL format, and Personal Access Token (PAT) authentication.
Topics
Community Discussion
No community discussion yet for this question.