问题描述
我想在我的 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>>".
我怎样才能做到这一点?
How can I achieve this?
例如我有命令行:
"C:Program FilesMicrosoft SDKsWindowsv7.1Binsigntool.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)
推荐答案
虽然您不会在 Macros>> 列表中看到您的宏,但您可以编辑您的 .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 FilesMicrosoft SDKsWindowsv7.1Binsigntool.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/en-US/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#) 中如何创建 Post Build 中可用的自定义宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!