If I change Object File Name
from $(IntDir)
to $(IntDir)%(RelativeDir)
, Visual Studio gives the following error when compiling:
C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(1016,5): error MSB3191: Unable to create directory "C:\Source\Repos\Smia\DpGraphs\out\x64\Debug\C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32522\modules". The given path's format is not supported.
C:\Source\Repos\Smia\DpGraphs\out\x64\Debug\
is my $(IntDir)
. It seems that Visual Studio wants to compile some file inside C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32522\modules
, and %(RelativeDir)
is calculated to the full path since it is not relative to my project.
I'm using C++ modules in my project, so that's probably why a file on that path is compiled.
I have files with the same names in my project, so I'd like to keep %(RelativeDir)
in the Object File Name
.
How can I solve this? I'm using Visual Studio 2022 17.6.0 Preview 4.0.
Edit 1
Here is my project file. As you can see, I'm not including all files using relative paths, so I think the file causing the issue must be included by one of the <import Project"..." />
lines.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{bda3f5fc-e66c-4c4c-a540-6432a8b2a847}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemDefinitionGroup>
<ClCompile>
<LanguageStandard>stdcpplatest</LanguageStandard>
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="DirectedGraph\DirectedGraph.ixx" />
<ClCompile Include="DirectedGraph\Edge.cpp" />
<ClCompile Include="DirectedGraph\Edge.ixx" />
<ClCompile Include="DirectedGraph\Graph.cpp" />
<ClCompile Include="DirectedGraph\Graph.ixx" />
<ClCompile Include="DirectedGraph\GraphTypes.ixx" />
<ClCompile Include="DirectedGraph\Node.cpp" />
<ClCompile Include="DirectedGraph\Node.ixx" />
<ClCompile Include="NestableGraph\Edge.cpp" />
<ClCompile Include="NestableGraph\Edge.ixx" />
<ClCompile Include="NestableGraph\Graph.cpp" />
<ClCompile Include="NestableGraph\Graph.ixx" />
<ClCompile Include="NestableGraph\GraphTypes.ixx" />
<ClCompile Include="NestableGraph\NestableGraph.ixx" />
<ClCompile Include="NestableGraph\Node.cpp" />
<ClCompile Include="NestableGraph\Node.ixx" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
Edit 2
I was able to find out which files are included by full path:
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32522\modules\std.ixx.obj
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32522\modules\std.compat.ixx.obj
Edit 3
I've tried explicitly including the two files causing issues in my project file. The idea was that I could then override Object File Name
for only those files. But then the files are just included twice and the issue persists.
On Visual Studio 17.8 Preview 1.0, disabling Build ISO C++23 Standard Library Modules doesn't seem to be enough anymore. The workaround I found was to add <EnableStdModules>false</EnableStdModules>
to any top-level <PropertyGroup>
inside the project file or a property sheet.
For example, at the top of the project file:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<EnableStdModules>false</EnableStdModules>
</PropertyGroup>
[... rest of the file]
The error I get is:
1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(1016,5): error MSB3191: Unable to create directory "C:\some\directory\C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.38.32919\modules". The given path's format is not supported.
There's two properties available from the UI for projects/property sheets:
<BuildStlModules>true</BuildStlModules>
<EnableModules>true</EnableModules>
I enabled diagnostic verbosity for MSBuild to figure out where the directory gets added to the list of directories that need to be created: Tools menu, Options; expand Project and Solutions/Build And Run, set MSBuild project build output verbosity to Diagnostic
.
I searched for 14.38.32919\modules
in the build output and found this:
1>Target "ComputeStdModulesCompileInputs" in file "C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets":
1> Set Property: EnableStdModules=true
1> Added Item(s): LibraryManifests=C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.38.32919\modules\modules.json
Notice the EnableStdModules=true
, which doesn't correspond to either property from the UI. Adding this property manually to the project file or a property sheet fixes it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With