2016-11-23 225 views
0

我在我的asp.net核心應用程序中引用了一個.Net核心類庫項目。 Web應用程序中的引用失敗。有人告訴我問題是什麼。我發佈了兩個我的Project.jsons文件。條目 「CustomerOrder.Data」:在asp.net JSON文件 「1.0.0- *」 是類庫項目的參考在Asp.Net核心項目中引用.Net核心類庫項目的問題

.NetCore類庫項目:netstandard1.6

Asp.Net核心:netcoreapp1.0

我收到以下錯誤消息

錯誤NU1001的依賴CustomerOrder.Data> = 1.0.0- *無法解析。

.NetCore類庫項目 - Project.Json

{ 
    "version": "1.0.0-*", 

    "dependencies": { 
    "CustomerOrder.Model": "1.0.0-*", 
    "Microsoft.EntityFrameworkCore": "1.1.0", 
    "Microsoft.EntityFrameworkCore.Relational": "1.0.1", 
    "Microsoft.Extensions.Caching.Abstractions": "1.1.0", 
    "NETStandard.Library": "1.6.1" 
    }, 

    "frameworks": { 
    "netstandard1.6": { 
     "imports": "dnxcore50" 

    } 
    } 
} 

.Asp.Net .NetCore項目 - Project.Json

{ 
    "dependencies": { 
    "Microsoft.NETCore.App": { 
     "version": "1.0.1", 
     "type": "platform" 
    }, 
    "Microsoft.AspNetCore.AngularServices": "1.0.0-*", 
    "Microsoft.AspNetCore.Diagnostics": "1.0.0", 
    "Microsoft.AspNetCore.Mvc": "1.0.1", 
    "Microsoft.AspNetCore.Razor.Tools": { 
     "version": "1.0.0-preview2-final", 
     "type": "build" 
    }, 
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", 
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1", 
    "Microsoft.AspNetCore.StaticFiles": "1.0.0", 
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", 
    "Microsoft.Extensions.Configuration.Json": "1.0.0", 
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0", 
    "Microsoft.Extensions.Logging": "1.0.0", 
    "Microsoft.Extensions.Logging.Console": "1.0.0", 
    "Microsoft.Extensions.Logging.Debug": "1.0.0", 
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", 
    "CustomerOrder.Data": "1.0.0-*" }, 

    "tools": { 
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final", 
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final", 
    "Microsoft.DotNet.Watcher.Tools": "1.0.0-preview2-final" 
    }, 

    "frameworks": { 
    "netcoreapp1.0": { 
     "imports": [ 
     "dotnet5.6", 
     "portable-net45+win8" 
     ] 
    } 
    }, 

    "buildOptions": { 
    "emitEntryPoint": true, 
    "preserveCompilationContext": true 
    }, 

    "runtimeOptions": { 
    "configProperties": { 
     "System.GC.Server": true 
    } 
    }, 

    "publishOptions": { 
    "include": [ 
     "appsettings.json", 
     "ClientApp/dist", 
     "node_modules", 
     "Views", 
     "web.config", 
     "wwwroot" 
    ] 
    }, 

    "scripts": { 
    "prepublish": [ 
     "npm install", 
     "node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod", 
     "node node_modules/webpack/bin/webpack.js --env.prod" 
    ], 
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] 
    }, 

    "tooling": { 
    "defaultNamespace": "CustomerOrder.Web" 
    } 
} 

更新版本

{ 
    "dependencies": { 
    "Microsoft.NETCore.App": { 
     "version": "1.1.0", 
     "type": "platform" 
    }, 
    "Microsoft.AspNetCore.AngularServices": "1.1.0-beta-000001", 
    "Microsoft.AspNetCore.Diagnostics": "1.1.0", 
    "Microsoft.AspNetCore.Mvc": "1.1.0", 
    "Microsoft.AspNetCore.Razor.Tools": { 
     "version": "1.1.0-preview4-final", 
     "type": "build" 
    }, 
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", 
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", 
    "Microsoft.AspNetCore.StaticFiles": "1.1.0", 
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", 
    "Microsoft.Extensions.Configuration.Json": "1.0.0", 
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0", 
    "Microsoft.Extensions.Logging": "1.1.0", 
    "Microsoft.Extensions.Logging.Console": "1.1.0", 
    "Microsoft.Extensions.Logging.Debug": "1.0.0", 
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0" 
    }, 

    "tools": { 
    "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final", 
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final", 
    "Microsoft.DotNet.Watcher.Tools": "1.1.0-preview4-final" 
    }, 

    "frameworks": { 
    "netcoreapp1.1": { 
     "imports": [ 
     "dotnet5.6", 
     "portable-net45+win8" 
     ] 
    } 
    }, 

    "buildOptions": { 
    "emitEntryPoint": true, 
    "preserveCompilationContext": true 
    }, 

    "runtimeOptions": { 
    "configProperties": { 
     "System.GC.Server": true 
    } 
    }, 

    "publishOptions": { 
    "include": [ 
     "appsettings.json", 
     "ClientApp/dist", 
     "node_modules", 
     "Views", 
     "web.config", 
     "wwwroot" 
    ] 
    }, 

    "scripts": { 
    "prepublish": [ 
     "npm install", 
     "node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod", 
     "node node_modules/webpack/bin/webpack.js --env.prod" 
    ], 
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] 
    }, 

    "tooling": { 
    "defaultNamespace": "CustomerOrder.Web" 
    } 
} 
+0

一個錯誤是您要混合包版本。例如。 '「Microsoft.AspNetCore.Server.IISIntegration」:「1.0.0」和「」Microsoft.AspNetCore.Server.Kestrel「:」1.0.1「'。嘗試爲所有與aspnetcore相關的軟件包使用'1.0.1'。 –

+0

您的意思是版本1.1.0,因爲我沒有得到錯誤,當我把1.0.1,並沒有出現在intellisense – Tom

+0

你有沒有.net核心1.1.0安裝?如果是,則使用'1.1.0'。記得更新你的project.json。例如:'netcoreapp1.1'和''version「:」1.1.0「,' –

回答

0

現在已經解決了。我已經將「win10-x64」應用於以下框架部分,並且工作正常。

"frameworks": { 
    "netcoreapp1.0": { 
     "imports": [ 
     "dotnet5.6", 
     "win10-x64" 
     ] 
    } 
    }, 
相關問題