How to pass linker options to msbuild via command line?

萝らか妹 提交于 2019-12-18 11:46:40

问题


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.


回答1:


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.

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


来源:https://stackoverflow.com/questions/17677076/how-to-pass-linker-options-to-msbuild-via-command-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!