system.io.directorynotfoundexception could not find a part of the path roslyn csc.exe code example

Example 1: Could not find file \bin\roslyn\csc.exe

//Run this in package manager console
Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -r

Example 2: roslyn csc.exe visual studio 2017

<Target Name="CopyRoslynFiles" AfterTargets="AfterBuild" Condition="!$(Disable_CopyWebApplication) And '$(OutDir)' != '$(OutputPath)'">
    <ItemGroup>
      <RoslynFiles Include="$(CscToolPath)\*" />
    </ItemGroup>
    <MakeDir Directories="$(WebProjectOutputDir)\bin\roslyn" />
    <Copy SourceFiles="@(RoslynFiles)" DestinationFolder="$(WebProjectOutputDir)\bin\roslyn" SkipUnchangedFiles="true" Retries="$(CopyRetryCount)" RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" />
</Target>

Tags:

Misc Example