在Visual Studio 2012(C#)中如何创建在生成后可用的自定义宏 [英] In Visual Studio 2012 (C#) How to Create Custom Macros available in Post Build
问题描述
我想在Visual Studio 2012 C#项目中添加构建后事件命令行.
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>>".
我该如何实现?
例如,我有命令行:
"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)
推荐答案
尽管您不会在宏>> 列表中看到宏,但是您可以编辑 .csproj 坚强>用手归档.查找第一个<PropertyGroup>
并将其添加在结束</PropertyGroup>
:
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>
现在,您可以将$(SignCommandLinePrefix) $(TargetDir)$(TargetFileName)
添加到您的构建后事件中,它将按您的意愿运行.
Now, you can add $(SignCommandLinePrefix) $(TargetDir)$(TargetFileName)
to your Post-Build Event and it will work just as you wish.
查看Chuck England对以下问题的回答: http://social.msdn.microsoft.com /Forums/zh-CN/vsx/thread/e774f871-8fc2-4875-b791-1df3dd0bb2dc/
Check out Chuck England's response to this question: http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/e774f871-8fc2-4875-b791-1df3dd0bb2dc/
这篇关于在Visual Studio 2012(C#)中如何创建在生成后可用的自定义宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!