Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft.AspNetCore.Hosting.Abstractions, Version=3.0.0.0 assembly is missing #2194

Closed
martore opened this issue Dec 30, 2018 · 6 comments
Closed
Assignees

Comments

@martore
Copy link

martore commented Dec 30, 2018

Microsoft.AspNetCore.Hosting.Abstractions, Version=3.0.0.0 assembly is missing

I have created new .NET Core 3.0 project, and moved code from .NET Core 2.1 (so far only Startup.cs and Program.cs) to the new project. When started, the following exception is thrown:

System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.AspNetCore.Hosting.Abstractions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.'

NuGet package Microsoft.AspNetCore.Hosting.Abstractions version 3.0.0.0 is not available in NuGet Package Manager. There is only 2.2.0 version.

Is there something I am doing wrong here or I will have to wait on Microsoft.AspNetCore.Hosting.Abstractions to be updated to version 3.0.0.0?

Packages I have included in my project:
Microsoft.AspNetCore.App 3.0.0-preview
Microsoft.AspNETCore.App 3.0.0-preview

@Eilon
Copy link
Member

Eilon commented Jan 8, 2019

@martore can you show what your CSPROJ looks like?

@martore
Copy link
Author

martore commented Jan 9, 2019

ConsoleApp.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" Version="3.0.0-preview-18579-0056" />
  </ItemGroup>

</Project>

Program.cs

using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using System.IO;

namespace ConsoleApp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args)
        {
            var config = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("hostsettings.json", optional: true)
                .AddCommandLine(args)
                .Build();

            return WebHost.CreateDefaultBuilder(args)
                .UseConfiguration(config)
                .UseStartup<Startup>();
        }
    }
}

Startup.cs

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace ConsoleApp
{
    public class Startup
    {
        public IConfiguration Configuration { get; }

        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }
        public void ConfigureServices(IServiceCollection services)
        {

        }

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {

        }
    }
}

These are installed on PC (beside .NET Core 2.2):

  • .NET Core 3.0.0 Preview Build 18579-0056 - Windows Server Hosting
  • ASP.NET Core 3.0.0 Preview Build 18579-0056 - Shared Framework
  • .NET Core SDK 3.0.100

@Eilon
Copy link
Member

Eilon commented Jan 9, 2019

Adding @natemcmaster who is an expert on this.

Two things I suspect:

  1. This line: <PackageReference Include="Microsoft.AspNetCore.App" Version="3.0.0-preview-18579-0056" /> I think shouldn't have the version specified - it's figured out automatically by the SDK based on other things. Or maybe it's not even needed at all anymore (@natemcmaster ?)
  2. The project should be using the Web SDK instead of the plain .NET SDK, so the first line should probably be <Project Sdk="Microsoft.NET.Sdk.Web">

@natemcmaster
Copy link
Contributor

Here is the minimal change you need to make to fix this. cref dotnet/aspnetcore#3612 and https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30

  <ItemGroup>
-   <PackageReference Include="Microsoft.AspNetCore.App" Version="3.0.0-preview-18579-0056" />
+   <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>

The preview 2 SDK should resolve this error automatically. dotnet/sdk#2738

@martore
Copy link
Author

martore commented Jan 10, 2019

Changes suggested in #2194 (comment) resolved the issue. Thanks.

@granadacoder
Copy link

Changes suggested in #2194 (comment) resolved the issue. Thanks.

Thank you for putting a DIRECT breadcrumb to the answer that resolved it. And not a "got it working" with no details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants