我有以下Directory.Build.props
文件:
<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>
每当我在子文件夹(在 Visual Studio 2019 中)中加载(C++)项目时,该项目都会丢失所有继承的包含和库路径:
我在想这可能是因为我没有附加到IncludePath
and LibraryPath
,所以我这样做并更改了props
文件如下:
<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>
然后重新加载项目,再次导致丢失继承的值。
我仔细检查了宏是否存在,它们是(VC_
和WindowsSDK_
宏):
我还尝试更改Directory.Build.props
为Directory.Build.targets
在加载项目后加载它,但是文件根本没有加载。
如何确保我Directory.Build.props
继承默认值并附加我的自定义选项?
我想这样做的原因是因为我正在从已弃用的Microsoft.Cpp.Win32.user.props
文件中迁移出来。
将扩展名更改为.targets
仅适用于构建过程,但智能感知/视觉工作室不会处理包含文件,并且会显示很多错误(在编译之前)。这不是优选的。