Cannot build C++ Release in VS Studio 2022 but Debug builds fine


I have a solution in VS 2022 written on C++. In Debug mode it builds fine. But in Release mode 2 of more then 30 projects cannot be build due to strange errors:

E:\src\Logics\StandartRemoteCommandManager.cpp(2,10): error C1083: Cannot open include file: 'Logics/StandartRemoteCommandManager.h': No such file or directory

I checked projects settings – they are the same in Debug and Release modes. But in Release mode a compiler cannot find some of the header files.
I noticed that \temp and \lib folder of these 2 projects was created in the root folder of my disk E:\ and not in the \Release folder of my solution. Maybe its the reason – I don’t know.

Please, advise me to how to fix this problem.

[Updated]
.props file

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup Label="UserMacros">
    <RepoExternal>..\</RepoExternal>
    <EXTERNAL_INCLUDES>$(RepoExternal)\CSoft.Device.Drivers\include;$(RepoExternal)\CSoft.Tools\include;$(RepoExternal)\CSoft.Shared\include;$(RepoExternal)\CSoft.Sync.Core\include;$(RepoExternal)\CSoft.SyncClient\include;$(RepoExternal)\CSoft.Gui.Tools\include;$(RepoExternal)\CSoft.Console.Tools\include;$(RepoExternal)\CSoft.Zip\include;$(RepoExternal)\CSoft.System.Tools\include;</EXTERNAL_INCLUDES>
    <EXTERNAL_LIBS>CSoft.Device.Drivers.lib;CSoft.Gui.Tools.lib;CSoft.Shared.lib;CSoft.Sync.Core.lib;CSoft.SyncClient.lib;CSoft.Tools.lib;CSoft.Console.Tools.lib;Pdh.lib;</EXTERNAL_LIBS>
    <EXTERNAL_BUILD_PATH>$(SolutionDir)\build\$(Configuration)</EXTERNAL_BUILD_PATH>
  </PropertyGroup>
  <PropertyGroup />
  <ItemDefinitionGroup />
  <ItemGroup>
    <BuildMacro Include="RepoExternal">
      <Value>$(RepoExternal)</Value>
    </BuildMacro>
    <BuildMacro Include="EXTERNAL_INCLUDES">
      <Value>$(EXTERNAL_INCLUDES)</Value>
    </BuildMacro>
    <BuildMacro Include="EXTERNAL_LIBS">
      <Value>$(EXTERNAL_LIBS)</Value>
    </BuildMacro>
    <BuildMacro Include="EXTERNAL_BUILD_PATH">
      <Value>$(EXTERNAL_BUILD_PATH)</Value>
    </BuildMacro>
  </ItemGroup>
</Project>

.vcxproj file:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="include\Application\AppLineArguments.h" />
    <ClInclude Include="include\Application\MyBaseApplication.h" />
    <QtMoc Include="include\ContextualObject.h" />
    <QtMoc Include="include\Application\MyBaseAppSettings.h" />
    <ClInclude Include="include\Screen\BaseScreen.h" />
    <QtMoc Include="include\ScreensRouter.h" />
    <QtMoc Include="include\Screenshotter.h" />
    <ClInclude Include="include\Screen\CachedScreen.h" />
    <QtMoc Include="include\Application\MyAppCommand.h" />
    <QtMoc Include="include\Application\AppCommandsExecutor.h" />
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="src\Application\AppCommandsExecutor.cpp" />
    <ClCompile Include="src\Application\MyBaseApplication.cpp" />
    <ClCompile Include="src\Application\MyBaseAppSettings.cpp" />
    <ClCompile Include="src\ContextualObject.cpp" />
    <ClCompile Include="src\ScreensRouter.cpp" />
    <ClCompile Include="src\Screen\BaseScreen.cpp" />
    <ClCompile Include="src\Screenshotter.cpp" />
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{14F3588F-1431-43B9-A6C1-6462F849C5E5}</ProjectGuid>
    <Keyword>QtVS_v303</Keyword>
    <WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">10.0.19041.0</WindowsTargetPlatformVersion>
    <WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0.19041.0</WindowsTargetPlatformVersion>
    <QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <PlatformToolset>v143</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <PlatformToolset>v143</PlatformToolset>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
    <Message Importance="High" Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." />
  </Target>
  <ImportGroup Label="ExtensionSettings" />
  <ImportGroup Label="Shared" />
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    <Import Project="..\External.props" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <ImportGroup Condition="Exists('$(QtMsBuild)\qt_defaults.props')">
    <Import Project="$(QtMsBuild)\qt_defaults.props" />
  </ImportGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    <OutDir>$(EXTERNAL_BUILD_PATH)\lib\</OutDir>
    <IntDir>$(EXTERNAL_BUILD_PATH)\temp\$(ProjectName)\</IntDir>
    <IncludePath>$(EXTERNAL_INCLUDES);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
    <OutDir>$(EXTERNAL_BUILD_PATH)\lib\</OutDir>
    <IntDir>$(EXTERNAL_BUILD_PATH)\temp\$(ProjectName)\</IntDir>
    <IncludePath>$(EXTERNAL_INCLUDES);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <ClCompile>
      <LanguageStandard>stdcpp17</LanguageStandard>
      <BrowseInformation>true</BrowseInformation>
    </ClCompile>
    <Bscmake>
      <PreserveSbr>true</PreserveSbr>
    </Bscmake>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <LanguageStandard>stdcpp17</LanguageStandard>
    </ClCompile>
  </ItemDefinitionGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
    <QtInstall>msvc2019_64</QtInstall>
    <QtModules>core;network</QtModules>
    <QtBuildConfig>debug</QtBuildConfig>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
    <QtInstall>msvc2019_64</QtInstall>
    <QtModules>core;network</QtModules>
    <QtBuildConfig>release</QtBuildConfig>
  </PropertyGroup>
  <ImportGroup Condition="Exists('$(QtMsBuild)\qt.props')">
    <Import Project="$(QtMsBuild)\qt.props" />
  </ImportGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
    <ClCompile>
      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
      <MultiProcessorCompilation>true</MultiProcessorCompilation>
      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
      <Optimization>Disabled</Optimization>
      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
      <PreprocessorDefinitions>CSOFT_DEVICES_INTERFACES_LIB;BUILD_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
    <ClCompile>
      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
      <MultiProcessorCompilation>true</MultiProcessorCompilation>
      <DebugInformationFormat>None</DebugInformationFormat>
      <Optimization>MaxSpeed</Optimization>
      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
      <PreprocessorDefinitions>CSOFT_DEVICES_INTERFACES_LIB;BUILD_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
      <GenerateDebugInformation>false</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
    <Import Project="$(QtMsBuild)\qt.targets" />
  </ImportGroup>
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>

Leave a Reply

Your email address will not be published. Required fields are marked *