How to disable MSBuild's <RegisterOutput> target on a per-user basis?

Posted by Roger Lipscombe on Stack Overflow See other posts from Stack Overflow or by Roger Lipscombe
Published on 2010-05-05T12:16:44Z Indexed on 2010/05/05 14:08 UTC
Read the original article Hit count: 226

Filed under:

I like to do my development as a normal (non-Admin) user. Our VS2010 project build fails with "Failed to register output. Please try enabling Per-user Redirection or register the component from a command prompt with elevated permissions."

Since I'm not at liberty to change the project file, is there any way that I can add user-specific MSBuild targets or properties that disable this step on a specific machine, or for a specific user? I'd prefer not to hack on the core MSBuild files.

I don't want to change the project file because I might then accidentally check it back in. Nor do I want to hack on the MSBuild core files, because they might get overwritten by a service pack.

Given that the Visual C++ project files (and associated .targets and .props files) have about a million places to alter the build order and to import arbitrary files, I was hoping for something along those lines.

MSBuild imports/evaluates the project file as follows (I've only looked down the branches that interest me):

Foo.vcxproj
  Microsoft.Cpp.Default.props
  Microsoft.Cpp.props
  $(UserRootDir)\Microsoft.Cpp.$(Platform).user.props
  Microsoft.Cpp.targets
    Microsoft.Cpp.$(Platform).targets
      ImportBefore\*
      Microsoft.CppCommon.targets

The "RegisterOutput" target is defined in Microsoft.CppCommon.targets. I was hoping to replace this by putting a do-nothing "RegisterOutput" target in $(UserRootDir)\Microsoft.Cpp.$(Platform).user.props, which is %LOCALAPPDATA%\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props (UserRootDir is set in Microsoft.Cpp.Default.props if it's not already set).

Unfortunately, MSBuild uses the last-defined target, which means that mine gets overridden by the built-in one.

Alternatively, I could attempt to set the %(Link.RegisterOutput) metadata, but I'd have to do that on all Link items. Any idea how to do that, or even if it'll work?

© Stack Overflow or respective owner

Related posts about msbuild