2
我下載了一個私人的git項目,其他開發者一直在努力幾個月。在構建項目時,遇到以下幾個問題:IApplicationBuilder UseCookieAuthentication擴展方法在哪裏?
- 要最初恢復軟件包,我需要從命令行執行
dnu restore
。從Visual Studio 2015中恢復包似乎很好。 - 一個項目在.cs文件中仍然有一些缺失引用。我通過將軟件包添加到相應的
project.json
文件來修復它。
現在我只剩下一個錯誤: IApplicationBuilder does not contain a definition for 'UseCookieAuthentication
...
代碼期望一個匿名函數:
app.UseCookieAuthentication(options =>
{
options.AuthenticationScheme = "NLCookieMiddleware";
options.LoginPath = new PathString("/api/Account/Login/");
//options.AccessDeniedPath = new PathString("/Account/Forbidden/");
options.AutomaticAuthenticate = true;
options.AutomaticChallenge = true;
});
有什麼困惑,我的是,其他開發人員版本是不罰款在其project.json文件中添加了其他任何引用。對他們來說,工作文件是:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"AutoMapper": "3.3.1",
"Core": "1.0.0-*",
"Data.EF": "1.0.0-*",
"FluentMigrator": "1.6.0",
"HtmlAgilityPack": "1.4.9",
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
"Microsoft.AspNet.Hosting": "1.0.0-rc1-final",
"Microsoft.AspNet.Identity": "3.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
"Microsoft.AspNet.Identity.Owin": "1.0.0-rc1",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.Core": "6.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Abstractions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration": "1.0.0-rc1-final",
"WindowsAzure.Storage": "5.0.0",
"System.Net.Http": "4.0.0",
"RazorEngine": "4.2.3-beta1",
"Microsoft.AspNet.Razor": "4.0.0-rc1-final",
"premailer.net": "1.4.2",
"Microsoft.Net.Http.Client": "1.0.0-beta6",
"Moq": "4.2.1510.2205",
"Serilog.Framework.Logging": "1.0.0-rc1-final-10071",
"Microsoft.AspNet.WebApi.Client": "5.2.3",
"Microsoft.Net.Http.Server": "1.0.0-rc1-final",
"StructureMap.Dnx": "0.4.0-alpha4"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"dependencies": {
"CMS.Services.Contracts": "1.0.0-*",
"CSharpSDK": "1.0.0-*",
"Lookups.Contracts": "1.0.0-*",
"Services.Internal.Contracts": "1.0.0-*"
},
"frameworkAssemblies": {
"System.ServiceModel": "4.0.0.0",
"System.DirectoryServices.AccountManagement": "4.0.0.0"
}
}
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
]
}
我已經添加了其他無數的包,並試圖舊版本的人,沒有運氣:
- Microsoft.AspNet.Authentication.Cookies
- Microsoft.Owin .Security.Cookies.Interop
此擴展方法在哪裏存在?爲什麼其他開發者不會遇到這個問題?
對於我剛剛關閉Visual Studio並重新打開它修復此錯誤。 我已經添加了nuget軟件包Microsoft.AspNetCore.Authentication.Cookies – Paul