dotnet build error - the project 'Web' must provide a value for Configuration
See original GitHub issueSteps 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
Issue Analytics
- State:
- Created 5 years ago
- Comments:22 (3 by maintainers)
Top GitHub 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.