# Access to any relative binaryDir path is denied inside Visual Studio

**URL:** https://discourse.cmake.org/t/access-to-any-relative-binarydir-path-is-denied-inside-visual-studio/6742
**Category:** Usage
**Tags:** gen:vs
**Created:** [October 27, 2022, 3:55pm UTC](https://discourse.cmake.org/t/access-to-any-relative-binarydir-path-is-denied-inside-visual-studio/6742 "2022-10-27T15:55:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mojca](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mojca/32/610_2.png) [@mojca](https://discourse.cmake.org/u/mojca)
#### Post date: [October 27, 2022, 3:55pm UTC](https://discourse.cmake.org/t/access-to-any-relative-binarydir-path-is-denied-inside-visual-studio/6742/1 "2022-10-27T15:55:39Z")

</div>

When I open a CMake project with Visual Studio 2022 Preview (17.4.0 Preview 3) and use

```json
"binaryDir": "foo"

```

inside a preset in `CMakePresets.json`, I get an error when configuring the project

```auto
1> Access to the path 'foo' is denied.
Access to the path 'foo' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
   at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
   at Microsoft.VisualStudio.CMake.Project.ExternalBuildProject.ProjectProvider.<ParseProjectAsync>d__46.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
...

```

After switching to

```json
"binaryDir": "${sourceDir}/foo"

```

it starts working.

Documentation at [https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#configure-preset](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#configure-preset) says

> If a relative path is specified, it is calculated relative to the source directory.

So I’m confused if this is a bug somewhere in CMake/Visual Studio or if I’m just misinterpreting the documentation.

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [October 27, 2022, 3:56pm UTC](https://discourse.cmake.org/t/access-to-any-relative-binarydir-path-is-denied-inside-visual-studio/6742/2 "2022-10-27T15:56:51Z")

</div>

My guess is Visual Studio has not implemented the relative path correctly.

---

<div class="post-metadata">

### Author: ![mojca](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mojca/32/610_2.png) [@mojca](https://discourse.cmake.org/u/mojca)
#### Post date: [October 30, 2022, 8:35am UTC](https://discourse.cmake.org/t/access-to-any-relative-binarydir-path-is-denied-inside-visual-studio/6742/3 "2022-10-30T08:35:06Z")

</div>

Thank you, I filed a bug report, let’s see what Microsoft says.

> **[Visual Studio Feedback](https://developercommunity.visualstudio.com/t/Access-to-any-relative-binaryDir-path-is/10185024)**
>
> Visual Studio Feedback
