sdk: dotnet build error - the project 'Web' must provide a value for Configuration

Steps to reproduce

I run this command to build an aspnet core project(Web is the startup project)

dotnet build X.sln -c Release --no-cache --source “\\local_source\packages” --source “https://api.nuget.org/v3/index.json

Expected behavior

Build should be successful.

The same issue was raised by our TFS autobuild. When I tried on my local machine I get the same error. But I have no clue what could be wrong here. There is this post here but I doubt this is related to razor only. And also, the solution there was not very clear and (re-installing the sdk) won’t be an option (especially on the build server).

Actual behavior

I get the following error right after the packages has been restored:

C:\Users\MyUser\.nuget\packages\microsoft.aspnetcore.razor.design\2.1.1\build\netstandard2.0\Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets(121,5): error : The project D:\Workspaces\X\src\Web must provide a value for Configuration. [D:\Workspaces\X\src\Web\Web.csproj]

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json): Version: 2.1.403 Commit: 04e15494b6

Runtime Environment: OS Name: Windows OS Version: 6.1.7601 OS Platform: Windows RID: win7-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.403\

Host (useful for support): Version: 2.1.5 Commit: 290303f510

.NET Core SDKs installed: 1.0.4 [C:\Program Files\dotnet\sdk] 2.1.4 [C:\Program Files\dotnet\sdk] 2.1.102 [C:\Program Files\dotnet\sdk] 2.1.103 [C:\Program Files\dotnet\sdk] 2.1.104 [C:\Program Files\dotnet\sdk] 2.1.200 [C:\Program Files\dotnet\sdk] 2.1.201 [C:\Program Files\dotnet\sdk] 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.300 [C:\Program Files\dotnet\sdk] 2.1.400 [C:\Program Files\dotnet\sdk] 2.1.402 [C:\Program Files\dotnet\sdk] 2.1.403 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22 (3 by maintainers)

Commits related to this issue

Most upvoted comments

I had this infuriating issue when migrating a .NET Core 2.2 app to core 3.0. 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.

You might need to restart VS too in some cases (see @JerryBian’s comment below).

(I’ve stuck this answer on Stack Overflow too to make it a bit more visible as it looks like a lot of people are having this issue. So if none of the above fixes the issue you could check that question too in case more answers get added there)

Exactly like @tomRedox explained.

For me just one additional step - restart Visual Studio to make it effective. Possible some cache file - not sure.

Yap… if this is related to update from 2.2 to 3.0

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.

Thank you @tomRedox , in my mixed version solution, I had a legacy web project using 2.2 converted to 3 and it was still referencing Microsoft.AspNetCore.Razor.Design Version=“2.2.0”

I’m a bit ashamed to not have looked at the references before. I guess the config value error message was distracting.

my 2 cents: I had to use the metapackage Microsoft.AspNetCore.App in order to get rid of this error.

thanks @tomRedox - I would have spent hours to debug this issue without your suggestion.

I tried by removing Microsoft.AspNetCore.Mvc 2.20 and Microsoft.AspNetCore.Razor.Design then the issue gone.

Sorry to bump this. (definetely not a CLI issue!!)

Just calling in to say if removing the packages doesn’t do it in Visual Studio, try cleaning the solution and then building anew. That’s all.

@bbqchickenrobot Try removing your dependencies. After a while i found out what caused the issue for me. In my case it was a dependency on AspNetCore.RouteAnalyzer which relied on certain netcore versions. I assume that got the build configuration into a conflict. At least by referencing/dereferencing that nuget package i was able to toggle the issue on and off for me.

Interesting. In some sample solution this fixed the issue, in my actual application it doesn’t work.

So when I specified the target framework (-f|–framework) then the build/publish was successful.

Have you tried building the project instead of the solution?