我有dotnet核心应用程序,我正在研究这是跨平台的。我想在我的项目中使用Noda作为实用程序,但是即使我在项目中将nodatime定义为依赖项,也会出现以下错误:
System.IO.FileNotFoundException: Could not load file or assembly 'NodaTimestrong text, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1'. The system cannot find the file specified.
File name: 'NodaTime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1'
at project.ef.CalendarHelper.ValidateTimeZone(String timezoneTypeName)
at project.ef.CalendarHelper.
以下是项目配置文件:
API PROJECT
{
"buildOptions": {
"preserveCompilationContext": true,
"emitEntryPoint": true,
"warningsAsErrors": true,
"debugType": "portable",
"copyToOutput": {
"include": [
"config.json",
"Certificate.pfx"
]
}
},
"dependencies": {
"AspNet.Security.OAuth.Introspection": "1.0.0-alpha2-final",
"AspNet.Security.OAuth.Validation": "1.0.0-alpha2-final",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Mvc.Formatters.Json": "1.0.0",
"Microsoft.AspNetCore.Mvc.Cors": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.EntityFrameworkCore.Design": {
"type": "build",
"version": "1.0.0-preview2-final"
},
"Microsoft.NETCore.App": "1.0.0",
"project.ef": "1.0.0-*"
},
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [ "portable-dnxcore50+net45+win8+wp8+wpa81" ]
}
},
"publishOptions": {
"include": [
"config.json"
]
},
"runtimes": {
"win10-x64": {},
"osx.10.11-x64": {},
"ubuntu.14.04-x64": {}
}
}
EF项目
{
"dependencies": {
"NETStandard.Library": "1.6.0",
"Npgsql.EntityFrameworkCore.PostgreSQL": "1.0.1",
"Npgsql.EntityFrameworkCore.PostgreSQL.Design": "1.0.1",
"project.Internal.ERP": "1.1.0-*",
"project.models": "1.0.0-*",
"NodaTime": "2.0.0-alpha-*"
},
"frameworks": {
"netstandard1.6": {
"imports": [
"dnxcore50",
"portable-net451+win8"
]
}
}
}
答案 0 :(得分:5)
Noda Time 1.x仅针对PCL。您可能能够使用netcoreapp1.0,但我不会保证。
但Noda Time 2.0的目标是netstandard1.1,所以应该没问题。这只是现在的alpha版本,但它运行正常:
project.json
内容:
{
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"NodaTime": "2.0.0-alpha20160729"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
}
}
}
}
Program.cs
内容:
using System;
using NodaTime;
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine(SystemClock.Instance.GetCurrentInstant());
}
}
没有任何问题。