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)
I am seeing the same error, only if the class library project has *.resx files with the language code in path.
For example:
A class library with a resource file named Foo.fr.resx will fail.
However a class library with a resource file named Foo.resx (without the .fr or any other language code) will compile without error.
dotnet --info
.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
Try with MSBuild15 : MSBuild.exe /t:package
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.
I confirm.
I'm having this problem on Mac OS with Visual Studio 2017, trying to run from the command line.
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.
The dotnet command line does not support old style csproj project files.
@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].
Encountering this same thing -- works great in VS, but my CI builds are failing. Using dotnet build/dotnet test
@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
@Oceanswave check if your resx files use any System.Windows.Forms references like mentioned above. If they contain anything but strings, the cli won't work and you'll have to use full msbuild from either a VS installation on windows or a recent mono version.
@desmondgc I want to know if Telerik report designer works with the new msbuild csproj template?
bump
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?
@dasMulli , So could u pls recommend which docker image is used for that kind of issue? Now I am using window server core image and I got this issue and my resx file is exactly the same u provided structure.