Could not find a part of the path … bin\roslyn\csc.exe. Error while setting up of OAuth implicit 2.0 API for PowerApps portal

IF you are not aware of OAuth 2.0 Implicit grant for PowerApps portal, I suggest you refer this Microsoft Docs link.

To put in Microsoft words –

“This feature allows a customer to make client-side calls to external APIs and secure them by using OAuth implicit grant flow. It provides an endpoint to obtain secure access tokens that will contain user identity information to be used by external APIs for authorization following OAuth 2.0 implicit grant flow. The identity information of a signed-in user is passed in a secured manner to the external AJAX calls. This will not only help developers to pass authentication context but will also help users to secure their APIs by using this mechanism”.

The docs link is pretty extensive to make your understand the various nuances of this concept. My blog talks about a specific issue which you may encounter when you try to download the sample API from this link – https://github.com/microsoft/PowerApps-Samples/tree/master/portals/ExternalWebApiConsumingPortalOAuthTokenSample and try to build the same.

When you build you may get the following error – Could not find a part of the path … bin\roslyn\csc.exe

Trust me if you are not aware on how to resolve this, you may waste significant time of the day in trying to build the project instead of getting it up and running the wonderful feature.

So basically there are two ways to resolve this.

Uninstall the Nuget packages

1. Microsoft.CodeDom.Providers.DotNetCompilerPlatform
2. Microsoft.Net.Compilers

After you do this, find references of compiler tag in your web.config

<system.codedom>
     <compilers>
       <compiler language=”c#;cs;csharp” extension=”.cs” type=”Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, ……….”></compiler>
       <compiler language=”vb;vbs;visualbasic;vbscript” …………></compiler>
     </compilers>
</system.codedom>

If you find this, simply delete it. This should get you up and running.

If you ask me, this is workaround and not really a good solution. This is because you can’t use the new compiler and new features. The other way is

copying file from “<your path>\packages\Microsoft.Net.Compilers.1.3.2\tools\csi.exe” to “bin\Debug\roslyn\csi.exe”. This is an easier and simple way to do it and your Sample API would be up and running.

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Notes Manager (https://debajmecrm.com/add-metadata-to-your-notes-and-attachments-in-dynamics-notes-metadata-manager-from-xrmforyou-com/)

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)