# Visual Studio closes non-project files when reloading ?

**URL:** https://discourse.cmake.org/t/visual-studio-closes-non-project-files-when-reloading/7438
**Category:** Usage
**Created:** [February 9, 2023, 10:27pm UTC](https://discourse.cmake.org/t/visual-studio-closes-non-project-files-when-reloading/7438 "2023-02-09T22:27:54Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![neundorf](https://discourse.cmake.org/user_avatar/discourse.cmake.org/neundorf/32/2075_2.png) [@neundorf](https://discourse.cmake.org/u/neundorf)
#### Post date: [February 9, 2023, 10:27pm UTC](https://discourse.cmake.org/t/visual-studio-closes-non-project-files-when-reloading/7438/1 "2023-02-09T22:27:54Z")

</div>

Hi,

using Visual Studio 2017 I noticed today that when Visual Studio reloads the cmake-generated project (because cmake was rerun when building one of the targets), it closes the open files which are not part of the project.  
Is this normal ? Can I do something against this ?  
This is especially annoying when editing some of the used cmake files, those which did not end up in the generated project (even though they are include()ed, see my other post).  
The other set of files are the .h files, which I did not add as sources to the targets. Now they are closed when the project is reloaded. Should I add them for this purpose to the project ?

Thanks  
Alex

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 13, 2023, 5:16am UTC](https://discourse.cmake.org/t/visual-studio-closes-non-project-files-when-reloading/7438/2 "2023-02-13T05:16:51Z")

</div>

The automatic project-reloading has been a native feature of Visual Studio for a long time. Is it fine with newer VS versions?

---

<div class="post-metadata">

### Author: ![neundorf](https://discourse.cmake.org/user_avatar/discourse.cmake.org/neundorf/32/2075_2.png) [@neundorf](https://discourse.cmake.org/u/neundorf)
#### Post date: [February 14, 2023, 9:10pm UTC](https://discourse.cmake.org/t/visual-studio-closes-non-project-files-when-reloading/7438/3 "2023-02-14T21:10:50Z")

</div>

I have only that version available.  
I just reproduced it again.  
When reloading a project, sometimes non-project files stay open, sometimes they are closed. That’s a bit annoying when editing one of the include()d cmakefiles, so the project will be reloaded, and then this file is closed.  
I haven’t found out yet what the exact conditions are.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 14, 2023, 9:21pm UTC](https://discourse.cmake.org/t/visual-studio-closes-non-project-files-when-reloading/7438/4 "2023-02-14T21:21:05Z")

</div>

Cc: @brad.king

---

<div class="post-metadata">

### Author: ![neundorf](https://discourse.cmake.org/user_avatar/discourse.cmake.org/neundorf/32/2075_2.png) [@neundorf](https://discourse.cmake.org/u/neundorf)
#### Post date: [February 14, 2023, 10:17pm UTC](https://discourse.cmake.org/t/visual-studio-closes-non-project-files-when-reloading/7438/5 "2023-02-14T22:17:41Z")

</div>

It seems the non-project files stay open if I edit one of the CMakeLists.txt, and they are closed when I edit one of the include()d cmake files.  
I’ll try with a small example project tomorrow.

---

<div class="post-metadata">

### Author: ![neundorf](https://discourse.cmake.org/user_avatar/discourse.cmake.org/neundorf/32/2075_2.png) [@neundorf](https://discourse.cmake.org/u/neundorf)
#### Post date: [February 15, 2023, 5:38pm UTC](https://discourse.cmake.org/t/visual-studio-closes-non-project-files-when-reloading/7438/6 "2023-02-15T17:38:02Z")

</div>

Haven’t tried with another project yet, but, if I add the included cmake file to the sources of a target, it stays open when the project is reloaded, if I remove it again from the list of source files, it is closed.
