dotnet build fails for C++ projects
See original GitHub issueI’m having an issue working with the dotnet tools and c++ projects. I initially encountered this issue using a c++ project as a reference to a C# project. However I have replicated it using a brand new c++ project in it’s own solution.
I’m probably raising this issue at the wrong part of the build chain, but any help would be greatly appreciated.
Steps to reproduce
- Create a new C++ Dynamic link library in Visual Studio 2019
- From the solution folder run
dotnet build
Expected behavior
Solution builds successfully
Actual behavior
error MSB4019: The imported project “C:\Microsoft.Cpp.Default.props” was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
It seems that the $(VCTargetsPath) variable is not being evaluated. I thought this might be just my machine having the issue, but i’m also seeing the same issue building the project in a server environment.
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
Strangely the solution builds fine from the visual studio UI
Environment data
.NET Core SDK (reflecting any global.json): Version: 2.2.203 Commit: e5bab63eca
Runtime Environment: OS Name: Windows OS Version: 6.1.7601 OS Platform: Windows RID: win7-x64 Base Path: C:\Program Files\dotnet\sdk\2.2.203\
Host (useful for support): Version: 2.2.4 Commit: f95848e524
.NET Core SDKs installed: 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.504 [C:\Program Files\dotnet\sdk] 2.1.505 [C:\Program Files\dotnet\sdk] 2.1.602 [C:\Program Files\dotnet\sdk] 2.2.103 [C:\Program Files\dotnet\sdk] 2.2.202 [C:\Program Files\dotnet\sdk] 2.2.203 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.9 [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.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.4 [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 4 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
Top GitHub Comments
Thanks that does make sense. So I guess I should use
msbuild
instead ofdotnet build
Given that c++ projects are not supported do you think the error message should be a bit clearer. Something along the lines of
Although this is not officially supported, as said. I would like to point out that this official hosting sample works around it by wrapping a C++ project around a .csproj container: https://github.com/dotnet/samples/tree/master/core/hosting/HostWithHostFxr
At the very least, for now it can serve as an idea.
Edit: For Windows users, I would like to point out that building using Visual Studio from the command line is also possible.
Consider using
devenv -h
from the Visual Studio Developer Command Prompt to get a list of the available flags.