dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.7k stars 1.06k forks source link

dotnet publish fails with "error MSB3552: Resource file "**/*.resx" cannot be found" #4177

Closed msschl closed 4 years ago

msschl commented 4 years ago

Running the following commands in a docker container (ci/cd environment) results in an error: error MSB3552: Resource file "**/*.resx" cannot be found

$ dotnet restore --packages $NUGET_PACKAGES_DIRECTORY
Restore completed in 247.66 ms for /builds/service/...
Restore completed in 1.25 sec for /builds/service/...
Restore completed in 1.01 sec for /builds/service/...
Restore completed in 9.28 ms for /builds/service/...
Restore completed in 132.98 ms for /builds/service/...

$  dotnet build -c $CONFIGURATION --no-restore
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restore operation started...
  XXX -> /builds/service/XXX/bin/Release/netstandard2.1/XXX.dll
  XXX -> /builds/service/XXX/bin/Release/netcoreapp3.1/XXX.dll
  XXX -> /builds/service/XXX/bin/Release/netcoreapp3.1/XXX.dll
  Restoring library jquery@3.4.1...
  wwwroot/lib/jquery/core.js written to destination
  wwwroot/lib/jquery/jquery.js written to destination
  wwwroot/lib/jquery/jquery.min.js written to destination
  wwwroot/lib/jquery/jquery.min.map written to destination
  wwwroot/lib/jquery/jquery.slim.js written to destination
  wwwroot/lib/jquery/jquery.slim.min.js written to destination
  wwwroot/lib/jquery/jquery.slim.min.map written to destination
  Restoring library twitter-bootstrap@4.3.1...
  wwwroot/lib/bootstrap/css/bootstrap-grid.css written to destination
  wwwroot/lib/bootstrap/css/bootstrap-grid.css.map written to destination
  wwwroot/lib/bootstrap/css/bootstrap-grid.min.css written to destination
  wwwroot/lib/bootstrap/css/bootstrap-grid.min.css.map written to destination
  wwwroot/lib/bootstrap/css/bootstrap-reboot.css written to destination
  wwwroot/lib/bootstrap/css/bootstrap-reboot.css.map written to destination
  wwwroot/lib/bootstrap/css/bootstrap-reboot.min.css written to destination
  wwwroot/lib/bootstrap/css/bootstrap-reboot.min.css.map written to destination
  wwwroot/lib/bootstrap/css/bootstrap.css written to destination
  wwwroot/lib/bootstrap/css/bootstrap.css.map written to destination
  wwwroot/lib/bootstrap/css/bootstrap.min.css written to destination
  wwwroot/lib/bootstrap/css/bootstrap.min.css.map written to destination
  wwwroot/lib/bootstrap/js/bootstrap.bundle.js written to destination
  wwwroot/lib/bootstrap/js/bootstrap.bundle.js.map written to destination
  wwwroot/lib/bootstrap/js/bootstrap.bundle.min.js written to destination
  wwwroot/lib/bootstrap/js/bootstrap.bundle.min.js.map written to destination
  wwwroot/lib/bootstrap/js/bootstrap.js written to destination
  wwwroot/lib/bootstrap/js/bootstrap.js.map written to destination
  wwwroot/lib/bootstrap/js/bootstrap.min.js written to destination
  wwwroot/lib/bootstrap/js/bootstrap.min.js.map written to destination

  2 libraries restored in 4.32 seconds

  Bundler: Begin processing bundleconfig.json
  Bundler: Done processing bundleconfig.json
  XXX -> /builds/service/XXX/bin/Release/netcoreapp3.1/XXX.dll
  XXX -> /builds/service/XXX/bin/Release/netcoreapp3.1/XXX.dll

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

Time Elapsed 00:00:08.43

$ dotnet publish src/XXX/MVC_APP.csproj -c $CONFIGURATION -f $FRAMEWORK --no-restore  -o ./$ARTIFACTS_DIR/$FRAMEWORK
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore operation started...
  Restoring library jquery@3.4.1...
  Restoring library twitter-bootstrap@4.3.1...

  2 libraries restored in 0.09 seconds

  XXX -> /builds/service/XXX/bin/Release/netstandard2.1/XXX.dll
  XXX -> /builds/service/XXX/bin/Release/netcoreapp3.1/XXX.dll
/usr/share/dotnet/sdk/3.1.100/Microsoft.Common.CurrentVersion.targets(3056,5): error MSB3552: Resource file "**/*.resx" cannot be found. [/builds/service/XXX/XXX.csproj]

$CONFIGURATION is set to Release $FRAMEWORK is set to netcoreapp3.1

.NET Core SDK (reflecting any global.json):
 Version:   3.1.100
 Commit:    cd82f021f4

Runtime Environment:
 OS Name:     debian
 OS Version:  10
 OS Platform: Linux
 RID:         debian.10-x64
 Base Path:   /usr/share/dotnet/sdk/3.1.100/

Host (useful for support):
  Version: 3.1.0
  Commit:  65f04fb6db

.NET Core SDKs installed:
  3.1.100 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
andresrsanchez commented 4 years ago

Same error for me with Ubuntu 16.04, console template and running "dotnet build".

andresrsanchez commented 4 years ago

Solved it creating a folder for the project, the original one was in the root path (don't tell me why :) )

DanteMarshal commented 4 years ago

I was having this issue since Yesterday on Windows 10 with a project targeting "net48" framework. First I thought it's because I installed Visual Studio with its own set of DotNet Core installations and also had some Windows SDK and UWP stuff for the sake of testing. But even after I removed everything the bug still persisted. Then I created a new dotnet console project and started moving configurations from the old .csproj file to the new file one by one, But no error happened. Then I moved all the source code and still no errors happened. Right now, Both directories are Identical (With Source code and Resources) but still no error ! image (Images : Left side is Old project files, Right side is the new one which is an identical copy to the old one at this moment, Except they're in different directories) image

I think this is a Caching issue, Since only changing the path of a project's directory fixed the problem.