msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

Building inside a container fails with MSB3026 / MSB3027

Open nguerrera opened this issue 9 years ago • 7 comments

From @oyosefi on June 7, 2017 23:4

Trying to build a sample dotnetcore API inside an SDK container:

Created a container and mounted a local folder (docker run -v c:/docker:c:/docker -it --rm --memory 9072 microsoft/dotnet:2.0-sdk).

Created an app using dotnet new webapi. dotnet restore works fine. dotnet build sometimes works. dotnet publish -c Release -o out` mostly fails with:

C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\Microsoft.Common.CurrentVersion.targets(3993,5): warning MSB3026: Coul d not copy "obj\Debug\netcoreapp2.0\playground.dll" to "bin\Debug\netcoreapp2.0\playground.dll". Beginning retry 1 in 10 00ms. The data area passed to a system call is too small [C:\docker\playground\playground.csproj] C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\Microsoft.Common.CurrentVersion.targets(3993,5): warning MSB3026: Coul d not copy "obj\Debug\netcoreapp2.0\playground.dll" to "bin\Debug\netcoreapp2.0\playground.dll". Beginning retry 2 in 10 00ms. The data area passed to a system call is too small [C:\docker\playground\playground.csproj] C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\Microsoft.Common.CurrentVersion.targets(3993,5): warning MSB3026: Coul d not copy "obj\Debug\netcoreapp2.0\playground.dll" to "bin\Debug\netcoreapp2.0\playground.dll". Beginning retry 3 in 10 00ms. The data area passed to a system call is too small [C:\docker\playground\playground.csproj] C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\Microsoft.Common.CurrentVersion.targets(3993,5): warning MSB3026: Coul d not copy "obj\Debug\netcoreapp2.0\playground.dll" to "bin\Debug\netcoreapp2.0\playground.dll". Beginning retry 4 in 10 00ms. The data area passed to a system call is too small [C:\docker\playground\playground.csproj] C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\Microsoft.Common.CurrentVersion.targets(3993,5): warning MSB3026: Coul d not copy "obj\Debug\netcoreapp2.0\playground.dll" to "bin\Debug\netcoreapp2.0\playground.dll". Beginning retry 5 in 10 00ms. The data area passed to a system call is too small [C:\docker\playground\playground.csproj] C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\Microsoft.Common.CurrentVersion.targets(3993,5): warning MSB3026: Coul d not copy "obj\Debug\netcoreapp2.0\playground.dll" to "bin\Debug\netcoreapp2.0\playground.dll". Beginning retry 6 in 10 00ms. The data area passed to a system call is too small [C:\docker\playground\playground.csproj] C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\Microsoft.Common.CurrentVersion.targets(3993,5): warning MSB3026: Coul d not copy "obj\Debug\netcoreapp2.0\playground.dll" to "bin\Debug\netcoreapp2.0\playground.dll". Beginning retry 7 in 10 00ms. The data area passed to a system call is too small [C:\docker\playground\playground.csproj] C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\Microsoft.Common.CurrentVersion.targets(3993,5): warning MSB3026: Coul d not copy "obj\Debug\netcoreapp2.0\playground.dll" to "bin\Debug\netcoreapp2.0\playground.dll". Beginning retry 8 in 10 00ms. The data area passed to a system call is too small [C:\docker\playground\playground.csproj] C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\Microsoft.Common.CurrentVersion.targets(3993,5): warning MSB3026: Coul d not copy "obj\Debug\netcoreapp2.0\playground.dll" to "bin\Debug\netcoreapp2.0\playground.dll". Beginning retry 9 in 10 00ms. The data area passed to a system call is too small [C:\docker\playground\playground.csproj] C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\Microsoft.Common.CurrentVersion.targets(3993,5): warning MSB3026: Coul d not copy "obj\Debug\netcoreapp2.0\playground.dll" to "bin\Debug\netcoreapp2.0\playground.dll". Beginning retry 10 in 1 000ms. The data area passed to a system call is too small [C:\docker\playground\playground.csproj] C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\Microsoft.Common.CurrentVersion.targets(3993,5): error MSB3027: Could not copy "obj\Debug\netcoreapp2.0\playground.dll" to "bin\Debug\netcoreapp2.0\playground.dll". Exceeded retry count of 1 0. Failed. [C:\docker\playground\playground.csproj] C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\Microsoft.Common.CurrentVersion.targets(3993,5): error MSB3021: Unable to copy file "obj\Debug\netcoreapp2.0\playground.dll" to "bin\Debug\netcoreapp2.0\playground.dll". The data area passed to a system call is too small [C:\docker\playground\playground.csproj] 10 Warning(s) 2 Error(s)

Any suggestions?

Copied from original issue: dotnet/sdk#1319

nguerrera avatar Jun 08 '17 15:06 nguerrera

Similar to https://github.com/Microsoft/msbuild/issues/2153, but this time from a search on "The data area passed to a system call is too small" it appears to be a low-level issue on a Windows rather than Linux container.

@stephentoub Thoughts?

nguerrera avatar Jun 08 '17 15:06 nguerrera

Quick note. In my case I worked around the issue by adding --memory 2048**mb** : docker run -v c:/docker:c:/docker -it --rm --memory 2048mb microsoft/dotnet:2.0-sdk Not sure why I would need to allocate 2GB to build an empty dotnet core app, but at least it worked

OriYosefiMSFT avatar Jun 08 '17 17:06 OriYosefiMSFT

@stephentoub Thoughts?

Hmm, I've not see that error before. Do you have a call stack? It sounds like it simply doesn't have enough memory. What's the default unit if no unit is supplied on the --memory flag as is done in the original example "--memory 9072"? If the default is bytes or kilobytes such that this is either 9K or 9MB, I could certainly imagine that being too little such that various things could go wrong.

stephentoub avatar Jun 09 '17 12:06 stephentoub

hmmm... failed for the same reason... allocate more memory does not solve it... (even allocate for 4Gb...) (╯‵□′)╯︵┻━┻

YiMysty avatar Aug 24 '17 23:08 YiMysty

I am experiencing the same problem building a .NET Core app inside of a container.

In my case, I am using Bower to restore a wwwroot directory in my project. I am then running a gulp build and copying additional files into the directory. The RUN dotnet publish ... step in my Dockerfile is failing.

I have tried many iterations and diagnostic directory listings and haven't found a solution, yet. Here is an example error:

/usr/share/dotnet/sdk/2.0.0/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Publish.targets(109,5): warning MSB3026: Could not copy "/src/My/Web/App/wwwroot/lib/jquery/AUTHORS.txt" to "bin/Release/netcoreapp2.0/publish/wwwroot/lib/jquery/AUTHORS.txt". Beginning retry 1 in 1000ms. Could not find a part of the path '/src/My/Web/App/bin/Release/netcoreapp2.0/publish/wwwroot/lib/jquery/AUTHORS.txt'. [/src/My/Web/App/My.Web.App.csproj]

This happens regardless of how I try to perform the copy. I have tried setting EnableDefaultContentItems to false and manually including <Content Include="wwwroot\**"> and I get the same error from a different source.

/usr/share/dotnet/sdk/2.0.0/Microsoft.Common.CurrentVersion.targets(4436,5): warning MSB3026: Could not copy "/src/My/Web/App/wwwroot/lib/jquery/AUTHORS.txt" to "bin/Release/netcoreapp2.0/wwwroot/lib/jquery/AUTHORS.txt". Beginning retry 2 in 1000ms. Could not find a part of the path '/src/My/Web/App/bin/Release/netcoreapp2.0/wwwroot/lib/jquery/AUTHORS.txt'. [/src/My/Web/App/My.Web.App.csproj]

Another difference (aside from the target source) is that the former example fails copying to the publish directory while this fails coping to the Release directory.

I have verified that the source files are present and the destination directories exist. In both cases, the parent of the destination wwwroot directories exist (i.e., the bin/Release/... directory), but the wwwroot directory itself does not exist. All directories are marked as root so it doesn't appear to be a permissions issue.

toddlucas avatar Nov 09 '17 01:11 toddlucas

Hi @toddlucas, did you manage to fix your problem? I'm in same situation and I have no idea where the problem might be. In my situation, the docker image builds properly locally, but fails in CI.

Euphoric avatar Jun 11 '19 08:06 Euphoric

Hi @Euphoric, I found a workaround and have been using that ever since I encountered the issue. I haven't tried since then to see if it's fixed for my scenario. Here is the workaround I use.

ARG DOTNETCORE_CONFIGURATION=Release
ENV PUBLISH_ROOT netcoreapp2.1/publish

RUN dotnet publish MyApp.sln --configuration $DOTNETCORE_CONFIGURATION && \
    mkdir -p /src/MyApp/bin/$DOTNETCORE_CONFIGURATION/$PUBLISH_ROOT/wwwroot && \
    cp -R /src/MyApp/wwwroot/. /src/MyApp/bin/$DOTNETCORE_CONFIGURATION/$PUBLISH_ROOT/wwwroot

Hopefully something similar will work for you.

toddlucas avatar Jun 13 '19 22:06 toddlucas