2016-05-29 60 views
1

引用當地建造NuGet包進行診斷後(克隆/當前回購的構建 - 我的機器上它的建成爲「Microsoft.AspNetCore.Diagnostics」:「1.0.0-t002a46b59」)在未觸及的RC2 ASP.NET Web App中,NuGet會自動開始恢復軟件包。與當地的NuGet包不明確的參考

這樣做似乎是因爲我的Program.cs無法區分我想使用的.UseContentRoot的版本而創建了一個模棱兩可的引用。

enter image description here

我沒有足夠的熟悉程度project.json和的NuGet關係,以確定問題的根源是什麼。

我是否錯過了該過程中的某個步驟,或者是否存在導致此問題的更基礎的內容?

我project.json如下:

{ 
    "userSecretsId": "aspnet-JamieTest-ffeafaa8-e549-4ce5-89f2-69089954bd81", 

    "dependencies": { 
    "Microsoft.NETCore.App": { 
     "version": "1.0.0-rc2-3002702", 
     "type": "platform" 
    }, 
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-rc2-final", 
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-t002a46b59", 
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0-rc2-final", 
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-final", 
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final", 
    "Microsoft.AspNetCore.Razor.Tools": { 
     "version": "1.0.0-preview1-final", 
     "type": "build" 
    }, 
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final", 
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final", 
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final", 
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final", 
    "Microsoft.EntityFrameworkCore.Tools": { 
     "version": "1.0.0-preview1-final", 
     "type": "build" 
    }, 
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final", 
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final", 
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc2-final", 
    "Microsoft.Extensions.Logging": "1.0.0-rc2-final", 
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final", 
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final", 
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final", 
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": { 
     "version": "1.0.0-preview1-final", 
     "type": "build" 
    }, 
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": { 
     "version": "1.0.0-preview1-final", 
     "type": "build" 
    } 
    }, 

    "tools": { 
    "Microsoft.AspNetCore.Razor.Tools": { 
     "version": "1.0.0-preview1-final", 
     "imports": "portable-net45+win8+dnxcore50" 
    }, 
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": { 
     "version": "1.0.0-preview1-final", 
     "imports": "portable-net45+win8+dnxcore50" 
    }, 
    "Microsoft.EntityFrameworkCore.Tools": { 
     "version": "1.0.0-preview1-final", 
     "imports": [ 
     "portable-net45+win8+dnxcore50", 
     "portable-net45+win8" 
     ] 
    }, 
    "Microsoft.Extensions.SecretManager.Tools": { 
     "version": "1.0.0-preview1-final", 
     "imports": "portable-net45+win8+dnxcore50" 
    }, 
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": { 
     "version": "1.0.0-preview1-final", 
     "imports": [ 
     "portable-net45+win8+dnxcore50", 
     "portable-net45+win8" 
     ] 
    } 
    }, 

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

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

    "runtimeOptions": { 
    "gcServer": true 
    }, 

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

    "scripts": { 
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ], 
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] 
    } 
} 
+1

什麼是依賴於你本地構建的'Microsoft.AspNetCore.Diagnostics'?原因很可能是你的本地構建的'Microsoft.AspNetCore.Diagnostics'提取了一個過時的包(即'Microsoft.AspNet。*'')。所以你最終得到2個版本的相同的程序集(有2個不同的名稱),其中兩個都有相同的擴展方法註冊。這是消息的原因。在解決方案資源管理器的依賴關係樹視圖中檢查引用的庫依賴關係 – Tseng

+0

@Tseng上的現貨 - 我設法找出根本原因。現在發佈一個答案。 –

回答

0

在撰寫aspnet/Diagnostics庫的時間包括commit其中refactors的多個託管基於擴展方法的位置。

不幸的是,文件 - >從RC2新建項目輸出在看以前的位置的擴展方法。由於我的本地構建的NuGet包和RC2輸出使用了不同的實現,因此編譯器無法確定哪一個是正確的。

我沒有打擾paricuarly其執行長被用作他們是一樣的,和阻力最小的路徑是改變我的本地製造NuGet包使用Microsoft.AspNetCore.Hosting的RC2版本 。抽象

雖然這糾正了直接的問題我則在運行期間,在兩個人來到從而使包括依賴注入未能加載需要的類型。

總之,我必須實現三個轉變,以我的診斷project.json文件,以便我在當地建立NuGet包加載,並在Visual Studio中調試的:

enter image description here