MikeB-3284 avatar image
0 Votes"
MikeB-3284 asked TianyuSun-MSFT commented

VS2022 .vcxproj.user UserMacros properties not applying to .vcxproj fields

Hello! I am relatively new to understanding the .vcxproj schema, but I cannot find solutions for what we want to do.

We are programmatically generating our .vcxproj file with a custom NMake build commandline. I want individual users to be able to append commandline args from a .vsix extension.

To facilitate this, I had the idea to add a custom macro to the generated commandline in the .vcxproj file (so that the .vcxproj file itself remains static). This works if I define the custom macro inside the .vcxproj file itself:

 <PropertyGroup Label="UserMacros">
     <NMakeBuildCommandLine>../Path/To/My/Build.bat MyProjName $(DynamicVSIXBuildArguments)<NMakeBuildCommandLine>

However, if I move the <PropertyGroup Label="UserMacros"> block into the .vcxproj.user file, the macro doesn't resolve in the build commandline (it's resolved to nothing). I even had the vsix extension writing the property to the user file using this code:

 IVsBuildPropertyStorage PropertyStorage = ...
 PropertyStorage.SetPropertyValue("DynamicVSIXBuildArguments", null, (uint)_PersistStorageType.PST_USER_FILE, "-MyAddedBuildArg=ValueFromVSIX");

And by default that writes to a "UserMacros" property block without me having to specify it.

I know I was kind of blindly hoping this would work, but would like to understand why it doesn't, and how I might achieve my original goal.


· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @MikeB-3284 , welcome to Microsoft Q&A forum. This doc: .vcxproj.user files says:

A user file ( .vcxproj.user ) stores user-specific properties, for example, debugging and deployment settings.

I’m not sure, but perhaps .vcxproj.user file doesn’t support customizing user macros. Or in .vcxproj file you can’t get the macros which is defined in .vcxproj.user file.

I may misunderstand your requirement, but is it possible to put and set user macros in .vcxproj file, even if it’s for individual users?

0 Votes 0 ·

Hello, and thank you for the reply!

I did a brief test, and changed PST_USER_FILE to PST_PROJECT_FILE. It wrote to the .vcxproj file, but not the the UserMacros block, and the build process didn't appear to pick it up.

0 Votes 0 ·

From this thread:, there's a reply that's:

So it appears storing usermacros in the .user file is the way to go.

Which makes me think it's possible, but maybe things have changed since 2010?

0 Votes 0 ·

Probably, as VS 2010 is an old version of VS. I think it’s better to confirm this with VS Product Team, you can directly ask this question on our Developer Community to confirm this.


0 Votes 0 ·

0 Answers