I have the following Directory.Build.props
files:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-14.2</LibraryPath>
<IncludePath>$(BOOST_ROOT)\</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LibraryPath>$(BOOST_ROOT)\lib64-msvc-14.2</LibraryPath>
<IncludePath>$(BOOST_ROOT)\</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-14.2</LibraryPath>
<IncludePath>$(BOOST_ROOT)\</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LibraryPath>$(BOOST_ROOT)\lib64-msvc-14.2</LibraryPath>
<IncludePath>$(BOOST_ROOT)\</IncludePath>
</PropertyGroup>
</Project>
Whenever I load a (C++) project in a subfolder (in visual Studio 2019), the project loses all inherited include and library paths:
I was thinking this might be due to me not appending to IncludePath
and LibraryPath
, so I did that and changed the props
files as follow:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LibraryPath>$(LibraryPath);$(BOOST_ROOT)\lib32-msvc-14.2</LibraryPath>
<IncludePath>$(IncludePath);$(BOOST_ROOT)\</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LibraryPath>$(LibraryPath);$(BOOST_ROOT)\lib64-msvc-14.2</LibraryPath>
<IncludePath>$(IncludePath);$(BOOST_ROOT)\</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LibraryPath>$(LibraryPath);$(BOOST_ROOT)\lib32-msvc-14.2</LibraryPath>
<IncludePath>$(IncludePath);$(BOOST_ROOT)\</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LibraryPath>$(LibraryPath);$(BOOST_ROOT)\lib64-msvc-14.2</LibraryPath>
<IncludePath>$(IncludePath);$(BOOST_ROOT)\</IncludePath>
</PropertyGroup>
</Project>
Then reloading the project, results in missing inherited values, again.
I double checked to see if the macros are present, and they are (VC_
and WindowsSDK_
macros):
I also tried changing Directory.Build.props
to Directory.Build.targets
to make it load after the projects have been loaded, but then the file does not get loaded at all.
How can I make sure that my Directory.Build.props
inherits the default values, and appends my custom options?
The reason I want to do this is because I'm migrating away from the deprecated Microsoft.Cpp.Win32.user.props
file.
Changing the extention to .targets
works only for the build process, but intellisense / visual Studio doesn't pick up on the include files, and shows a lot of error (before compilation). This is not preferable.
Directory.Build.props
to overwrite the values because it runs beforeMicrosoft.Common.props
which defines the default inherited values. So it always cannot overwrite the system values but only create some custom properties for overwriting or using later. – CarbreyMicrosoft.Cpp.Win32.user.props
is not an option as it's deprecated. – MalcolmmalcomMicrosoft.Cpp.Win32.user.props
file, and it is the best way to achieve it. I guess you just want to tie these Custom properties to a specific project instead of acting on all projects created in VS, or you just want to automatically migrate to a new environment with the project,these properties are only the address of the class library, and invalid address VS will be skipped without any other effect on VS. So you don't have to worry about it. – Carbreyicrosoft.Cpp.Win32.user.props
. So if you agree with me, you could consider accepting my answer. – CarbreyDirectory.Build.props
intoMicrosoft.Cpp.Win32.user.props
so that it can avoid missing system property values. – CarbreyUserMacros
PropertyGroup
in Directory.Build.props, so it's available to everything, and just put yourIncludePath
/LibraryPath
extensions inDirectory.Build.targets
. This seems to work with intellisense. – Curiosity