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

流过昼夜 提交于 2019-11-27 21:23:29

问题


I want to add in a Post-build event commandline in my 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 with "Macros>>".

How can I achieve this?

For instance I have the 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 hate to copy and paste that into every project. I would like to place the first part into a macro so that I would have:

$(SignCommandLinePrefix) $(TargetDir)$(TargetFileName)

回答1:


Though you won't see your macro in the Macros>> list, you can edit your .csproj file by hand. Look for the first <PropertyGroup> and add this right before the 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 Event and it will work just as you wish.

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



来源:https://stackoverflow.com/questions/13632282/in-visual-studio-2012-c-how-to-create-custom-macros-available-in-post-build

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