My Dockerfile looks like this:
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS build
WORKDIR /projectName
COPY . .
RUN nuget restore
COPY . .
WORKDIR /repoName/projectName
RUN msbuild ./projectName.csproj /p:Configuration=Debug
Locally, the msbuild step gives me no problems. Without a .dockerignore file, the build fails:
Process is terminated due to StackOverflowException.
When I add a .dockerignore file that looks like this...
./.git
./.idea
./.vs
./gen
./packages
./irrelevantProject1
./irrelevantProject2
# etc
...the build fails again, but with a different error message:
CompilerServer: server failed - server rejected the request 'Error reading response: Reached end of stream before end of read.' - b6c5574e-55ea-4d7d-adb3-e156ebd65296
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(71,5): error MSB6006: "csc.exe" exited with code -2146232797. [C:\repoName\projectName\projectName.csproj]
Done Building Project "C:\repoName\projectName\projectName.csproj" (default targets) -- FAILED.
Build FAILED.
"C:\repoName\projectName\projectName.csproj" (default target) (1) ->
(CoreCompile target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(71,5): error MSB6006: "csc.exe" exited with code -2146232797. [C:\repoName\projectName\projectName.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:31.66
The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; msbuild ./projectName.csproj /p:Configuration=Debug' returned a non-zero code: 1
I've been stuck on this problem for days. Any advice would be greatly appreciated.