Я пытаюсь запустить сборку docker для приложения. net, исходный код здесь: https://github.com/NileshGule/AKS-learning-series/tree/master/src
После выполнения действий я получаю сообщение об ошибке :
Web/Startup.cs(30,56): error CS0246: The type or namespace name 'IWebHostEnvironment' could not be found (are you missing a using directive or an assembly reference?) [/TechTalksWeb/TechTalksWeb.csproj]
Я считаю, что это устарело в. Net 3.0, но я включен. Net 2.1
dotnet --version
2.1.607
Полный вывод строение ниже
➜ TechTalksWeb git:(master) ✗ docker build .
Sending build context to Docker daemon 6.879MB
Step 1/11 : FROM microsoft/dotnet:2.1.300-sdk AS build-env
---> 90a5a2ee9755
Step 2/11 : WORKDIR /TechTalksWeb
---> Running in bf2efd408659
Removing intermediate container bf2efd408659
---> b5c1c0a8f026
Step 3/11 : COPY NuGet.config ./
---> 2fbe7f9eb0ba
Step 4/11 : COPY TechTalksWeb.csproj ./
---> 49e1c29e4144
Step 5/11 : RUN dotnet restore
---> Running in bfb23ac61bbf
Restoring packages for /TechTalksWeb/TechTalksWeb.csproj...
Generating MSBuild file /TechTalksWeb/obj/TechTalksWeb.csproj.nuget.g.props.
Generating MSBuild file /TechTalksWeb/obj/TechTalksWeb.csproj.nuget.g.targets.
Restore completed in 1.4 sec for /TechTalksWeb/TechTalksWeb.csproj.
Removing intermediate container bfb23ac61bbf
---> 2b5068160dd8
Step 6/11 : COPY . ./
---> d6e2551f5bfb
Step 7/11 : RUN dotnet publish --configuration Release --output releaseOutput --no-restore
---> Running in f08fbc49c68f
Microsoft (R) Build Engine version 15.7.179.6572 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Web/Startup.cs(30,56): error CS0246: The type or namespace name 'IWebHostEnvironment' could not be found (are you missing a using directive or an assembly reference?) [/TechTalksWeb/TechTalksWeb.csproj]
The command '/bin/sh -c dotnet publish --configuration Release --output releaseOutput --no-restore' returned a non-zero code: 1
Данная строка является частью startup.cs
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
Полный код ниже:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Web
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}