I am trying to run a C++ solution project on VS Code, while the rest of my team (and me currently) are running on Visual Studio. I am using C# devkit to run solutions in VS Code. And I want to use all of VS Code's extensions while I am programming at work.
The error shows up when I select the solution and start the build.
Error Msg:
The imported file "$(VCTargetsPath)/Microsoft.Cpp.Default.props" does not exist and appears to be a Visual Studio component. This file may require MSBuild.exe in order to be imported successfully, and so may fail to build in the dotnet CLI. I have:
I am on an Air gapped network, and my codebase compiles in Visual Studio just fine.
I can not change my project to CMAKE, and the code still needs to run in Visual Studio for most of my team.
I'm guessing your question is - can the C++ project be built without Visual Studio installed?
No, the project can't be built without Visual Studio.
C++ projects are structured differently than C# projects. The .vcxproj MSBuild project file imports and depends on a set of files that are installed with Visual Studio. MSBuild is embedded in the dotnet tool but dotnet doesn't "know" about Visual Studio, won't attempt to locate a VS install, and won't find the project dependencies. The dotnet tool can't build a .vcxproj project.
Note that you can add a terminal profile that matches the "Visual Studio Developer Command Prompt" to the integrated terminal in VS Code. In the Dev Cmd Prompt, the MSBuild.exe will be in the PATH. It's probably not what you were hoping for, but you can edit a source file and run a build of the solution without leaving VS Code.