Why is Access to the path '/bin/roslyn' denied?

Cataster 641 Reputation points
2020-12-17T21:17:54.94+00:00

Long story short, I was able to build a bitbucket .NET/MVC/Angular project successfully on windows 2019 azure hosted agent, but I am unable to make it build successfully on ubuntu agent. The reason I want to build it on ubuntu is because I noticed the build time is way faster than that of the windows agent, which makes sense considering the platforms.

I am facing this error:

Copying file from "/home/vsts/work/1/s/Bobby.ProjectA/obj/Debug/Bobby.ProjectA.pdb" to "/home/vsts/work/1/s/Bobby.ProjectA/bin/Bobby.ProjectA.pdb".
CopyRoslynCompilerFilesToOutputDirectory:
Creating directory "/bin/roslyn".
Creating directory "/bin/roslyn".
Creating directory "/bin/roslyn".
Creating directory "/bin/roslyn".

/home/vsts/work/1/s/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8/build/net45/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(17,5):
warning MSB3021: Unable to copy file "/home/vsts/work/1/s/packages/Microsoft.Net.Compilers.2.4.0/build/../tools/csc.exe" to "/bin/roslyn/csc.exe". Access to the path '/bin/roslyn' is denied. [/home/vsts/work/1/s/Bobby.ProjectA/Bobby.ProjectA.csproj]

According to this post, the issue is because the VBCSCompiler is locking the src.

So i have exhausted all of these solutions here, but none of them worked. I also can't restart the ubuntu agent during a build due to CI limitation, and killall VBCSCompiler bash script before msbuild task resulted in this error: VBCSCompiler: no process found

So now i am stumped, if VBCSCompiler process is not even running, why is Access to the path '/bin/roslyn' denied???

Ive also tried updating/installing Microsoft.CodeDom.Providers.DotNetCompilerPlatform package per this post here, but that didnt do/help anything.

if it helps out, here is some information (versions) about the above packages from packages.config file:

<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.8" targetFramework="net471" />
<package id="Microsoft.Net.Compilers" version="2.4.0" targetFramework="net471" developmentDependency="true" />

This is how my build tasks looks like if it helps:

49264-image.png

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,148 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Tianyu Sun-MSFT 27,356 Reputation points Microsoft Vendor
    2020-12-18T09:52:26.56+00:00

    Hello @Cataster ,

    Thank you for taking time to post this issue in Microsoft Q&A forum.

    From your description, actually I am not sure if this issue is really caused by VBCSCompiler, as you got the error: no process found. For this access issue, if, indeed there is no process that using the related resources, then I think this issue may be still a potential issue.

    Actually, if “restart“ could make this warning disappear, I may suggest you check the related references, process, dlls and so on, which may using the resources and cause this warning. But, I noticed that it seems there are some limitations for restarting.

    So, I suggest you

    1). Check the related authority.

    2). Since this may be related to Linux, check if there are some Linux related tools that could help to find and confirm that if this is locked by a specific process…

    3). You can also start a new thread and report this issue directly to VS Product Team in our Developer Community with some reproduced steps or detailed information. If you do report this issue, please share the link here, other forum members, include me, who are interested or meet the same or similar issue can go to vote for this thread.

    Sincerely,
    Tianyu

    • If the answer is helpful, please click "Accept Answer" and upvote it.
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    1 person found this answer helpful.

  2. Cataster 641 Reputation points
    2020-12-25T07:00:34.097+00:00

    @Tianyu Sun-MSFT

    It finally worked! I don't know why removing these lines resolved the VBCSCompiler issue, but by doing so, the msbuild completed successfully on Ubunutu 20 agent!!

    Remove the following lines from the .csproj file:

    <Import Project="..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props')" />  
      
    <Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props'))" />  
    <Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />  
    

    To give some context to the answer, this post here indicated that converting from MSBuild-Integrated Package Restore to Automatic Package Restore (nuget restore task) implied that the Microsoft.Net.Compilers <Import> and <Error Condition> snippets are no longer relevant/needed in the .csproj file.

    1 person found this answer helpful.
    0 comments No comments