dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.38k stars 9.99k forks source link

Unable to build from command line: restore.cmd/build.cmd fails #33411

Open shirhatti opened 3 years ago

shirhatti commented 3 years ago

Describe the bug

Unable to build from command line: restore.cmd/build.cmd fails.

(Running .\build.cmd /p:BuildNative=false also fails)

To Reproduce

Running restore.cmd fails on main ( which is currently at 0ecf4c1bd9526c36356a0f259d90aafdf0756fcd)

Exceptions (if any)

Build FAILED.

C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\AspNetCore\AspNetCore.vcxproj(39,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-
alpha\tools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-alpha\tools
\MSBuild\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\IISLib\IISLib.vcxproj(36,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-alpha\to
ols\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-alpha\tools\MSBuild
\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\InProcessRequestHandler\InProcessRequestHandler.vcxproj(38,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\aspnetc
ore\.tools\msbuild\16.5.0-alpha\tools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.tools\
msbuild\16.5.0-alpha\tools\MSBuild\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\OutOfProcessRequestHandler\OutOfProcessRequestHandler.vcxproj(38,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\a
spnetcore\.tools\msbuild\16.5.0-alpha\tools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.
tools\msbuild\16.5.0-alpha\tools\MSBuild\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\RequestHandlerLib\RequestHandlerLib.vcxproj(36,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\aspnetcore\.tools\m
sbuild\16.5.0-alpha\tools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5
.0-alpha\tools\MSBuild\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\RequestHandlerLib\RequestHandlerLib.vcxproj(36,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\aspnetcore\.tools\m
sbuild\16.5.0-alpha\tools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5
.0-alpha\tools\MSBuild\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\IISLib\IISLib.vcxproj(36,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-alpha\to
ols\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-alpha\tools\MSBuild
\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\CommonLibTests\CommonLibTests.vcxproj(41,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild
\16.5.0-alpha\tools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-alp
ha\tools\MSBuild\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\CommonLibTests\CommonLibTests.vcxproj(41,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild
\16.5.0-alpha\tools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-alp
ha\tools\MSBuild\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\OutOfProcessRequestHandler\OutOfProcessRequestHandler.vcxproj(38,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\a
spnetcore\.tools\msbuild\16.5.0-alpha\tools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.
tools\msbuild\16.5.0-alpha\tools\MSBuild\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\InProcessRequestHandler\InProcessRequestHandler.vcxproj(38,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\aspnetc
ore\.tools\msbuild\16.5.0-alpha\tools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.tools\
msbuild\16.5.0-alpha\tools\MSBuild\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\AspNetCore\AspNetCore.vcxproj(39,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-
alpha\tools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-alpha\tools
\MSBuild\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\gtest\gtest.vcxproj(39,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-alpha\tool
s\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-alpha\tools\MSBuild\M
icrosoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\CommonLib\CommonLib.vcxproj(36,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-al
pha\tools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-alpha\tools\M
SBuild\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\CommonLib\CommonLib.vcxproj(36,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-al
pha\tools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-alpha\tools\M
SBuild\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
C:\Users\shirh\source\repos\aspnetcore\src\Servers\IIS\AspNetCoreModuleV2\gtest\gtest.vcxproj(39,3): error MSB4019: The imported project "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-alpha\tool
s\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Users\shirh\source\repos\aspnetcore\.tools\msbuild\16.5.0-alpha\tools\MSBuild\M
icrosoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
    0 Warning(s)
    16 Error(s)

Time Elapsed 00:00:15.57
Build failed with exit code 1. Check errors above.

Further technical details

.NET SDK (reflecting any global.json):
 Version:   6.0.100-preview.5.21264.3
 Commit:    94d9b1ee65

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.21390
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Users\shirh\source\repos\aspnetcore\.dotnet\sdk\6.0.100-preview.5.21264.3\

Host (useful for support):
  Version: 6.0.0-preview.6.21308.1
  Commit:  d52f925042

.NET SDKs installed:
  6.0.100-preview.5.21264.3 [C:\Users\shirh\source\repos\aspnetcore\.dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.14 [C:\Users\shirh\source\repos\aspnetcore\.dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.5.21263.4 [C:\Users\shirh\source\repos\aspnetcore\.dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.27 [C:\Users\shirh\source\repos\aspnetcore\.dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.14 [C:\Users\shirh\source\repos\aspnetcore\.dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-preview.5.21263.1 [C:\Users\shirh\source\repos\aspnetcore\.dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-preview.6.21308.1 [C:\Users\shirh\source\repos\aspnetcore\.dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.0-preview.5.21262.4 [C:\Users\shirh\source\repos\aspnetcore\.dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
shirhatti commented 3 years ago

Turns out this was my mistake. Running ./eng/scripts/InstallVisualStudio.ps1 -Edition Enterprise -Channel Preview fixed it for me.

Leaving this issue open in case we want to add anything to the build scripts to make this easier to diagnose.

dougbu commented 3 years ago

Documents already say

If you don't have visual studio installed you can run eng/scripts/InstallVisualStudio.ps1 to install the exact required dependencies.

Is the action here to:

If yes, the fix would be in https://github.com/dotnet/aspnetcore/blob/main/docs/BuildFromSource.md and this would be a good first issue (hint, hint).

shirhatti commented 3 years ago

Is the action here to:

  • Mention the need to run this script if builds complain of missing components (when the script wasn't used before)❔
  • Stop mentioning preview versions now that 16,10 is out❔

I'd rather the build not fail when I've explicitly mentioned .\build.cmd /p:BuildNative=false.

dougbu commented 3 years ago

I'd rather the build not fail when I've explicitly mentioned .\build.cmd /p:BuildNative=false.

There are still doc problems in that we don't need preview versions of VS at the moment and don't mention InstallVisualStudio.ps1 as a fix when paths like .tools\msbuild\16.5.0-alpha\ show up in the logs prior to a build break.

In addition to that, /p:BuildNative=false doesn't actually disable native builds because the -buildNative default in eng/build.ps1 will override that property setting. Use -noBuildNative instead. That would be safer anyway because it completely skips the desktop msbuild step and will use only dotnet msbuild.

shirhatti commented 3 years ago

Use -noBuildNative instead

Ah thank you! That's what I was looking for

KevRitchie commented 3 years ago

Hi @dougbu, I'd be happy to make the changes to the document if it's still required?

dougbu commented 3 years ago

Hi @dougbu, I'd be happy to make the changes to the document if it's still required?

If a doc change would have helped you, @shirhatti, or others get going in this repo, I'm all for it. Much appreciated @KevRitchie❕

KevRitchie commented 3 years ago

No problem @dougbu.

In summary the changes would be:

That look OK?

dougbu commented 3 years ago

That look OK?

Sounds great. Thanks @KevRitchie❕

adrianwright109 commented 2 years ago

Sounds like the Build From Source instructions have been redesigned so this issue may no longer be relevant. See comment

dougbu commented 2 years ago

@dotnet/aspdoi this or similar problems come up most times we change our VS requirements and it's not clear how best to inform our community. A pinned issue for (say) two weeks after we add a new component or stop supporting a VS version might work but I've heard comments about usability there. Ideas much appreciated.

BrennanConroy commented 2 years ago

A curated error message would be great instead of some random vcxproj error that no one understands. Like if there was a way for us to see what you have available on the machine and compare it to what is required.

ilonatommy commented 1 year ago

I have a similar problem, only updating VS does not help, no matter if I run ./eng/scripts/InstallVisualStudio.ps1 or manually upload .vsconfig to the installer.

Running ./restore.cmd, results in:

 Restore was successful.
  All projects are up-to-date for restore.
Attempting to install dotnet from public location.
dotnet-install: Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:
dotnet-install: - The SDK needs to be installed without user interaction and without admin rights.
dotnet-install: - The SDK installation doesn't need to persist across multiple CI runs.
dotnet-install: To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer.
dotnet-install: .NET Core Runtime with version '8.0.0-alpha.1.23067.2' is already installed.
dotnet-install: Adding to current process PATH: "source\repos\aspnetcore\.dotnet\x86\". Note: This change will not be visible if PowerShell was run as a child process.
Attempting to install dotnet from public location.
dotnet-install: Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:
dotnet-install: - The SDK needs to be installed without user interaction and without admin rights.
dotnet-install: - The SDK installation doesn't need to persist across multiple CI runs.
dotnet-install: To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer.
dotnet-install: .NET Core Runtime with version '8.0.0-alpha.1.23067.2' is already installed.
dotnet-install: Adding to current process PATH: "source\repos\aspnetcore\.dotnet\". Note: This change will not be visible if PowerShell was run as a child process.
.nuget\packages\microsoft.dotnet.arcade.sdk\8.0.0-beta.23063.7\tools\Build.proj(221,5): error MSB3202: The project file "source\repos\aspnetcore\src\**\*.vcxproj" was not found.
.nuget\packages\microsoft.dotnet.arcade.sdk\8.0.0-beta.23063.7\tools\Build.proj(221,5): error MSB3202: The project file "source\repos\aspnetcore\src\**\*.vcxproj" was not found.
.nuget\packages\microsoft.dotnet.arcade.sdk\8.0.0-beta.23063.7\tools\Build.proj(221,5): error MSB3202: The project file "source\repos\aspnetcore\src\**\*.vcxproj" was not found.

Build FAILED.

Edit: removing the repository and cloning again (in the same location) solved this problem.