错误代码MSB3823:非字符串资源需要将属性GenerateResourceUsePreserializedResources设置为true。

14

大家好,我遇到了一个错误并正努力尝试解决它。我发现了一些类似的资源,但无法解决我的问题。类似问题可以在这里找到。

我使用.bat文件(实际上是从cmd运行的.batch文件)编译我的项目.csproj文件。但是我遇到了这个错误:

error MSB3823: Non-string resources require the property GenerateResourceUsePreserializedResources to be set to true. [C:\Users\rmrud\source\Workspaces\Workspace2\HAL9\v3_07\Test\Test\Test.csproj]

还有我也遇到了这个问题:

error MSB3822: Non-string resources require the 
System.Resources.Extensions assembly at runtime, but it was not found in this project's references. [C:\Users\rmrud\source\Workspaces\Workspace2\HAL9\
v3_07\Test\Test\Test.csproj]

我也在cmd中执行了以下命令:choco install visualstudio2019-workload-netcoretools

我编辑了我的.csproj文件,在你的xxx.csproj文件中添加了这些xml节点:

<PropertyGroup> 
    <GenerateResourceMSBuildArchitecture>
        CurrentArchitecture
    </GenerateResourceMSBuildArchitecture>
    <GenerateResourceMSBuildRuntime>
        CurrentRuntime
    </GenerateResourceMSBuildRuntime>
</PropertyGroup>

然而,我使用批处理文件从命令提示符编译,但仍然出现构建错误。如何克服这个问题,提前致谢。请注意,在我的计算机上,我正在使用.NET框架4.8版本和.Net Core 5。


这个有任何更新吗? - Aditya Nair
无需尝试。 - Rifat Murtuza
2个回答

21
请将System.Resources.Extensions NuGet包添加到相应的项目中。

1
我遇到了类似的问题,尝试了一个简单的命令 "dotnet add package System.Resources.Extensions",但是它没有起作用。你有什么想法我可能漏掉了什么吗? - Dave Potts
@DavePotts,框架还是核心? - Anton Norko
框架与核心是我的问题。经过仔细检查,这与本问题无关。对于造成的混淆,我感到抱歉! - Dave Potts
@DavePotts 你是怎么添加这个包的?我用了 Install-Package System.Resources.Extensions,但是构建还是出错了。 - undefined

5
如果您的项目使用.NET Framework,并且在其中使用资源,请检查您的csproj文件中是否有以下内容:
 <GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>

删除它或将其设置为false。 检查相关资料,似乎它在.NET Core中使用,但对于.NET Framework会出现错误。

1
这个不起作用..错误MSB3823显示我需要在这里添加true。 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接