【问题标题】:.NET Core RC2 - NeutralResourcesLanguageAttribute.NET Core RC2 - NeutralResourcesLanguageAttribute
【发布时间】:2016-10-15 13:15:50
【问题描述】:

使用新版本的 .NET Core RC2,当使用新的 SDK 1.0.0-preview1-002702(从版本 1.0.0-rc1-update1 迁移后)编译项目时,它会为每个框架生成一个包含属性的文件 dotnet-compile.assemblyinfo.cs System.Resources.NeutralResourcesLanguageAttribute。示例:

// <auto-generated> This file has been auto generated. </auto-generated>
[assembly:System.Reflection.AssemblyFileVersionAttribute("1.0.1.0")]
[assembly:System.Resources.NeutralResourcesLanguageAttribute("en-US")]
[assembly:System.Runtime.Versioning.TargetFrameworkAttribute(".NETStandard,Version=v1.0")]

我的问题是,当编译到像新的 NET Standard 框架这样的框架时,我现在必须向 System.Resources.ResourceManager 添加一个依赖项,否则它将无法编译。

有没有办法防止这种情况发生?

这是我目前的project.json

{
  "version": "1.0.1",
  "title": "Simple Exception Handling",
  "description": "Library that helps developers to handle exceptions outside catch blocks. Typical usages are global exception handlers.",
  "authors": [ "João Simões" ],
  "language": "en-US",
  "copyright": "Copyright © 2016 João Simões",
  "packOptions": {
    "summary": "Library that helps developers to handle exceptions outside catch blocks.",
    "tags": [ "exception", "handler" ],
    "projectUrl": "https://github.com/gravity00/SimpleExceptionHandling",
    "licenseUrl": "https://raw.githubusercontent.com/gravity00/SimpleExceptionHandling/master/LICENSE",
    "iconUrl": "https://raw.githubusercontent.com/gravity00/SimpleExceptionHandling/master/SimpleExceptionHandling-Logo.png",
    "releaseNotes": "Library is now strong signed",
    "owners": [ "João Simões" ],
    "repository": {
      "type": "git",
      "url": "https://github.com/gravity00/SimpleExceptionHandling"
    }
  },
  "buildOptions": {
    "xmlDoc": true,
    "optimize": true,
    "keyFile": "SimpleExceptionHandling.snk"
  },

  "frameworks": {
    ".NETPortable,Version=v4.0,Profile=Profile328": {
      "buildOptions": {
        "define": [ "PORTABLE40" ]
      },
      "frameworkAssemblies": {
        "mscorlib": "",
        "System": "",
        "System.Core": ""
      }
    },
    "dnxcore5": {
      "dependencies": {
        "System.Runtime": "4.0.0",
        "System.Resources.ResourceManager": "4.0.0"
      }
    },
    "dotnet": {
      "dependencies": {
        "System.Runtime": "4.0.0",
        "System.Resources.ResourceManager": "4.0.0"
      }
    },
    "net20": { },
    "net35": { },
    "net40": { },
    "net45": { },
    "netcore45": {
      "dependencies": {
        "System.Runtime": "4.0.0",
        "System.Resources.ResourceManager": "4.0.0"
      }
    },
    "netstandard10": {
      "imports": [ "dnxcore50" ],
      "dependencies": {
        "System.Runtime": "4.0.0",
        "System.Resources.ResourceManager": "4.0.0"
      }
    }
  }
}

【问题讨论】:

    标签: c# .net .net-core-rc2


    【解决方案1】:

    通过在 project.json 中设置 "language": "en-US" 来包含 [NeutralResourcesLanguage] 属性,因为您要求包含它

    如果您不想依赖 System.Resources.ResourceManager 包,请从 project.json 中删除该行。

    【讨论】:

    • 我已经习惯了放置该属性,以至于我什至没有想到这可能是原因。非常感谢,它解决了我的问题!
    猜你喜欢
    • 2016-09-18
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-20
    • 1970-01-01
    • 2016-10-10
    相关资源
    最近更新 更多