Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Daniel15 opened this issue May 10, 2017 · 34 comments

Comments

@Daniel15
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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)

dotnet/msbuild#406
dotnet/msbuild#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
Copy link
Contributor Author

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 referenced this issue in reactjs/React.NET May 11, 2017
* Upgrade to Visual Studio 2017 + csproj tooling

* Include workaround for NuGet/Home#4337 (explicitly specify version when restoring NuGet packages)

* Work around dotnet/cli-migrate#11

* Upgrade to .NET Core 1.1.x

* Remove VersionPrefix from all csproj files

* Legacy NuGet restore is no longer needed

* Disable CS1701 warning for sample projects

* Turns out we actually do need the legacy NuGet restore

* Use VS2017 AppVeyor image

* Remove project dependencies to work around NuGet/Home#5193 and NuGet/Home#4578

* Use MSBuild 15 on AppVeyor

* Enforce .NET Core tools 1.0.0 in global.json

* Use newer npm on AppVeyor (as a workaround for https://github.com/dotnet/cli/issues/6561 and dotnet/msbuild#406), and run correct test command
@cellvia
Copy link

cellvia commented Sep 8, 2017

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

@hkarask
Copy link

hkarask commented Sep 9, 2017

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]

@cellvia
Copy link

cellvia commented Sep 12, 2017

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...

@rashidovich
Copy link

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,

@ghost
Copy link

ghost commented Sep 27, 2017

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

@ipavlo
Copy link

ipavlo commented Sep 30, 2017

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

@rashidovich
Copy link

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

@WillooWisp
Copy link

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!

@dasjestyr
Copy link

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.

@livarcocc
Copy link
Contributor

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: dotnet/msbuild#406.

@dasjestyr
Copy link

@livarcocc perfects. Thanks much

@tarntanate
Copy link

tarntanate commented Jan 13, 2018

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

@ghost
Copy link

ghost commented Jan 13, 2018

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

@mrhocuong
Copy link

mrhocuong commented Apr 18, 2018

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.

@mr-coetzee
Copy link

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.

@alexandervantrijffel
Copy link

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

@spboyer
Copy link
Contributor

spboyer commented Aug 16, 2018

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

@n873
Copy link

n873 commented Dec 24, 2018

Delete the bin folder and anything inside of the wwwroot folder prior to doing to a build or publish
This worked for me hope it helps

@walter-torricos-rgroup
Copy link

In my case I had one folder that was being created to a configuration I had on startup.
The folder holder a correct path on windows but not on Mac OS. After deleting the folder everything started working fine. You may also want to review the .csproj as it can hold paths that are not valid.
This worked for me, hope it helps someone...

@Alex2357
Copy link

I had

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

The problem was because I had in my Dockerfile

COPY / ./
RUN dotnet run --project tests.fsproj

After I changed to

COPY / ./tests
RUN dotnet run --project tests/tests.fsproj

The problem disappeared.

@leighghunt
Copy link

leighghunt commented Mar 20, 2019

Thanks to those above who pointed out the windows path issue - I just got this when I had a merge cause my build machine to start creating some funky directories from Windows path settings. Appears the presence of such a folder is all that is needed to trigger this issue.

I'll raise this as a new bug, as it seems it's not resolved. (Update: logged as dotnet/cli#10995)

Reproduction steps below:

Last login: Wed Mar 20 15:43:48 on ttys003
✔ ~/dev/playground 
21:11 $ mkdir build-error2
✔ ~/dev/playground 
21:12 $ cd build-error2
✔ ~/dev/playground/build-error2 
21:12 $ dotnet new console
The template "Console Application" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on /Users/leigh/dev/playground/build-error2/build-error2.csproj...
  Restoring packages for /Users/leigh/dev/playground/build-error2/build-error2.csproj...
  Generating MSBuild file /Users/leigh/dev/playground/build-error2/obj/build-error2.csproj.nuget.g.props.
  Generating MSBuild file /Users/leigh/dev/playground/build-error2/obj/build-error2.csproj.nuget.g.targets.
  Restore completed in 359.63 ms for /Users/leigh/dev/playground/build-error2/build-error2.csproj.

Restore succeeded.

✔ ~/dev/playground/build-error2 
21:12 $ dotnet run
Hello World!
✔ ~/dev/playground/build-error2 
21:12 $ mkdir D\:\\Processed
✔ ~/dev/playground/build-error2 
21:12 $ dotnet build
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 47.03 ms for /Users/leigh/dev/playground/build-error2/build-error2.csproj.
/usr/local/share/dotnet/sdk/2.2.102/Microsoft.Common.CurrentVersion.targets(3049,5): error MSB3552: Resource file "**/*.resx" cannot be found. [/Users/leigh/dev/playground/build-error2/build-error2.csproj]

Build FAILED.

/usr/local/share/dotnet/sdk/2.2.102/Microsoft.Common.CurrentVersion.targets(3049,5): error MSB3552: Resource file "**/*.resx" cannot be found. [/Users/leigh/dev/playground/build-error2/build-error2.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.52
✘-1 ~/dev/playground/build-error2 

Removal of the folder resolves the issue:

21:19 $ rmdir D\:\\Processed/
✔ ~/dev/playground/build-error2 
21:19 $ dotnet build
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 38.44 ms for /Users/leigh/dev/playground/build-error2/build-error2.csproj.
  build-error2 -> /Users/leigh/dev/playground/build-error2/bin/Debug/netcoreapp2.2/build-error2.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.89
✔ ~/dev/playground/build-error2 
21:19 $ 

More info - versions etc.

21:19 $ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.2.102
 Commit:    96ff75a873

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.2.102/

Host (useful for support):
  Version: 2.2.1
  Commit:  878dd11e62

.NET Core SDKs installed:
  1.0.1 [/usr/local/share/dotnet/sdk]
  1.0.4 [/usr/local/share/dotnet/sdk]
  2.1.4 [/usr/local/share/dotnet/sdk]
  2.2.100-preview3-009430 [/usr/local/share/dotnet/sdk]
  2.2.102 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.0-preview3-35497 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.0-preview3-35497 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0-preview3-27014-02 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
✔ ~/dev/playground/build-error2 
21:20 $ dotnet --version
2.2.102

@GuillaumeJUST
Copy link

Same problem for me with MacOs and Rider.

To resolve :

  • Close Rider
  • Remove path with ** into Yotha.Website.csproj added by Rider
  • Remove binand obj`folder (if you don't close rider they are automatically regenerated)
  • Open Visual Studio for Mac
  • Clean and Build your project
  • You can reopen Rider

I don't try to rebuild with rider

@waratah
Copy link

waratah commented Jun 3, 2019

Side note: I got this error due to stackify creating logs on Mac. Removing these allowed the build and run to complete without issue:

c:\temp\stackifymiddleware_settings.log
it also created c:\temp directory

The moral to this is to look for c: in your application directory. I had to close VS before the log was created. Researching stackify issue now...

@chriskuech
Copy link

I had this issue building dotnet app in an Ubuntu container. I was being lazy and copying the files directly into the file system root. Would work fine for any other language, but dotnet seems to do some kind of recursive search from the build folder and some of the unexpected file types trigger this error. I solved the problem by moving to an app folder.

@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@nohwnd
Copy link
Member

nohwnd commented Apr 14, 2020

FWIW I triggered this error when using runsettings for vstest that contained ...\build for test results. This created ... folder which is recursive on itself and that made the path infinitely long...

🔥 Before removing it copy all other content from the directory to a different location.

Removing it from Explorer will cause it to crash, because it attempts to remove recursively. Remove it from PowerShell instead, without the -Recurse switch by calling remove on the folder that contains the ... folder:

Remove-Item -Force "C:\Projects\temp\XUnitTestProject12\XUnitTestProject12"

@IanMercer
Copy link

I hit this using dotnet 5.0 on Raspberry Pi 4 64-bit Ubuntu. The issue was a folder that had been created by accident called 'd:\Music', i.e. a folder name containing what would have been a drive letter on Windows. Deleting that folder fixed the issue.

@trentmillar
Copy link

Just like @Alex2357 it was my Dockerfile.

I had,

COPY . .
WORKDIR "/src/clourful-robot"
RUN dotnet build "colourful-robot.csproj" -c Release -o /app/build

I needed,

COPY . .
WORKDIR "/src"
RUN dotnet build "colourful-robot.csproj" -c Release -o /app/build

I figured this out by finding the lastest docker images ID hash which was the one that failed mid-way through build. Then ran it interactivly to find the correct pathing docker run -it --name testingmyshiz 9af314

@ejhg
Copy link

ejhg commented Jan 5, 2021

If you are building using Docker, make sure to set an appropriate WORKDIR in the Dockerfile. The default working directory is the root directory/, and it will result in this error if you try to build from there.

@tengl
Copy link

tengl commented Nov 24, 2022

I hit this using dotnet 5.0 on Raspberry Pi 4 64-bit Ubuntu. The issue was a folder that had been created by accident called 'd:\Music', i.e. a folder name containing what would have been a drive letter on Windows. Deleting that folder fixed the issue.

I encountered this on a Linux machine today, dotnet 6.0. I probably had a folder with a \, but deleted it before I checked all levels. It works after the delete.

@Mrking-007
Copy link

i get this problem on my macos,use the visual studio for mac。open the project dictionary,i find there is a windows dictionary "r/\xx\projects",delete it ,it works。

@TTV-VOXindie
Copy link

I had

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

The problem was because I had in my Dockerfile

COPY / ./
RUN dotnet run --project tests.fsproj

After I changed to

COPY / ./tests
RUN dotnet run --project tests/tests.fsproj

The problem disappeared.

This worked for me. Fixed my issue trying to run a .NET project via docker in GitHub Actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests