私はASP.NET Core 1.1.0でWebアプリケーションを開発しています。私のアプリケーションはIIS Expressで動作しました。しかし、私がIISにアプリケーションをデプロイしたときに、「パッケージ 'Microsoft.AspNetCore.Antiforgery'」のコンパイルライブラリの場所を見つけることができませんでした。パッケージ 'Microsoft.AspNetCore.Antiforgery'のコンパイルライブラリの場所が見つかりません
私はproject.jsonからpreserveCompilationContextを削除されたが、私は「つまたは複数のコンパイル参照が不足している。考えられる原因は、アプリケーションのproject.jsonの 『buildOptions』の下で行方不明 『preserveCompilationContext』プロパティが含まれています。」しまいましたエラーメッセージ。
静的ファイル(.htmlなど)は正常に動作しています。
この問題を解決するにはどうすればよいですか?バック
project.json
{
"dependencies": {
"Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
"Microsoft.AspNetCore.Diagnostics": "1.1.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.0",
"Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
"Microsoft.AspNetCore.Routing": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
"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.1.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.1.0",
"Microsoft.Extensions.Logging": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.Extensions.Logging.Debug": "1.1.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
"Microsoft.NETCore.App": "1.1.0"
},
"tools": {
},
"frameworks": {
"netcoreapp1.1": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"nowarn": [],
"copyToOutput": [ "appsettings.json", "appsettings.staging.json" ]
},
"runtimes": {
"win10-x64": {}
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"appsettings.staging.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ],
"precompile": [ "C:\\Windows\\System32\\inetsrv\\appcmd recycle apppool /apppool.name:local.com" ]
}
}
Startup.cs
using System.Collections.Generic;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Localization;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Web.Management
{
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddLocalization(options =>
{
});
// Add framework services.
services
.AddMvc(options =>
{
options.Filters.Add(new ExceptionFilter());
})
.AddViewOptions(options =>
{
});
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseLogger();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
var localizationOptions = new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en-US"),
RequestCultureProviders = new List<IRequestCultureProvider>
{
new QueryStringRequestCultureProvider(),
new CookieRequestCultureProvider(),
new AcceptLanguageHeaderRequestCultureProvider()
}
};
app.UseRequestLocalization(localizationOptions);
HttpContextMiddleware.Configure(app.ApplicationServices.GetRequiredService<IHttpContextAccessor>());
//app.UseStatusCodePages();
app.UseStaticFiles();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationScheme = "AuthCookie",
AutomaticAuthenticate = true,
AutomaticChallenge = false,
LoginPath = new PathString("/login"),
CookieSecure = CookieSecurePolicy.SameAsRequest
});
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}
**以前はproject.jsonから 'preserveCompilationContext'を削除する前に**エラーが発生しましたか? – Sanket
preserveCompilationContextを削除する前に、エラー「** Microsoft.AspNetCore.Antiforgery」**のコンパイルライブラリの場所が見つかりません。 – Mennan
コマンドラインから 'dotnet restore'を試しましたか? – Sanket