# Custom command/target results in MSB8065 warnings in Visual Studio 2022 & 2026

**URL:** https://discourse.cmake.org/t/custom-command-target-results-in-msb8065-warnings-in-visual-studio-2022-2026/15757
**Category:** Code
**Tags:** os:windows, gen:vs
**Created:** [July 23, 2026, 9:54am UTC](https://discourse.cmake.org/t/custom-command-target-results-in-msb8065-warnings-in-visual-studio-2022-2026/15757 "2026-07-23T09:54:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![MarkCallow](https://discourse.cmake.org/user_avatar/discourse.cmake.org/markcallow/32/4823_2.png) [@MarkCallow](https://discourse.cmake.org/u/MarkCallow)
#### Post date: [July 23, 2026, 9:54am UTC](https://discourse.cmake.org/t/custom-command-target-results-in-msb8065-warnings-in-visual-studio-2022-2026/15757/1 "2026-07-23T09:54:57Z")

</div>

I am aware of [Custom command results in MSB8065 warnings in Visual Studio 2019](https://discourse.cmake.org/t/custom-command-results-in-msb8065-warnings-in-visual-studio-2019/4893). That is a different issue. In that case the custom command OUTPUT is not a real file. In this case it is a real file, actually a directory. Setting the `SYMBOLIC` property does not help.

With the following very simple CMake project that has a single custom target to create a directory I am getting the subject warning.

```auto
cmake_minimum_required(VERSION 3.25)
include(CMakePrintHelpers)

project(TestDirCreation
    VERSION 1.0
    DESCRIPTION "Simple test of creating a directory"
)

set(BUILDTIME_RESOURCES_DIR resources)
add_custom_command(
    OUTPUT ${BUILDTIME_RESOURCES_DIR}
    COMMAND ${CMAKE_COMMAND} -E make_directory "${BUILDTIME_RESOURCES_DIR}"
    COMMENT "Make resources directory"
    VERBATIM
)
add_custom_target(
    buildtime_resources_dir
    DEPENDS ${BUILDTIME_RESOURCES_DIR}
)

```

When running the build with this

```auto
cmake --build build --config Release --target buildtime_resources_dir

```

the projects created by both the VS2022 and VS2026 generators give the warning

```auto
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): w
arning MSB8065: Custom build for item "C:\Users\mark\Projects\khronos\github\test_create_dir\build\CMakeFiles\50efc16c9
d132abaa8a164aece7e2f3a\resources.rule" succeeded, but specified output "c:\users\mark\projects\khronos\github\test_cre
ate_dir\build\resources" has not been created. This may cause incremental build to work incorrectly. [C:\Users\mark\Pro
jects\khronos\github\test_create_dir\build\buildtime_resources_dir.vcxproj]

```

But the output file `resources` (actually a directory) is created.

There is no problem when using the Ninja generator.

This is with CMake 4.4. It was happening with earlier versions too.

Any idea what the problem is and how to fix it?

---

<div class="post-metadata">

### Author: ![vito.gamberini](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vito.gamberini/32/4376_2.png) [@vito.gamberini](https://discourse.cmake.org/u/vito.gamberini)
#### Post date: [July 23, 2026, 1:41pm UTC](https://discourse.cmake.org/t/custom-command-target-results-in-msb8065-warnings-in-visual-studio-2022-2026/15757/2 "2026-07-23T13:41:30Z")

</div>

The problem is a directory is not an output, the files contained within the directory are the outputs. `add_custom_command` documents `OUTPUT` as:

> This defines a command to generate specified `OUTPUT` **file(s)**.

Using a directory works accidentally on some generators and doesn’t on others. It’s not within the contract of the command itself.

---

<div class="post-metadata">

### Author: ![MarkCallow](https://discourse.cmake.org/user_avatar/discourse.cmake.org/markcallow/32/4823_2.png) [@MarkCallow](https://discourse.cmake.org/u/MarkCallow)
#### Post date: [July 23, 2026, 2:27pm UTC](https://discourse.cmake.org/t/custom-command-target-results-in-msb8065-warnings-in-visual-studio-2022-2026/15757/3 "2026-07-23T14:27:29Z")

</div>

Thank you for the clarification.

I have two independent targets (executables) sharing a resources directory. Many of the resource files are common to both targets, many are not. I have custom targets and custom commands to install those files. I made the `buildtime_resources_dir` target a dependency of those because I was trying to avoid a race in creating the directory when running a parallel build.

If I remove the `buildtime_resources_dir` target, will the file installation targets create the directory and will they work without races in a parallel build?
