小编典典

Could not find a part of the path … bin\roslyn\csc.exe

c#

I am trying to run Asp.net MVC project retrieved from TFS source control. I
have added all assembly references and I am able to build and compile
successfully without any error or warning.

But I get the following error in the browser:

Could not find a part of the path
‘C:\B8akWorkspace\B8akProject\B8akSolution\B8AK.Portal\bin\roslyn\csc.exe’.

Here is a full screenshot of the error page.

enter image description
here

After few days of research, I understood that
Roslyn is .Net compiler platform that offers
advance compiling features. However, I do not understand why my build is
trying to find \bin\roslyn\csc.exe because I did not configure anything
related to Roslyn nor I intend to use Roslyn in my project.


阅读 698

收藏
2020-05-19

共1个答案

小编典典

The problem with the default VS2015 templates is that the compiler isn’t
actually copied to the tfr\bin\roslyn\ directory, but rather the
{outdir}\roslyn\ directory

Add this code in your .csproj file:

<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>
2020-05-19