samhowes / rules_msbuild

Build .csproj files with Bazel
Apache License 2.0
6 stars 3 forks source link

UseSharedCompilation=false likely causes a slower build #35

Open samhowes opened 3 years ago

samhowes commented 3 years ago

I saw the message

Using shared compilation with compiler from directory: /home/sam/.cache/bazel/_bazel_sam/c0ab60a4963be8b657cd35acdb19a608/external/dotnet_sdk/sdk/3.1.100/Roslyn/bincore

From the binlog on az ubuntu when a build failed.

This led to this SO post: https://stackoverflow.com/questions/47590068/what-means-the-using-shared-compilation-with-compiler-from-directory-messag

Setting UseSharedCompilation to false got the build to succeed, but apparently slows down the build. As such, this issue can be closed, and a new optimization issue can be opened.

What's happening is the MSBuild property UseSharedCompilation is being set to false. As such we are not using the compiler server and you're paying the JIT cost for CSC on every build. That is the reason for the slow down.

_Originally posted by @samhowes in https://github.com/samhowes/my_rules_dotnet/issues/33#issuecomment-809529789_

samhowes commented 2 years ago

The csc build process that gets started appears to not have permissions to write the the desired directories in the sandboxes on linux:

CSC : error CS2012: Cannot open '/home/vsts/.cache/bazel/_bazel_vsts/5c27df7f718ab35828b0e0cfe0993663/sandbox/linux-sandbox/62/execroot/rules_msbuild/bazel-out/k8-fastbuild/bin/tests/examples/Grpc/Protos/obj/netcoreapp3.1/Protos.Net.dll' for writing -- 'Read-only file system'

I think [persistent workers](https://docs.bazel.build/versions/main/persistent-workers.html_ is actually the intended solution for situations like this