gpt4 book ai didi

asp.net-core - NodaTime 与 NetCoreApp 1.0 兼容吗?

转载 作者:行者123 更新时间:2023-12-03 02:13:50 24 4
gpt4 key购买 nike

我正在开发一个跨平台的 dotnet core 应用程序。我想在我的项目中使用 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 项目

{
"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"
]
}
}
}

最佳答案

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());
}
}

运行没有问题。

关于asp.net-core - NodaTime 与 NetCoreApp 1.0 兼容吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40347451/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com