Adding Azure Email Service in Core project

 Hello,

Issue : 01

Today I was trying to add Azure Communication Email in my existing entity framework core project but it was giving me some error.


Let me share the issue and its solution :)


Step 1 : I was referring this link https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/email/send-email?pivots=programming-language-csharp


Step 2 : After creating logins and all I was trying to add package to use following namespace

using Azure;
using Azure.Communication.Email;
using Azure.Communication.Email.Models;

Command line for adding package is : dotnet add  package Azure.Communication.Email --prerelease

You can run this command in your Visual studio 2022 project's console

Go to Tools >> Nuget Package Manager > Pckage Manager Console.


Now when you hit this command you will see the below error :

PM> dotnet add package Azure.Communication.Email --prerelease

  Determining projects to restore...

  Writing C:\Users\LENOVO\AppData\Local\Temp\tmpD7EB.tmp

info : X.509 certificate chain validation will use the default trust store selected by .NET.

info : Adding PackageReference for package 'Azure.Communication.Email' into project 'C:\Users\LENOVO\source\repos\NSRCC.GMS.Booking\docker-compose.dcproj'.

error: Error while adding package 'Azure.Communication.Email' to project 'C:\Users\LENOVO\source\repos\NSRCC.GMS.Booking\docker-compose.dcproj'. The project does not support adding package references through the add package command.

Usage: NuGet.CommandLine.XPlat.dll package add [options]


Solution :

Just add project name in your command line 

Old : dotnet add package Azure.Communication.Email --prerelease
New : dotnet add [Projectname] package Azure.Communication.Email --prerelease

In my case my project name is : dotnet add DEMO.TEST.Utilities package Azure.Communication.Email --prerelease

Thank you,

If you have any issues write to me on skahmed.shaikh@gmail.com



Comments