Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass linker options to msbuild via command line?

Tags:

msbuild

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.

like image 331
ArtDen Avatar asked Jul 16 '13 12:07

ArtDen


People also ask

How use MSBuild command line?

To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-line options. Command-line options let you set properties, execute specific targets, and set other options that control the build process.

How do I configure MSBuildDisableNodeReuse?

To set the “MSBuildDisableNodeReuse” variable globally use the “Environment Variables” property page, which is accessed by right-clicking Computer, clicking Properties, and clicking the “Environment Variables” button under the “System Properties” dialog window Advanced tab.


1 Answers

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
like image 84
stijn Avatar answered Oct 08 '22 01:10

stijn