Compilation via msbuild command is successfull ("%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe" CLRNetCoreTest.sln /p:Configuration=Debug /p:Platform=x86).
And that is very strange - I supposed dotnet to be a wrapper built on the top of msbuild..
Sample project is attached (run Build.bat for compilation).
To add more details:
And that is very strange - I supposed dotnet to be a wrapper built on the top of msbuild.
Agree with Martin, dotnet build
for now doesn't support building C++ project, cause dotnet cli doesn't know where to find the necessary C++ xx.targets
and xx.props
.
Your project is a C++/CLR project(xx.vcxproj) whose target framework is .net core
, it has big difference with actual .net core
projects(xx.csproj or xx.vbproj), the xx.vcxproj
imports many C++ specific files which is not included in .net core sdk
.
For example: Go C:\Program Files\dotnet\sdk\xxx
you can find many msbuild targets and props files there, but you can't find Microsoft.Cpp.Default.props file. This file comes from C++ workload instead of .net core SDK.
So though dotnet build
uses msbuild to build project, it actually doesn't use the same msbuild.exe from VS folder(C:\Program Files (x86)\Microsoft Visual Studio\xxx\xxx\MSBuild\1xxx\Bin\MSBuild.exe
). And only the msbuild.exe from VS IDE or MSBuild build tools package can be used to build this project.
In addition:
If your final goal is to build the project in remote server, maybe you're looking for Build Tools for Visual Studio 2019` package.(Free if you've gotten corresponding lisense, more details see this) It doesn't require VS IDE to be installed. (Download link here)
C++ projects can only be built with the msbuild.exe
shipped with Visual Studio as it relies on Visual Studio's C++ tooling.
The cross-platform dotnet
command with its cross-platform MSBuild distribution does not have these tools and as such unable to compile C++ projects. The dotnet
command does not use the visual studio version of MSBuild.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With