# cmake problems with MSBuild.exe

**URL:** https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875
**Category:** Usage
**Tags:** os:windows
**Created:** [March 27, 2020, 8:04pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875 "2020-03-27T20:04:24Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![userJB](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/u/dec6dc/32.png) [@userJB](https://discourse.cmake.org/u/userJB)
#### Post date: [March 27, 2020, 8:04pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/1 "2020-03-27T20:04:24Z")

</div>

have problems with cmake on Windows 10. I pruned things to the smallest example that will generate the same errors. I run cmake from the Windows command prompt (the same problem occurs with the git bash command-line interpreter, of the Visual Studio command prompt ). My CMakeLists.txt contains three lines:

```auto
    cmake_minimum_required(VERSION 3.1)

    project(DEBUG bogus)

```

I run cmake this way:

`cmake -G "Visual Studio 15 2017 Win64" .`

A MSBuild.exe window pops up briefly with an error message, but I can’t read it. It’s gone too fast.

The command-line window displays this error message:

```auto
CMake Error at CMakeLists.txt:3 (project):

  Failed to run MSBuild command:

    C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/MSBuild/15.0/Bin/MSBuild.exe

  to get the value of VCTargetsPath:

-- Configuring incomplete, errors occurred!

See also "C:/Users/tmpuser/Desktop/SDK/dependencies/DEBUG/CMakeFiles/CMakeOutput.log".

```

The executable for MSBuild.exe does indeed exist. The CmakeOutput.log file contains:

```auto
The system is: Windows - 10.0.17763 - AMD64

```

Does anyone know what is wrong?

---

<div class="post-metadata">

### Author: ![anon45792294](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@anon45792294](https://discourse.cmake.org/u/anon45792294)
#### Post date: [March 29, 2020, 6:06am UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/2 "2020-03-29T06:06:36Z")

</div>

Could you try running this instead? I’m not sure why you are calling the project command like that.

```auto
cmake_minimum_required(VERSION 3.1)

project(bogus)

```

---

<div class="post-metadata">

### Author: ![userJB](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/u/dec6dc/32.png) [@userJB](https://discourse.cmake.org/u/userJB)
#### Post date: [March 29, 2020, 1:01pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/3 "2020-03-29T13:01:13Z")

</div>

Thank you. Yes, I tried that and it produced the same result.

---

<div class="post-metadata">

### Author: ![fdk17](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/ea666f/32.png) [@fdk17](https://discourse.cmake.org/u/fdk17)
#### Post date: [March 29, 2020, 3:53pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/4 "2020-03-29T15:53:15Z")

</div>

The error wasn’t necessarily that `MSBuild.exe` couldn’t be found but that getting the value of `VCTargetsPath` failed.

There are a few open / closed issues that can be found when searching for `VCTargetsPath`  
[https://gitlab.kitware.com/cmake/cmake/-/issues/17349](https://gitlab.kitware.com/cmake/cmake/-/issues/17349)

I would first check that MSBuild.exe is working and building projects from the command line to verify the installation is working correctly.

---

<div class="post-metadata">

### Author: ![userJB](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/u/dec6dc/32.png) [@userJB](https://discourse.cmake.org/u/userJB)
#### Post date: [March 29, 2020, 5:25pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/5 "2020-03-29T17:25:21Z")

</div>

Thank you. I can run MSBuild.exe from the command line and it doesn’t immediately fail. I’m a Linux guy, and I’ve never used MSBuild before. I don’t know how to tell if it’s fully working. Can you suggest a few command-line options for MSBuild.exe to verify that it was installed and working properly?

---

<div class="post-metadata">

### Author: ![userJB](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/u/dec6dc/32.png) [@userJB](https://discourse.cmake.org/u/userJB)
#### Post date: [March 29, 2020, 5:30pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/6 "2020-03-29T17:30:27Z")

</div>

For example, when cmake tries to run MSBuild.exe, what command-line arguments does to use?

---

<div class="post-metadata">

### Author: ![userJB](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/u/dec6dc/32.png) [@userJB](https://discourse.cmake.org/u/userJB)
#### Post date: [March 29, 2020, 5:36pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/7 "2020-03-29T17:36:24Z")

</div>

What should `VCTargetsPath` be set to? Should the user (me) set that explicitly? Or should it be set by the system somewhere?

---

<div class="post-metadata">

### Author: ![userJB](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/u/dec6dc/32.png) [@userJB](https://discourse.cmake.org/u/userJB)
#### Post date: [March 31, 2020, 12:21pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/8 "2020-03-31T12:21:27Z")

</div>

Is anybody going to help me resolve this? Should I submit a bug report?

---

<div class="post-metadata">

### Author: ![fdk17](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/ea666f/32.png) [@fdk17](https://discourse.cmake.org/u/fdk17)
#### Post date: [March 31, 2020, 6:07pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/9 "2020-03-31T18:07:01Z")

</div>

The general steps would be to:  
Open Visual Studio  
Generate a new project with the Console App project (Prints “hello world” to console)  
Open the “Developer Command Prompt”  
Navigate to where the project .sln was created  
Run MSbuild.exe ConsoleApplication1.sln  
Watch it build the solution.

This is what I did for Visual Studio 2019 to run MSBuild.exe.  
.

---

<div class="post-metadata">

### Author: ![userJB](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/u/dec6dc/32.png) [@userJB](https://discourse.cmake.org/u/userJB)
#### Post date: [March 31, 2020, 6:19pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/10 "2020-03-31T18:19:28Z")

</div>

How does one Open the “Developer Command Prompt”?

---

<div class="post-metadata">

### Author: ![userJB](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/u/dec6dc/32.png) [@userJB](https://discourse.cmake.org/u/userJB)
#### Post date: [March 31, 2020, 6:20pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/11 "2020-03-31T18:20:04Z")

</div>

I have VisualStudio 2017. There is no “Developer Command Prompt”.

---

<div class="post-metadata">

### Author: ![userJB](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/u/dec6dc/32.png) [@userJB](https://discourse.cmake.org/u/userJB)
#### Post date: [March 31, 2020, 6:28pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/12 "2020-03-31T18:28:19Z")

</div>

I feel like I did my part. I created the minimal cmake configuration that fails. I think you should either tell me what I did was wrong, or cmake is broken and that should be fixed. It should be easy from here.

---

<div class="post-metadata">

### Author: ![McMartin](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mcmartin/32/150_2.png) [@McMartin](https://discourse.cmake.org/u/McMartin)
#### Post date: [March 31, 2020, 7:22pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/13 "2020-03-31T19:22:08Z")

</div>

It is called “Developer Command Prompt for VS 2017”, you can normally find it under Start \> Visual Studio 2017 \> Developer Command Prompt for VS 2017.

If you really don’t have it, then maybe some required components of VS 2017 are not installed. Please start “Visual Studio Installer”, click on “Modify” and make sure that the “Visual C++ core desktop features” component of the “Desktop development with C++” workload is installed (on the right side).

I hope this helps.

---

<div class="post-metadata">

### Author: ![userJB](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/u/dec6dc/32.png) [@userJB](https://discourse.cmake.org/u/userJB)
#### Post date: [March 31, 2020, 7:39pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/14 "2020-03-31T19:39:01Z")

</div>

Okay, thanks for your help. I found the developer prompt. And I got the simple ConsoleApp program to compile with no errors. I’m not sure what this accomplishes.

---

<div class="post-metadata">

### Author: ![userJB](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/u/dec6dc/32.png) [@userJB](https://discourse.cmake.org/u/userJB)
#### Post date: [March 31, 2020, 7:46pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/15 "2020-03-31T19:46:08Z")

</div>

After following the above instructions for the ConsoleAPp, I tried to run cmake on my simple CMakeLists.txt that had been giving me problems. Now it works. I did nothing different.

---

<div class="post-metadata">

### Author: ![userJB](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/u/dec6dc/32.png) [@userJB](https://discourse.cmake.org/u/userJB)
#### Post date: [March 31, 2020, 7:46pm UTC](https://discourse.cmake.org/t/cmake-problems-with-msbuild-exe/875/16 "2020-03-31T19:46:39Z")

</div>

I guess this means my problem is “solved”. Thank everyone for the help.
