msbuild – 从命令行编译时添加附加库并包含路径

前端之家收集整理的这篇文章主要介绍了msbuild – 从命令行编译时添加附加库并包含路径前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试在编译期间添加其他路径供我的项目组使用.由于C Builder 2010使用msbuild,我已经尝试查看文档,并根据我可以找到的AdditionalLibPaths应该作为属性传递.即
msbuild /p:AdditionalLibPaths=C:\FooBar\Libs /t:build foo.groupproj

但似乎没有使用我添加的路径.我以前注意到,当传递给msbuild时,VC和C Builder之间的某些属性名有所不同,并且想知道C Builder是否可能使用其他属性名来添加额外的lib和包含文件夹?

我不想替换项目中定义的现有路径,但附加其他路径.这样做的理由是,当项目建立在我们的构建服务器上时,某些库位于标准化的位置,可能与开发机器上安装的位置不同.

msbuild acertally调用一个msbuild脚本文件,该文件反过来调用其他脚本,包括使用该标记的.groupproj文件.我知道使用该标签时会创建一个新的msbuild实例,因此我知道在脚本中运行该任务时必须添加属性.

<MSBuild Targets="Build" Projects="..\Foo.groupproj" Properties="Config=Debug (property to add additional paths here!)" />

更新:

C Builder似乎正在使用IncludePath和ILINK_LibraryPath,但设置这些覆盖了项目文件中已定义的路径.由于此文件由IDE创建和维护,所以任何使其附加而不是覆盖的更改都将被IDE覆盖.这是奇怪的,因为它看起来应该附加值

<IncludePath>..\FooBar\;$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;Common Components;..\Config\Config32;$(IncludePath)</IncludePath>

更新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>

        <!-- _TCHAR mapping for Uni^H^H^H character selection -->
        <StartupObj Condition="'$(_TCHARMapping)'=='wchar_t'">$(StartupObj)w</StartupObj>
        <ILINK_StartupObjs Condition="'$(ILINK_StartupObjs)'==''">$(StartupObj)</ILINK_StartupObjs>
        <BCC_GenerateUnicode Condition="'$(_TCHARMapping)'=='wchar_t'">true</BCC_GenerateUnicode>
        <!-- Include Paths -->
        <Win32LibraryPath Condition="'$(Win32LibraryPath)'==''">$(BDS)\lib</Win32LibraryPath>
        <IncludePath Condition="'$(CBuilderIncludePath)'!=''">$(IncludePath);$(CBuilderIncludePath)</IncludePath>
                <IncludePath Condition="'$(AdditionalIncludePath)'!=''">$(IncludePath);$(AdditionalIncludePath)</IncludePath>
        <BCC_IncludePath Condition="'$(BCC_IncludePath)'!=''">$(BCC_IncludePath);$(IncludePath)</BCC_IncludePath>
        <BCC_IncludePath Condition="'$(BCC_IncludePath)'==''">$(IncludePath)</BCC_IncludePath>
        <BRCC_IncludePath Condition="'$(BRCC_IncludePath)'!=''">$(BRCC_IncludePath);$(IncludePath)</BRCC_IncludePath>
        <BRCC_IncludePath Condition="'$(BRCC_IncludePath)'==''">$(IncludePath)</BRCC_IncludePath>
        <DCC_IncludePath Condition="'$(DCC_IncludePath)'!=''">$(DCC_IncludePath);$(IncludePath)</DCC_IncludePath>
        <DCC_IncludePath Condition="'$(DCC_IncludePath)'==''">$(IncludePath)</DCC_IncludePath>
        <DCC_UnitSearchPath>$(DCC_IncludePath);$(Win32LibraryPath)</DCC_UnitSearchPath>
        <DCC_ResourcePath>$(DCC_IncludePath)</DCC_ResourcePath>
        <DCC_ObjPath>$(DCC_IncludePath)</DCC_ObjPath>
        <TASM_IncludePath Condition="'$(TASM_IncludePath)'!=''">$(TASM_IncludePath);$(IncludePath)</TASM_IncludePath>
        <TASM_IncludePath Condition="'$(TASM_IncludePath)'==''">$(IncludePath)</TASM_IncludePath>

然后我可以打电话

msbuild /t:build /p:AdditionalIncludePaths=C:\Foo\Include foo.groupproj

这工作正常,做我想要的我只需要与图书馆的路径一样.但是我不想要这样一个Embarcaderos提供的文件.这只是可笑的:P …没有任何官方属性设置添加包括路径和lib路径?

解决方法

对于VS2013,只需要在运行msbuild之前定义环境变量:
set "INCLUDE=%additional_include_path%;%INCLUDE%"
set "LIB=%additional_lib_path%;%LIB%"
REM use environment variables for INCLUDE and LIB values
set UseEnv=true

参考:MSBuild / Microsoft.Cpp / v4.0 / V120 / Microsoft.Cpp.targets

<Target Name="SetBuildDefaultEnvironmentVariables"
        Condition="'$(UseEnv)' != 'true'">
...
    <SetEnv Name   ="INCLUDE"
        Value  ="$(IncludePath)"
        Prefix ="false" >
       <Output TaskParameter="OutputEnvironmentVariable"             PropertyName="INCLUDE"/>
    </SetEnv>

但是看起来像INCLUDE和LIB附加在项目属性中指定的附加include / lib目录之后.

原文链接:https://www.f2er.com/c/115721.html

猜你在找的C&C++相关文章