Why can't I use embedded resources (resx) when targeting .netstandard 1.3?

大兔子大兔子 提交于 2019-12-22 05:14:06

问题


(Question subtitle: Are resources not supported in .netstandard 1.3 or is my project file just messed up?)

I just created an example portable class library in Visual Studio 2015 Update 3 and added a sample resource file. Initially, the file project.json looks like this:

{
  "supports": {
    "net46.app": {},
    "uwp.10.0.app": {},
    "dnxcore50.app": {}
  },
  "dependencies": {
    "Microsoft.NETCore": "5.0.0",
    "Microsoft.NETCore.Portable.Compatibility": "1.0.0"
  },
  "frameworks": {
    "dotnet": {
      "imports": "portable-net452+win81"
    }
  }
}

Fine: No compile errors!

After that, I used the project properties to target .NETStandard 1.3.

Now project.json looks like this:

{
  "supports": {},
  "dependencies": {
    "Microsoft.NETCore.Portable.Compatibility": "1.0.1",
    "NETStandard.Library": "1.6.0"
  },
  "frameworks": {
    "netstandard1.3": {}
  }
}

Now I get the following build error - which means basically the the build action EmbeddedRessource is not supported:

I'm really no expert with project.json, but for me the things look inconsistent - and I have no idea, where the problem is.

  • in the first project.json: if I support net46, why is it importing net452?
  • in the second project.json: if I use netstandard1.3, why is there a dependency to the library in version 1.6?
  • and finally, what is .NETPortable, Version=v5.0? The renaming of .NET Core has taken place early this year - why are we still referencing version 5.0? Even MSDN doesn't know <TargetFrameworkVersion>5.0</TargetFrameworkVersion> which is specified in the csproj

For me, this seems like netstandard isn't only about the available libraries, tooling seems involved, too. But that does not explain, why it worked for dnxcore50.


回答1:


You need Diagnostics.Tools and Resources.ResourceManager.

I got this working (for .NET Standard 1.4 though) by installing the pre versions, at this time:

  • "System.Diagnostics.Tools": "4.3.0-preview1-24530-04"
  • "System.Resources.ResourceManager": "4.3.0-preview1-24530-04"


来源:https://stackoverflow.com/questions/38131746/why-cant-i-use-embedded-resources-resx-when-targeting-netstandard-1-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!