Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"The project 'Web' must provide a value for Configuration" error after migrating to .NET Core 3

I've migrated an ASP.NET Core 2.2 project to Core 3.0 and am getting the error:

The project [Project location] must provide a value for Configuration.

There's not really a lot to go on with that error message, does anyone know how to resolve this error?

This looks like it could be similar to this issue on the dotnet cli github repo.

like image 342
tomRedox Avatar asked Sep 01 '19 14:09

tomRedox


People also ask

Does .NET core require web config?

In order to set up the ASP.NET Core Module correctly, the web. config file must be present at the content root path (typically the app base path) of the deployed app.

Does .NET core still use web config?

Setup configurationASP.NET Core no longer uses the Global. asax and web. config files that previous versions of ASP.NET utilized.

How do I upgrade my net core 3.1 to .NET 5 in Visual Studio 2019?

Open the solution with Visual Studio, right-click on the project, click on “Properties”, and on “Target Framework” change from “. NET 3.1” to “. NET 5”: Do the same for the other project's layers, including the unit tests projects.


4 Answers

The issue turned out to be that I was still referencing Microsoft.AspNetCore.Razor.Design Version="2.2.0" in the .proj file's package references. Deleting that reference (which isn't needed at all as Razor.Design is now part of AspNetCore library) fixed the issue.

Once I'd done that, I then got hundreds of errors about nullable objects being a new feature not compatible with razor. That was because I had <LangVersion>Latest</LangVersion> in my .proj file. Removing that line fixed that issue and got the project running again.

(In some cases you might need to clean and rebuild and/or restart VS too, according to comments on the github thread)

If that doesn't solve it, it's possible that one the NuGet packages used by your project is the cause. Try removing the dependencies to see if that clears the issue, and then re-add them one at a time to work out which NuGet package is the cause.

like image 175
tomRedox Avatar answered Oct 11 '22 14:10

tomRedox


There is an MS document title "Migrate from ASP.NET Core 2.2 to 3.0". Under "Update the project file", it states,

"A large number of NuGet packages aren't produced for ASP.NET Core 3.0. Such package references should be removed from your project file"

The two given as an example are:

  • Microsoft.AspNetCore.App
  • Microsoft.AspNetCore.Razor.Design

Below that, you can expand to see all the packages that are no longer being produced:

  • Microsoft.AspNetCore
  • Microsoft.AspNetCore.All
  • Microsoft.AspNetCore.App
  • Microsoft.AspNetCore.Antiforgery
  • Microsoft.AspNetCore.Authentication
  • Microsoft.AspNetCore.Authentication.Abstractions
  • Microsoft.AspNetCore.Authentication.Cookies
  • Microsoft.AspNetCore.Authentication.Core
  • Microsoft.AspNetCore.Authentication.OAuth
  • Microsoft.AspNetCore.Authorization.Policy
  • Microsoft.AspNetCore.CookiePolicy
  • Microsoft.AspNetCore.Cors
  • Microsoft.AspNetCore.Diagnostics
  • Microsoft.AspNetCore.Diagnostics.HealthChecks
  • Microsoft.AspNetCore.HostFiltering
  • Microsoft.AspNetCore.Hosting
  • Microsoft.AspNetCore.Hosting.Abstractions
  • Microsoft.AspNetCore.Hosting.Server.Abstractions
  • Microsoft.AspNetCore.Http
  • Microsoft.AspNetCore.Http.Abstractions
  • Microsoft.AspNetCore.Http.Connections
  • Microsoft.AspNetCore.Http.Extensions
  • Microsoft.AspNetCore.HttpOverrides
  • Microsoft.AspNetCore.HttpsPolicy
  • Microsoft.AspNetCore.Identity
  • Microsoft.AspNetCore.Localization
  • Microsoft.AspNetCore.Localization.Routing
  • Microsoft.AspNetCore.Mvc
  • Microsoft.AspNetCore.Mvc.Abstractions
  • Microsoft.AspNetCore.Mvc.Analyzers
  • Microsoft.AspNetCore.Mvc.ApiExplorer
  • Microsoft.AspNetCore.Mvc.Api.Analyzers
  • Microsoft.AspNetCore.Mvc.Core
  • Microsoft.AspNetCore.Mvc.Cors
  • Microsoft.AspNetCore.Mvc.DataAnnotations
  • Microsoft.AspNetCore.Mvc.Formatters.Json
  • Microsoft.AspNetCore.Mvc.Formatters.Xml
  • Microsoft.AspNetCore.Mvc.Localization
  • Microsoft.AspNetCore.Mvc.Razor
  • Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
  • Microsoft.AspNetCore.Mvc.RazorPages
  • Microsoft.AspNetCore.Mvc.TagHelpers
  • Microsoft.AspNetCore.Mvc.ViewFeatures
  • Microsoft.AspNetCore.Razor
  • Microsoft.AspNetCore.Razor.Runtime
  • Microsoft.AspNetCore.Razor.Design
  • Microsoft.AspNetCore.ResponseCaching
  • Microsoft.AspNetCore.ResponseCaching.Abstractions
  • Microsoft.AspNetCore.ResponseCompression
  • Microsoft.AspNetCore.Rewrite
  • Microsoft.AspNetCore.Routing
  • Microsoft.AspNetCore.Routing.Abstractions
  • Microsoft.AspNetCore.Server.HttpSys
  • Microsoft.AspNetCore.Server.IIS
  • Microsoft.AspNetCore.Server.IISIntegration
  • Microsoft.AspNetCore.Server.Kestrel
  • Microsoft.AspNetCore.Server.Kestrel.Core
  • Microsoft.AspNetCore.Server.Kestrel.Https
  • Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions
  • Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets
  • Microsoft.AspNetCore.Session
  • Microsoft.AspNetCore.SignalR
  • Microsoft.AspNetCore.SignalR.Core
  • Microsoft.AspNetCore.StaticFiles
  • Microsoft.AspNetCore.WebSockets
  • Microsoft.AspNetCore.WebUtilities
  • Microsoft.Net.Http.Headers
like image 44
Rob Johnston Avatar answered Oct 11 '22 16:10

Rob Johnston


I've had the same issue and it was solved by removing the following references:

"Microsoft.AspNetCore.Mvc" Version="2.2.0"

"Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.2.0"
like image 25
Stefano Avatar answered Oct 11 '22 16:10

Stefano


This is kind of weird.

For me, the problem was because of 'Microsoft.AspNetCore.Mvc' package.

I uninstalled it and installed 'Microsoft.AspNetCore.Mvc.Core'.

I need to add that, I had installed 'Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation' too.

like image 6
Mansoor Omrani Avatar answered Oct 11 '22 15:10

Mansoor Omrani