我正在尝试添加在编译期间由我的项目组使用的其他路径.由于C++ Builder 2010使用msbuild,我已经尝试查看文档,并根据我可以找到的内容,AdditionalLibPaths应该可以作为属性传递.即
msbuild /p:AdditionalLibPaths=C:\FooBar\Libs /t:build foo.groupproj
Run Code Online (Sandbox Code Playgroud)
但它似乎没有使用我添加的路径.我之前已经注意到,当传递给msbuild时,VC++和C++ Builder之间的某些属性名称有所不同,并且想知道C++ Builder是否可能使用其他属性名称来添加其他lib并包含文件夹?
我不想替换项目中定义的现有路径,而是添加其他路径.这样做的理由是,当项目在我们的构建服务器上构建时,一些库驻留在标准化的位置,这可能与它在开发机器上的安装位置不同.
的MSBuild实际上可以调用的MSBuild脚本文件,反过来调用其它脚本包括.groupproj使用的手机标签.我知道在使用时会创建一个新的msbuild实例 标记,所以我知道我必须在我的脚本中运行该任务时添加属性.
<MSBuild Targets="Build" Projects="..\Foo.groupproj" Properties="Config=Debug (property to add additional paths here!)" />
Run Code Online (Sandbox Code Playgroud)
更新:
C++ Builder似乎使用IncludePath和ILINK_LibraryPath,但设置这些会覆盖已在项目文件中定义的路径.由于此文件是由IDE创建和维护的,因此任何更改以使其附加而不是覆盖都将被IDE覆盖.这有点奇怪,因为它看起来确实应该附加值
<IncludePath>..\FooBar\;$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;Common Components;..\Config\Config32;$(IncludePath)</IncludePath>
Run Code Online (Sandbox Code Playgroud)
更新2:
在CodeGear.Cpp.Targets中,我将自己的名为AdditionalIncludePaths的属性添加到了包含路径的PropertyGroup中.
在251号线附近
<PropertyGroup>
<BCC_NoLink>true</BCC_NoLink>
<ILINK_OSVersion Condition="'$(ILINK_OSVersion)'=='' And '$(NoVCL)'!='true'">5.0</ILINK_OSVersion>
<DCC_GenerateCppFiles>true</DCC_GenerateCppFiles>
<ShowStdOut Condition="'$(ShowStdOut)'==''">$(ShowGeneralMessages)</ShowStdOut>
<!-- …Run Code Online (Sandbox Code Playgroud) 我有以下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>
Run Code Online (Sandbox Code Playgroud)
每当我在子文件夹(在 Visual Studio 2019 中)中加载 (C++) 项目时,该项目都会丢失所有继承的包含路径和库路径:
我想这可能是因为我没有附加到IncludePathand 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>
Run Code Online (Sandbox Code Playgroud)
然后重新加载项目,再次导致继承值丢失。
我仔细检查了宏是否存在,它们是(VC_和WindowsSDK_宏):
我还尝试更改Directory.Build.props为Directory.Build.targets使其在项目加载后加载,但文件根本没有加载。
如何确保我的Directory.Build.props继承默认值并附加我的自定义选项?
我想要这样做的原因是因为我正在迁移已弃用的Microsoft.Cpp.Win32.user.props …