microsoft / BCTech

Business Central technology samples
MIT License
561 stars 300 forks source link

Install-Package in Authenticate.ps1 does not work #117

Open spookymattress opened 2 years ago

spookymattress commented 2 years ago

If I try to install the package "Microsoft.Identity.Client" in the Authenticate.ps1 script in the AdminCenterAPI folder I get this error.

Install-Package : No match was found for the specified search criteria and package name 'Microsoft.Identity.Client'. Try Get-PackageSource to see all available registered package sources.

This sample authenticates to Azure Active Directory (AAD) an obtains an access token.
$aadAppId = "010316e9-9301-496c-8094-0876ae5c34ee"        # partner's AAD app id
$aadAppRedirectUri = "http://localhost"                   # partner's AAD app redirect URI
$aadTenantId = "108983a8-3d0d-4e21-95aa-595dd7ae6c04"     # customer's tenant id

Install-Package -Name Microsoft.Identity.Client -Source nuget.org -ProviderName nuget -SkipDependencies -Destination .\lib # run this line once to download the DLL
Add-Type -Path ".\lib\Microsoft.Identity.Client.4.36.0\lib\net461\Microsoft.Identity.Client.dll"
#Add-Type -Path ".\lib\Microsoft.Identity.Client.4.36.0\lib\netcoreapp2.1\Microsoft.Identity.Client.dll" # enable this line instead if you use 
PowerShell Core (pwsh)
chrishdmicrosoftcom commented 2 years ago

Hi @spookymattress,

My guess is nuget.org isn't registered as a package source on your system (which I believe it is by default, so don't know how come it's not for you).

Try running: Get-PackageSource Is "nuget.org" listed?

If it isn't you can run: Register-PackageSource -Name nuget.org -Location https://api.nuget.org/v3/index.json -ProviderName NuGet And then try again.

Let me know how it goes.

/Christian