Discussion:
Post-build editbin
(too old to reply)
Dave Booker
2005-10-26 18:36:11 UTC
Permalink
Every time I compile a solution I want it to run "editbin /LARGEADDRESSAWARE"
on the resulting .exe.

I have tried putting editbin in the project properties "Post-build Event
Command Line", but no matter how I try it won't work. Even if I hardcode the
path to editbin (which is not very helpful since the solution is compiled on
different computers with difference install paths) it fails without
explanation.

I suspect there are some environment or other settings that would enable
this to work without hardcoded paths. Any hints?
Gary Chang[MSFT]
2005-10-27 09:08:35 UTC
Permalink
Hi Dave,
Post by Dave Booker
I suspect there are some environment or other settings
that would enable this to work without hardcoded paths.
yes, there are some common used environment macro identifiers in the
Command Line dialog box, you can click the rightmost button of the
command-line edit box to invoke it.

The target command line would be like the following one:
editbin /LARGEADDRESSAWARE %TargetDir%%TarGetFileName% > result1.txt

The above command output will be redirect to the result1.txt of the
project's directory.


Wish this help!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
Dave Booker
2005-10-28 19:04:01 UTC
Permalink
This isn't working. First of all, it cannot locate the editbin command by
itself, and I can't find any environment variables that it might use to find
it (e.g., %VCINSTALLDIR% is not defined in whatever mysterious environment
the post-build uses).

I can hardcode the path to editbin, which isn't very useful because I use
dev machines with different install structuresI think my problem is locating
the "editbin" command. But even when I do that the "Post Build Event Failed"
and it just says a tool returned an error code from the build event. The >
result.txt file is empty.
Post by Gary Chang[MSFT]
Hi Dave,
Post by Dave Booker
I suspect there are some environment or other settings
that would enable this to work without hardcoded paths.
yes, there are some common used environment macro identifiers in the
Command Line dialog box, you can click the rightmost button of the
command-line edit box to invoke it.
editbin /LARGEADDRESSAWARE %TargetDir%%TarGetFileName% > result1.txt
The above command output will be redirect to the result1.txt of the
project's directory.
Wish this help!
Best regards,
Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
Gary Chang[MSFT]
2005-11-01 03:23:24 UTC
Permalink
Post by Dave Booker
This isn't working. First of all, it cannot locate the editbin command
by itself, and I can't find any environment variables that it might use
to find it (e.g., %VCINSTALLDIR% is not defined in whatever
mysterious environment the post-build uses).
It really works on my machine. the Editbin.exe utility is in the Vc7\bin\
directory, its corrsponding path env variable should be auto applied to
your current VS2003 IDE's process session.

Can you find the Editbin.exe utility in your VSInstallDir's Vc7\bin\
directory, and would you please tell me could you execute it in the VS2003
Command Prompt console window?

By the way, use the macro TargetPath is more simple:
editbin /LARGEADDRESSAWARE %TargetPath% > result1.txt


Thanks!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
Dave Booker
2005-11-01 17:26:17 UTC
Permalink
Editbin.exe is indeed in Vc7\bin\, and it is in the path for my VS2003
Command Prompt (i.e., I can call it from any location with just "editbin").

It seems that there is something wrong with the environment being used for
the post-build batch. I checked its environment variables by changing the
PostBuild to run "set > chk.txt", and the settings are significantly fewer
than what I get in the command prompt. Vc7\bin is not there, and for that
matter neither are any of the %target% variables you suggested.

How did this happen to me, and how should I fix it?

Thanks.
Gary Chang[MSFT]
2005-11-02 03:14:56 UTC
Permalink
Hi Dave,
Post by Dave Booker
It seems that there is something wrong with the environment
being used for the post-build batch.
Can you execute some other tools(such as sn.exe, dumpbin.exe) in the
post-build event command?


The environment variables of the VS2003 IDE's process should be set in the
following batch file:

\VSInstallDir\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat

Coulu you find the "@set PATH=%DevEnvDir%;%MSVCDir%\BIN;..." in that bat
file? By the way, the %TargetPath% is not a environment variable, it just
one of your current project's macros, so it will not in the PATH
variables...


Thanks!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
Dave Booker
2005-11-02 18:31:07 UTC
Permalink
I cannot execut sn or dumpbin in the post-build command. They also fail with
"'sn' is not recognized as an internal or external command..."

However, vsvars32.bat is in the directory you indicated and does contain the
@set PATH as you indicated.

BTW, I guess I should have noted earlier that I am running Windows Server
2003 x64, so the VSInstallDir is "C:\Program Files (x86)", though I don't see
how that should hurt....
Post by Gary Chang[MSFT]
Hi Dave,
Post by Dave Booker
It seems that there is something wrong with the environment
being used for the post-build batch.
Can you execute some other tools(such as sn.exe, dumpbin.exe) in the
post-build event command?
The environment variables of the VS2003 IDE's process should be set in the
\VSInstallDir\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat
file? By the way, the %TargetPath% is not a environment variable, it just
one of your current project's macros, so it will not in the PATH
variables...
Gary Chang[MSFT]
2005-11-03 07:19:49 UTC
Permalink
Hi Dave,
Post by Dave Booker
However, vsvars32.bat is in the directory you indicated and does
BTW, I guess I should have noted earlier that I am running Windows
Server 2003 x64, so the VSInstallDir is "C:\Program Files (x86)",
though I don't see how that should hurt.....
so this would be the problem, the VS.NET 2003 is not a 64bit application,
it doesn't provide the 64bit computable VS.NET utility(editbin, dumpbin).
So the PATH variables which is used under x32 system will not be applied to
your x64 system's VS2003 IDE process, this is why the environment variables
are significantly fewer than what you get in the command prompt.

So in this scenario, I suggest you had better use the x64 specific utility
from the latest platform SDK and add its corresponding directory to your
system's PATH environment variable.


Thanks!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
galgitron
2010-03-25 15:37:47 UTC
Permalink
Just went through my own session of agony to get this to work in the post-build event. The problem lies in the fact that the post-build doesn't leverage the same PATH variable that the VS CMD prompt does (why? It's VS!). So, I had to add a few paths to my system PATH variable to be sure that both the EditBin.exe, and mspdb80.dll files could be found. Once I did this, and (VERY IMPORTANT) restarted Visual Studio, I was able to use: editbin.exe /LARGEADDRESSAWARE "$(TargetPath)" in my post build. I verified it was working with the: dumpbin /headers {filename} command in a cmd prompt

From http://www.developmentnow.com/g/55_2005_10_0_0_625763/Post-build-editbin.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com/g/

Loading...