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

Created on 14 Nov 2018  路  21Comments  路  Source: dotnet/sdk

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 Filesdotnet\sdk\2.1.403\

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

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

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

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

Most helpful comment

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)

All 21 comments

Have you tried building the project instead of the solution?

I did try to pass the startup project as parameter, yet I get the same error.

I forgot to mention that the solution is built fine under visual studio 17.
It just won't work on the command line.

Any chance you can provide a small repro repo? that we can clone and repro the issue ourselves?

I am trying to make replicate the issue with a standalone/shareable project but no luck so far. The current code base where this is happening is a proprietary code thus I am unable to share it.

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

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

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)

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.

Exactly like @tomRedox explained.

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

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

Same issue here.... frustrating. The Razor design package doesn't exist in any of my projects

@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.

The documentation here explains to remove some packages when updating from v2.2 to 3.0.

https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio-mac#update-the-project-file

I am going to close this issue because it sounds like the problem occurs when migrating from 2.2 to 3.0.

For asp.net, this is not a matter of just retargeting the TFM. More work is needed to migrated, as documented on the link above.

If there are things missing on the documentation, I would suggest filling an issue against asp.net.

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.

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.

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)

This, additionally I had to follow the steps in https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.1&tabs=visual-studio specifically the code replacement under "Startup changes". I had to do this because I was converting my project from version 2.1 to 3.1 Hopefully this will save someone the struggle I had to endure

Hi , I m migrating from .net core 2.1 to 3.1 . I m getting the error as below

The project G:Projects....\
Admin must provide a value for Configuration.
C:\Users\User.nuget\packages\microsoft.aspnetcore.razor.design\2.2.0\build\netstandard2.0
\Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets 79. I m not able to find this reference Microsoft.AspNetCore.Razor.Design in my project. I tried all the above solutions but its not working for me.

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

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

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)

this should be pinned on top! 馃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joffreykern picture joffreykern  路  3Comments

aguacongas picture aguacongas  路  3Comments

thomaslevesque picture thomaslevesque  路  3Comments

darrensimio picture darrensimio  路  3Comments

srivatsn picture srivatsn  路  3Comments