PnP Core Component - Add Permission Level To Group in SharePoint 2016

Please refer to the Introduction to PnP Core Component and OfficeDevPnP.Core for more details. I have created a console application and added SharePointPnPCore2016 NuGet package for the SharePoint 2016 version.
 
Code Snippet
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using System.Threading.Tasks;  
  6. using Microsoft.SharePoint.Client;  
  7. using OfficeDevPnP.Core;  
  8. namespace SP2016PnPCoreComponentDemo  
  9. {  
  10. class Program  
  11. {  
  12. static void Main(string[] args)  
  13. {  
  14. // Input Parameters  
  15. string siteUrl = "http://c7395723754/";  
  16. string userName = "administrator";  
  17. string password = "Mf165Nz2WV";  
  18. string domain = "AD2012";  
  19. string groupName = "Group created using PnP";  
  20. string roleDefinitionName = "Design";  
  21. bool removeExistingPermLevel = false;  
  22. OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();  
  23. try  
  24. {  
  25. // Get the client context  
  26. using (var ctx = authMgr.GetNetworkCredentialAuthenticatedContext(siteUrl, userName, password, domain))  
  27. {  
  28. // Add permission level to group  
  29. ctx.Web.AddPermissionLevelToGroup(groupName, roleDefinitionName, removeExistingPermLevel);  
  30. ctx.Web.AddPermissionLevelToGroup(groupName, RoleType.Contributor, removeExistingPermLevel);  
  31. }  
  32. }  
  33. catch (Exception ex)  
  34. {  
  35. Console.WriteLine("Error Message: " + ex.Message);  
  36. }  
  37. }  
  38. }  
  39. }