VS .Net: Post build events for “Primary Output from <myProject>” in installer project

那年仲夏 提交于 2019-12-06 02:12:01

问题


I'm using the following post build actions in a project, to merge a lib into my application:

IF $(ConfigurationName) == Debug GOTO end
cp $(TargetPath) $(TargetDir)app_unmerged.exe
del $(TargetPath)
"C:\Program Files\Microsoft\ILMerge\ilmerge.exe" /internalize $(TargetDir)MyApp_unmerged.exe $(TargetDir)someLib.dll /out:$(TargetDir)myApp.exe
del $(TargetDir)myApp_unmerged.exe $(TargetDir)someLib.dll
:end

This works fine. Now I have an Installer project and added the Project Output. I would expect that the "Primary Output from " is used, i.e. the exe in /bin/Release . But actually instead of /bin/release/myApp.exe , /obj/release/myApp.exe is used.

Does anyone know if I can change this behavior and use the output in /bin/release for the installer project? Thanks.


回答1:


I solve the problem apply Ilmerge in /obj folder, this is my post-build event configuration:

COPY $(ProjectDir)obj\$(PlatformName)\$(ConfigurationName)\$(TargetFileName) $(TargetDir)temp.exe $(solutionDir)\lib\ilmerge /wildcards /t:exe /out:"$(ProjectDir)obj\$(PlatformName)\$(ConfigurationName)\$(TargetFileName)" "$(TargetDir)temp.exe" "$(TargetDir)log4net.dll" "$(TargetDir)other.dll" DEL $(TargetDir)temp.exe




回答2:


I put the files explicitly, meaning that instead of telling the setup project to use primery content, it put the .exe/.dll file explicitly.
That works pretty well, I get to control which file would enter and the setup project user relative paths so the setup project can be used on other machines.




回答3:


Seems there is no real solution for this problem, but a workaround exists. I created a ticket on Microsoft connect: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=428898

Microsofts anwser:

Hi,

In order to execute those post build actions, you will need to put them in a batch file and then add the appropiate command to invoke the batch file in the post build event dialog. I see that there are several instances in the script with references to a number of Visual Studio variables. Since we do not expose those variables as environment variables, you will have to pass them as parameters to the batch file.

I hope that helps!

Candy Chiang Program Manager - Visual Studio



来源:https://stackoverflow.com/questions/705209/vs-net-post-build-events-for-primary-output-from-myproject-in-installer-pr

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