[英]Pre-build event command line question
I created two applications.(Console Appliaction: MyConApp.exe and Windows Application: MyWinApp.exe) Purpose, Attach MyConApp.exe to MyWinApp.exe and transfer the MyConApp.exe args with the MyWinApp's Pre-build event. 我创建了两个应用程序。(控制台应用程序:MyConApp.exe和Windows应用程序:MyWinApp.exe)目的,将MyConApp.exe附加到MyWinApp.exe,并通过MyWinApp的Pre-build事件传输MyConApp.exe参数。
[update] [更新]
MyConApp.exe is a small tool to parse a XSD file and generate a FromXSD.cs file. MyConApp.exe是解析XSD文件并生成FromXSD.cs文件的小工具。 It worked very vell if i double click it.And myConAppArgs is the XSD file path .
如果我双击它,它的工作效果非常好。myConAppArgs是XSD文件路径 。
Now the FromXSD.cs file used by the MyWinApp.exe project. 现在, MyWinApp.exe项目使用的FromXSD.cs文件。 I hope to build MyWinApp.sln with the FromXSD.cs file at the building time.
我希望在构建时使用FromXSD.cs文件构建MyWinApp.sln。
If the XSD file changed someday. 如果XSD文件有一天更改了。 I need handle the new XSD file automatically if i take use the pre-build event command line method.
如果我使用预构建事件命令行方法,则需要自动处理新的XSD文件。 That's why i procedured the three steps.
这就是为什么我要执行这三个步骤。
My Procedure 我的程序
Step1. 第1步。
I copied the MyConApp.exe to the same path of MyWinApp.exe. 我将MyConApp.exe复制到MyWinApp.exe的相同路径。
That is say: there are two .exe file located in the path **D:\\learning\\cs\\MyWinApp\\MyWinApp\\bin\\Debug** 也就是说:在路径** D:\\ learning \\ cs \\ MyWinApp \\ MyWinApp \\ bin \\ Debug **中有两个.exe文件
Step2. 第2步。
Open the MyWinApp project properties -> build events -> and the Pre-build event command line: 打开MyWinApp项目属性->构建事件->和预构建事件命令行:
input: 输入:
myConApp.exe myConAppArgs
Step3. 第三步。
Save MyWinApp project, build and run it. 保存MyWinApp项目,生成并运行它。
Is there any better method to do this or any stand procedure to follow? 有没有更好的方法来执行此操作或遵循任何常规程序? Thanks for reading and replies.
感谢您的阅读和回复。
Due to the fact, that you want to do this in your pre-build event, you can merge step one and two. 由于事实是您想在构建前事件中执行此操作,因此可以合并步骤1和步骤2。 Just try the following in your WinApp pre-build event:
只需在WinApp的预构建事件中尝试以下操作:
copy /y $(SolutionDir)conApp\$(OutDir)ConApp.exe $(TargetDir)
ConApp.exe -i -k -whatever
So your ConApp will always be fresh copied within the pre-build event. 因此,您的ConApp将始终在构建前事件中被全新复制。 Also you should set in the Project Dependencies of WinApp, that it will depend on ConApp.
另外,您应该在WinApp的项目依赖项中进行设置,该依赖项将取决于ConApp。 So ConApp will always be built before WinApp.
因此,ConApp将始终在WinApp之前构建。
To access the Project Dependencies just right click in your Solution Explorer on the WinApp project and search that entry within the context menu. 要访问项目依赖关系,只需在WinApp项目上的解决方案资源管理器中右键单击,然后在上下文菜单中搜索该条目。
This sounds pretty bizarre, does the MyConApp.exe do anything that affects the build process of MyWinApp.exe? 这听起来很奇怪,MyConApp.exe会执行任何会影响MyWinApp.exe生成过程的事情吗? If it does, it certainly doesn't belong in the bin\\Debug directory, it would have to have the same affect when you build the Release version.
如果确实如此,则它肯定不属于bin \\ Debug目录,在构建发行版时,它必须具有相同的影响。 It belongs in the project directory.
它属于项目目录。
If it doesn't affect the build then using a pre-build event is entirely inappropriate. 如果不影响构建,则使用预构建事件是完全不合适的。 You'll then need to explain why this is at all necessary.
然后,您需要解释为什么这是绝对必要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.