diff --git a/news/233.bugfix b/news/233.bugfix
new file mode 100644
index 0000000..dc0a11e
--- /dev/null
+++ b/news/233.bugfix
@@ -0,0 +1,1 @@
+Generate .mbedignore in a project's build directory, to prevent Mbed CLI 1 from picking up CMake build files.
diff --git a/src/mbed_tools/build/config.py b/src/mbed_tools/build/config.py
index bea354e..e408564 100644
--- a/src/mbed_tools/build/config.py
+++ b/src/mbed_tools/build/config.py
@@ -16,6 +16,7 @@ from mbed_tools.build._internal.write_files import write_file
 from mbed_tools.build.exceptions import MbedBuildError
 
 CMAKE_CONFIG_FILE = "mbed_config.cmake"
+MBEDIGNORE_FILE = ".mbedignore"
 
 
 def generate_config(target_name: str, toolchain: str, program: MbedProgram) -> Tuple[Config, pathlib.Path]:
@@ -40,6 +41,8 @@ def generate_config(target_name: str, toolchain: str, program: MbedProgram) -> T
     )
     cmake_config_file_path = program.files.cmake_build_dir / CMAKE_CONFIG_FILE
     write_file(cmake_config_file_path, cmake_file_contents)
+    mbedignore_path = program.files.cmake_build_dir / MBEDIGNORE_FILE
+    write_file(mbedignore_path, "*")
     return config, cmake_config_file_path
 
 

diff --git a/tests/build/test_generate_config.py b/tests/build/test_generate_config.py
index e7d7eb7..9e94993 100644
--- a/tests/build/test_generate_config.py
+++ b/tests/build/test_generate_config.py
@@ -4,11 +4,12 @@
 #
 import json
 
+import os
 import pytest
 
 from mbed_tools.project import MbedProgram
 from mbed_tools.build import generate_config
-from mbed_tools.build.config import CMAKE_CONFIG_FILE
+from mbed_tools.build.config import CMAKE_CONFIG_FILE, MBEDIGNORE_FILE
 from mbed_tools.lib.exceptions import ToolsError
 
 
@@ -96,6 +97,17 @@ def matching_target_and_filter(request):
     return request.param
 
 
+def test_mbedignore_generated(program):
+    target = "K64F"
+    toolchain = "GCC_ARM"
+
+    generate_config(target, toolchain, program)
+
+    mbedignore_file = (program.files.cmake_build_dir / MBEDIGNORE_FILE)
+
+    assert os.path.isfile(mbedignore_file)
+
+
 def test_target_and_toolchain_collected(program):
     target = "K64F"
     toolchain = "GCC_ARM"

Users are building cli1 and cli2 within the same app
**Describe the bug**
A clear and concise description of what the bug is.

I've received 2 questions with the similar topic within the last 24 hours - "my build is failing with a weird error" - a user first run cli2 and then later another day switched to cli1 and received an error.

A question is: should we fix this and avoid surprises if users use either cli1 or cli2 ? One suggestion that many of us came to was adding .mbedignore and add there `cmake_build` directory.  Is there better way to make this use case working without errors ?

**To Reproduce**
Steps to reproduce the behavior:

Build blinky with cli2 first, then build with cli1.

**Expected behavior**
Both builds would work as they work on the same codebase, in separate build directories. As we support both at the time being, we should allow users to build both or at least warn them if they are doing this (if we do not want to support the use case)


**Mbed (please complete the following information):**
mbed-tools, mbed-cli and Mbed OS - any version
tests/build/test_generate_config.py::test_overrides_target_non_config_params_from_app[target: tests/build/test_generate_config.py::test_macros_from_lib_collected[single] tests/build/test_generate_config.py::test_target_list_params_can_be_added_to[target: tests/build/test_generate_config.py::test_target_and_toolchain_collected tests/build/test_generate_config.py::test_forced_reset_timeout_unspecified tests/build/test_generate_config.py::test_output_ext_hex tests/build/test_generate_config.py::test_config_parsed_when_mbed_os_outside_project_root[target: tests/build/test_generate_config.py::test_overrides_target_config_param_from_lib[target: tests/build/test_generate_config.py::test_config_param_from_lib_processed_with_default_name_mangling tests/build/test_generate_config.py::test_target_labels_collected_as_defines tests/build/test_generate_config.py::test_raises_when_attempting_to_override_lib_config_param_from_other_lib[target: tests/build/test_generate_config.py::test_target_list_params_can_be_removed[target: tests/build/test_generate_config.py::test_custom_targets_data_found tests/build/test_generate_config.py::test_overrides_lib_config_param_from_same_lib[target: tests/build/test_generate_config.py::test_warns_when_attempting_to_override_nonexistent_param[target: tests/build/test_generate_config.py::test_config_param_from_target_processed_with_default_name_mangling tests/build/test_generate_config.py::test_settings_from_multiple_libs_included[target: tests/build/test_generate_config.py::test_macros_from_target_collected tests/build/test_generate_config.py::test_macros_from_lib_collected[multiple] tests/build/test_generate_config.py::test_macros_from_app_collected[single] tests/build/test_generate_config.py::test_overrides_lib_config_param_from_app[target: tests/build/test_generate_config.py::test_config_param_from_app_processed_with_default_name_mangling tests/build/test_generate_config.py::test_raises_error_when_attempting_to_customize_existing_target tests/build/test_generate_config.py::test_requires_config_option tests/build/test_generate_config.py::test_macros_from_app_collected[multiple] tests/build/test_generate_config.py::test_output_ext_unspecified tests/build/test_generate_config.py::test_output_ext_bin tests/build/test_generate_config.py::test_forced_reset_timeout_set tests/build/test_generate_config.py::test_mbedignore_generated tests/build/test_generate_config.py::test_overrides_target_config_param_from_app[target: tests/build/test_generate_config.py::test_config_param_from_lib_processed_with_user_set_name