Dotnet Core Build Error in Docker: Resource file “**/*.resx” cannot be found

While building my new .NET Core project using Docker I ran into an error with the two stage build:

/usr/share/dotnet/sdk/2.0.0/Microsoft.Common.CurrentVersion.targets(2924,5): error MSB3552: Resource file “**/*.resx” cannot be found. [/Hapthorn.csproj]
The command ‘/bin/sh -c dotnet publish -c Release -o out’ returned a non-zero code: 1

The problem it turned out was that while trying to tune my Dockerfile I’d accidentally removed the WORKDIR directive. As a result MSBuild was interpreting the *.resx as an absolute path instead of a grouping/collection directive.

To fix it I put back in a WORKDIR /src directive in my Dockerfile.

Quick and easy!

2 Replies to “Dotnet Core Build Error in Docker: Resource file “**/*.resx” cannot be found”

  1. It sounds like this was a bandaid. As far as I understand it, it is an issue with path length; after a certain length, **/*.resx will no longer expand to the full value. By pulling your files into a working directory, you’re essentially shortening the path and inadvertently fixing the root cause (the length of the file path) and avoiding the problem.

    I mean, it fixes things for now, but as soon as you have a few more nested directories, the problem will return.

  2. I suppose it depends on how nested your directories are? Most people work on C:\Work so they aren’t going to see this problem.
    My mistake was that by removing the WORKDIR directive my project got placed somewhere deep into a system folder hierarchy.
    I suppose is a band-aid though, around the filename limitation in MSBuild, not Docker. I expect that this will get fixed in a future version of MSBuild. I’m not holding my breath though, I’d expect there are higher priorities.

Leave a Reply

Your email address will not be published. Required fields are marked *