Skip to content

"MSB3823: Non-string resources require the property GenerateResourceUsePreserializedResources to be set to true" if TargetFramework=net48 #4704

@to-st

Description

@to-st

We have a few projects that muti target .net core and the old fashioned .net framework. Some of these include binary resources (mostly images). With .net core 2.1 / 2.2 they build successfully but accessing an image while running under .net core throws an exception while with the full framework everything continues to works.
Now .net core 3.0 added support for binary resources giving us the chance to eliminate a few workarounds.
But now TargetFramework=net48 fails to build. As we are still in the transition to .net core and most of our products (still) require the full framework. Therefore this blocks any usage of .net core 3.0 in our codebase.

Steps to reproduce

unzip the attached project and run "dotnet build" or "dotnet build -p:TargetFramework=net48". Note that "dotnet build -p:TargetFramework=netcoreapp3.0" builds successfully.

LibraryWithImage.zip

Expected behavior

Successful build - net48 definitely supports images inside .resx

Actual behavior

Microsoft (R)-Build-Engine, Version 16.3.0-preview-19426-01+faf5e5d75 f▒r .NET Core
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

  Wiederherstellung in "113,4 ms" f▒r "C:\source\ResxBug\LibraryWithImage\LibraryWithImage.csproj" abgeschlossen.
  You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
C:\Program Files\dotnet\sdk\3.0.100-preview9-014004\Microsoft.Common.CurrentVersion.targets(3056,5): error : MSB3823: Non-string resources require the property GenerateResourceUsePreserializedResources to be set to true. [C:\source\ResxBug\LibraryWithImage\LibraryWithImage.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview9-014004\Microsoft.Common.CurrentVersion.targets(3056,5): warning MSB3555: Die Ausgabedatei "C:\source\ResxBug\LibraryWithImage\obj\Debug\net48\LibraryWithImage.Resources.resources" ist m▒glicherweise besch▒digt. [C:\source\ResxBug\LibraryWithImage\LibraryWithImage.csproj]
  LibraryWithImage -> C:\source\ResxBug\LibraryWithImage\bin\Debug\netcoreapp3.0\LibraryWithImage.dll

Fehler beim Buildvorgang.

C:\Program Files\dotnet\sdk\3.0.100-preview9-014004\Microsoft.Common.CurrentVersion.targets(3056,5): warning MSB3555: Die Ausgabedatei "C:\source\ResxBug\LibraryWithImage\obj\Debug\net48\LibraryWithImage.Resources.resources" ist m▒glicherweise besch▒digt. [C:\source\ResxBug\LibraryWithImage\LibraryWithImage.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview9-014004\Microsoft.Common.CurrentVersion.targets(3056,5): error : MSB3823: Non-string resources require the property GenerateResourceUsePreserializedResources to be set to true. [C:\source\ResxBug\LibraryWithImage\LibraryWithImage.csproj]
    1 Warnung(en)
    1 Fehler

Verstrichene Zeit 00:00:02.58

Environment data

SDK 3.0.100-preview9-014004 installed using the installer (see https://dotnet.microsoft.com/download/dotnet-core/3.0 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions