sdk icon indicating copy to clipboard operation
sdk copied to clipboard

"error MSB3552: Resource file "**/*.resx" cannot be found" only in particular environments

Open Daniel15 opened this issue 9 years ago • 35 comments

I have a build that works on my computer but is failing in a continuous integration environment (AppVeyor) with this error:

Microsoft.Common.CurrentVersion.targets(2867,5): error MSB3552: Resource file "**/*.resx" cannot be found.

On my computer, the build output contains:

React.Core.csproj" (target "ResGen" depends on it):
Task "GenerateResource" skipped, due to false condition; ('%(EmbeddedResource.Type)' == 'Resx' and '%(EmbeddedResource.GenerateResource)' != 'false' and '$(GenerateResourceMSBuildRuntime)' != 'CLR2') was evaluated as ('Non-Resx' == 'Resx' and '' != 'false' and 'CLR4' != 'CLR2').
Task "GenerateResource" skipped, due to false condition; ('%(EmbeddedResource.Type)' == 'Resx' and '%(EmbeddedResource.GenerateResource)' != 'false' and '$(GenerateResourceMSBuildRuntime)' == 'CLR2') was evaluated as ('Non-Resx' == 'Resx' and '' != 'false' and 'CLR4' == 'CLR2').
Done building target "CoreResGen" in project "React.Core.csproj".

However, on the build server, it says:

React.Core.csproj" (target "ResGen" depends on it):
Using "GenerateResource" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "GenerateResource"
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2867,5): error MSB3552: Resource file "**/*.resx" cannot be found. [C:\projects\react-net\src\React.Core\React.Core.csproj]
  "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\resgen.exe" ........

It looks like EmbeddedResource.Type is incorrectly set to Resx rather than Non-Resx, but I have no idea where that comes from :(

I also noticed a few other messages that appear on the build server that do not appear on my local build:

  Culture of "" was assigned to file "**/*.resx".
Done executing task "AssignCulture".
Task "AssignCulture"
  Resource file '**/*.resx' doesn't depend on any other file.
  Resource file '**/*.resx' gets manifest resource name 'React.Core.__.*'.
Done executing task "CreateCSharpManifestResourceName".
Task "CreateCSharpManifestResourceName"
 Creating a separate AppDomain because of error parsing "**/*.resx". Illegal characters in path

Seems like there's some strange globbing issue going on? I'm not sure.

Steps to reproduce

Clone https://github.com/reactjs/React.NET, checkout b2cd0a4f040da24d1ed2a46d454678fd58c6f8ec, run dev-build.bat

Expected behavior

It works

Actual behavior

Example build: https://ci.appveyor.com/project/Daniel15/react-net/build/217

Environment data

dotnet --info output:

On my computer:

.NET Command Line Tools (1.0.0)

Product Information:
 Version:            1.0.0
 Commit SHA-1 hash:  e53429feb4

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16188
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0

On AppVeyor:

.NET Command Line Tools (1.0.3)

Product Information:
 Version:            1.0.3
 Commit SHA-1 hash:  37224c9917

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.3

Edit: Also tested with 1.0.4 on my computer, and it works properly on that version too.

.NET Command Line Tools (1.0.4)

Product Information:
 Version:            1.0.4
 Commit SHA-1 hash:  af1e6684fd

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16188
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.4

Seems like something specific to the AppVeyor build.

Daniel15 avatar May 10 '17 04:05 Daniel15

I tried removing all references to <EmbeddedResource> from csproj files, but that didn't fix it. I'm not using any ResX files at all, just regular files as embedded resources.

Daniel15 avatar May 10 '17 05:05 Daniel15

So I figured this out. This is due to an annoying long-standing MSBuild issue whereby it doesn't expand wildcards at all if any paths are longer than the old-school max path length in Windows (260 characters)

https://github.com/Microsoft/msbuild/issues/406 https://github.com/Microsoft/msbuild/issues/53 http://stackoverflow.com/a/16738844/210370

This meant that the MSBuild scripts were treating **/*.resx as a literal file name, and then complaining that the file doesn't exist!

The only "fix" for this is to reduce the length of the paths. In my case, the build server was using a very old version of npm that had issues with long paths. At the moment it seems like the MSBuild team are not interested in fixing it.

Daniel15 avatar May 10 '17 05:05 Daniel15

The wildcard that breaks everything for folders with long paths is in %ProgramFiles%\Microsoft Visual Studio\2017\community\msbuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.DefaultItems.props:

<EmbeddedResource Include="**/*.resx" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" Condition=" '$(EnableDefaultEmbeddedResourceItems)' == 'true' " />

Daniel15 avatar May 10 '17 06:05 Daniel15

i am in OSX and getting this problem even when i move the project to a short folder, any help or ideas?

cellvia avatar Sep 08 '17 15:09 cellvia

Getting similar error when trying to build on Docker microsoft/aspnetcore-build:2.0 /usr/share/dotnet/sdk/2.0.0/Microsoft.Common.CurrentVersion.targets(2924,5): error MSB3552: Resource file "**/*.resx" cannot be found. [/Web.csproj]

hkarask avatar Sep 09 '17 06:09 hkarask

dont know if this helps but i saw that msbuild or vscode (or something) was trying to create a hidden keys folder ( ".keys") but was instead creating ".\keys" every time i run a build, i make sure to delete ".\keys" and things seem ok...

cellvia avatar Sep 12 '17 20:09 cellvia

VM Ubuntu 17.04 .net core 2.0

dotnet build throws same issue.

basically i cannot deploy to production. on local machine (OSX) builds fine.

i don't see any '.keys' folder.

Thanks in advance,

rashidovich avatar Sep 22 '17 11:09 rashidovich

I am also seeing the same thing on ubuntu:

dotnet --info

.NET Command Line Tools (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  16.04
 OS Platform: Linux
 RID:         ubuntu.16.04-x64
 Base Path:   /usr/share/dotnet/sdk/2.0.0/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

ghost avatar Sep 27 '17 12:09 ghost

Getting same problem, but on second build. First time dotnet build is successful but second time failes with same error: dotnet --info

.NET Command Line Tools (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  16.04
 OS Platform: Linux
 RID:         ubuntu.16.04-x64
 Base Path:   /usr/share/dotnet/sdk/2.0.0/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

ipavlo avatar Sep 30 '17 08:09 ipavlo

Not sure but it could be a problem with migration from .net core 1 to .net core 2.

If I start a new project (asp.net web/api) than everything is fine

rashidovich avatar Sep 30 '17 08:09 rashidovich

We also experience this problem with **/*.resx. It did build fine a couple of times, but then this started to occur and cleaning solution first does not work. It's really annoying!

WillooWisp avatar Dec 08 '17 14:12 WillooWisp

I'd like to reopen this. This is not ok. Not only does moving things around to shorten the path not work for a lot of is, it isn't a solution. If there's a setting that needs to be changed, then I need to know what it is, or this straight up needs to be fixed. I cannot build my projects on a mac at all.

dasjestyr avatar Dec 21 '17 16:12 dasjestyr

There is a bug in MSBuild tracking this and as the fix needs to happen there, I would comment there and follow it. Pasting the issue again here: https://github.com/Microsoft/msbuild/issues/406.

livarcocc avatar Dec 21 '17 17:12 livarcocc

@livarcocc perfects. Thanks much

dasjestyr avatar Dec 21 '17 20:12 dasjestyr

Try deleting "bin" and "obj" folder and rebuild project again. (I'm using macOS Sierra with VSCode)

tarntanate avatar Jan 13 '18 13:01 tarntanate

@tarntanate - Yep, we saw the same thing on ubuntu and fedora.

ghost avatar Jan 13 '18 13:01 ghost

I have a .net core project are run on Windows but when I try to run the project on macOs I got the error message "error MSB3552: Resource file "**/*.resx" cannot be found".

In my project, I have a config to store the log files in the folder

"WriteTo": [ { "Name": "RollingFileAlternate", "Args": { "logDirectory": ".\\Logs", "fileSizeLimitBytes": 10485760 } } ]

At the first time I run the project, this config can run on windows and create a folder have name "Logs" but when I run on macOs it will create a folder have name ".\Logs" and it's a hidden folder. So this is a problem, after that the project will get that error when building.

The solutions are changing the config to:

"WriteTo": [ { "Name": "RollingFileAlternate", "Args": { "logDirectory": "Logs", "fileSizeLimitBytes": 10485760 } } ] Now the project can run on macOs.

Basically, cause windows use the backslash in the directory path, but macOs use the slash so when you need to build the project which coding in Windows on macOs, you should check all the code have related to files, folder, path (ex: the code to create the folder to save log files, create the folder to save upload files..etc).

For the answer of cellvia, I think he got the same problem like me. The .keys folder are created by his code and he can hotfix by the way create a keys folder already before building the project.

Hope it helps.

mrhocuong avatar Apr 18 '18 02:04 mrhocuong

Same problem with windows paths.

I noticed the following when ls -al my src folder: drwxrwxr-x 2 user user 4096 May 16 17:29 c:\temp\data\

I deleted with rm -rf "c:\\temp\\data\\"/, updated my settings, and all is good.

Thank you @mrhocuong and @cellvia.

mr-coetzee avatar May 16 '18 21:05 mr-coetzee

Same here on mac os. I suddenly had a C:\dev\App\AppBytes subdirectory under my project directory holding the .csproj file.

alexandervantrijffel avatar Aug 08 '18 16:08 alexandervantrijffel

Getting this in Docker build for Razor Pages app.

/usr/share/dotnet/sdk/2.1.400/Microsoft.Common.CurrentVersion.targets(3049,5): error MSB3552: Resource file "**/*.resx" cannot be found.

Base Image

microsoft/dotnet:2.1.2-aspnetcore-runtime 
microsoft/dotnet:2.1.400-sdk

@richlander @MichaelSimons

spboyer avatar Aug 16 '18 18:08 spboyer