In Visual Studio 2012 (C #) How to Create Custom Macros Available in Post Build

I want to add Post-build events to the command line in a Visual Studio 2012 C # project.

I have a number of projects in my solution, and I would like to add to the list of macros available using "Macros โ†’".

How can i achieve this?

For example, I have a command line:

"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\signtool.exe" sign /f MYPFXFILEPATH /p MYPASSWORD /t http://timestamp.verisign.com/scripts/timstamp.dll $(TargetDir)$(TargetFileName) 

I would not want to copy and paste them into each project. I would like to put the first part in a macro so that I have:

 $(SignCommandLinePrefix) $(TargetDir)$(TargetFileName) 
+6
source share
1 answer

Although you will not see your macro in the Macros โ†’ list, you can manually edit the .csproj file. Find the first <PropertyGroup> and add this right before closing </PropertyGroup> :

 <SignCommandLinePrefix>"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\signtool.exe" sign /f MYPFXFILEPATH /p MYPASSWORD /t http://timestamp.verisign.com/scripts/timstamp.dll</SignCommandLinePrefix> 

Now you can add $(SignCommandLinePrefix) $(TargetDir)$(TargetFileName) to your Post-Build message, and it will work as you wish.

See Chuck England's answer to this question: http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/e774f871-8fc2-4875-b791-1df3dd0bb2dc/

+7
source

All Articles