sdk: dotnet build fails to manage embedded resources

Steps to reproduce

Create a new class library project (under VS2017, last update) Add a Foo.resx file (with designer) Add a Foo.fr.resx file Go to the project directory Execute dotnet build

Expected behavior

The project must be built without error

Actual behavior

C:\Program Files\dotnet\sdk\1.0.0\Microsoft.Common.CurrentVersion.targets(4072,5): error MSB3030: Could not copy the file “obj\Debug\fr\ProjectName.resources.dll” because it was not found. [C:\Projects\SolutionName\ProjectName\ProjectName.csproj]

Environment data

dotnet --info output:

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.0 (tested with 1.0.1 as well)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 15 (3 by maintainers)

Most upvoted comments

The originally reported issue persists in dotnet 2.0.0. In our case, I’m stuck using the old csproj format because Telerik Reporting tools don’t yet support the new project file format.

I’d like to request that this issue be reopened.

I experience the same problem. It appears to be only a problem if you use the old csproj format.

If you move your resource files to a class library with the new csproj format, this might be a viable workaround.

@mbp what do you mean with this? Could you give me an example please?

@rlordcardano your sample is using advanced resx features that aren’t supported using the .net core versions of MSBuild. The core version only supports key-value strings in resx files.

The following part of your resx file isn’t going to work using the cli:

<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Embedded" type="System.Resources.ResXFileRef, System.Windows.Forms">
  <value>..\Embedded.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>

There are a few issues for this and similar issues on the MSBuild side: https://github.com/Microsoft/msbuild/issues/2221 https://github.com/Microsoft/msbuild/issues/1247 https://github.com/Microsoft/msbuild/issues/2272

@livarcocc dotnet build also seems to have problems with embedded resources in general, also in new style csproj project files. In the attached project (a console application), I:

  • Access the embedded resource via resources, and print it in the console
  • Access the embedded resource via the manifest resource stream, and print it in the console

For your convenience, just run buildandrun.bat, and it will build and run using dotnet build. On my machine, this shows that the first way (accessing the embedded resource via Resources) does not work using dotnet build. Strangely enough, it does work when building the project in Visual Studio.

I see other changes in behaviour as well (numerically), but will create a separate post for this. [Edit: numerical differences were solved by forcing the platform to be x64 in the test settings file - appears to be the case that dotnet test or vstest.console by default (on Windows) runs in 32-bit modes].

EmbeddedResourceApp.zip

I’m having this problem on Mac OS with Visual Studio 2017, trying to run from the command line.