如何通过命令行将链接器选项传递给msbuild? [英] How to pass linker options to msbuild via command line?

查看:99
本文介绍了如何通过命令行将链接器选项传递给msbuild?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过msbuild的共通行将选项传递给链接器?例如,我要设置VC链接器选项/PROFILE .如何在不更改C ++项目文件的情况下做到这一点?

Is it possible to pass options to linker via comamnd line of msbuild? For example I want to set VC linker option /PROFILE. How to do it without changing of C++ project file?

PS:Visual Studio Express 2012.

PS: Visual Studio Express 2012.

推荐答案

在项目文件中,链接器选项设置在ItemGroup中,因此您不能从命令行简单地添加或覆盖它.相反,您必须使msbuild包含它们,这只能通过导入另一个msbuild文件来完成.支持此功能:如果在命令行上设置ForceImportBeforeCppTargets,则msbuild将导入它指向的文件.

Inside the projectfile the linker options are set in an ItemGroup so you cannot simply add or override this from the commandline. Instead you'll have to make msbuild include them which can only be done by importing another msbuild file. This functionality is supported: if you set the ForceImportBeforeCppTargets on the commandline, msbuild will import the file it points to.

实际上:创建此文件,我们称其为 c:\ props \ profile.props

Practically: create this file, let's call it c:\props\profile.props

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemDefinitionGroup>
    <Link>
      <Profile>true</Profile>
    </Link>
  </ItemDefinitionGroup>
</Project>

然后按如下所示构建您的(未修改的)项目:

Then build your (unmodified) project like this:

msbuild myProject.vcxproj /p:ForceImportBeforeCppTargets=c:\props\profile.props

这篇关于如何通过命令行将链接器选项传递给msbuild?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆