RE: Windows Installer removes embedded resource manifest ?



I found the 'problem'. The built deployment project never got the modified
..EXE file. I will post all the information in hopes it will help others.

My postbuild steps were set up to put the application.exe.manifest file
containing the required Vista <security>...</security> into the .exe found in
$(TargetDir)$(TargetFileName) as follows:

In the Build Events of the project (Post-build event command line):
set DEVENVDIR=$(DevEnvDir)
set PROJECTDIR=$(ProjectDir)
set TARGETNAME=$(TargetName)
set TARGETDIR=$(TargetDir)
set TARGETFILENAME=$(TargetFileName)
set CONFIGURATIONNAME=$(ConfigurationName)
call "$(ProjectDir)PostBuild.cmd"

In the file PostBuild.cmd kept with the Appliction Project:

rem Add the postbuild WIN32 resource identifying the Assembly Security for
Vista
@echo off
set INPUT="%PROJECTDIR%%TARGETNAME%.exe.manifest"
set BINOUTPUT="%TARGETDIR%%TARGETFILENAME%"
pushd %DEVENVDIR%
rem Check for existence of MT.EXE command on system (from .NET 3.0 SDK
assumed to be installed at default location)
pushd ..\..\..\Microsoft SDKs\Windows\v6.0\bin
IF ERRORLEVEL 1 goto NOMT
..\mt.exe -nologo -manifest %INPUT% -outputresource:%BINOUTPUT%;#1
IF ERRORLEVEL 0 goto :EOF
:NOMT
echo %INPUT% manifest resource NOT applied to %BINOUTPUT%
if NOT "%CONFIGURATIONNAME%" == "Release" exit 0


My 'problem' was that the deployment project in the solution was set to use
'Primary output from Application.Project' which is NOT
$(TargetDir)$(TargetFileName);
Deployment projects get their 'input' from
$(TargetDir)..\..\OBJ\$(ConfigurationName)\$(TargetFileName)

I ended up modifying my PostBuild.cmd file with the following steps:

set OBJOUTPUT="%TARGETDIR%..\..\obj\%CONFIGURATIONNAME%\%TARGETFILENAME%"
set BINOUTPUT="%TARGETDIR%%TARGETFILENAME%"
pushd %DEVENVDIR%
rem Check for existence of MT.EXE command on system (from .NET 3.0 SDK
assumed to be installed at default location)
pushd ..\..\..\Microsoft SDKs\Windows\v6.0\bin
IF ERRORLEVEL 1 goto NOMT
..\mt.exe -nologo -manifest %INPUT% -outputresource:%BINOUTPUT%;#1
..\mt.exe -nologo -manifest %INPUT% -outputresource:%OBJOUTPUT%;#1


This ensures both the .EXE under OBJ and the one under BIN get the resource
added to them.

It is not clear why I need to apply the postbuild step to both files; One
would assume doing it to perhaps the OBJ file alone would be sufficient, but
experimentation showed this not to be the case.


Thanks for your other information; I will investigate alternative methods to
embedding the necessary .manifest resource as you suggest. However, if I have
to still build a .RES file separately (from a .RC source file) then embed
that built .RES file into the solution for inclusion, then I have still have
an external dependence on some other project that keeps the .RES file
correct. There appears to be no single step in a managed code project to keep
the .RC source, invoke the resource compiler to build the .RES file, and then
have the .RES file added to the built executable......
There are other resources required to be added besides the RT_MANIFEST (like
the application Icon...)

Also, the Updated Vista Logo Test cases now recommend using CFF Explorer
instead of Resource Hacker to inspect the executables.

"Steven Cheng[MSFT]" wrote:

Hello Keith,

From your description, you're building a Vista awared application which
will need to embed an manifest file in the win32 resource collection.
However, you found the res manifest occur in the built exe but disappear
after packaged it and deploy onto vista machine, correct?

Based on my experience, windows installer package or the visual studio
setup project won't automatically remove resource from program. In setup
project, you simply add those existing files(exe , dll. ...) into it and it
will copy it and merge into setup package. For your issue, I think there
may has something else cause the manifest not work.

Since you said you have to use the "Post Build" event to inject the win32
resource, are you building a managed application? If so, the Visual Studio
IDE's project properties has provided the built-in support on embed a win32
resource file(.res) into the managed exe program. You find the setting
through the following steps:

** select project node in solution explorer and choose "properties" menu
item
** in the properties setting explorer, choose the first "application" tab
in left view

* in the rigth panel, you can find the "resources" section, by default it
is set as "Icon", you can change it to "Resource File" and manually choose
a win32 res resource file.

Here is a blog article provide detailed description on embed Manifest into
managed code:

#Adding a UAC Manifest to Managed Code
http://blogs.msdn.com/shawnfa/archive/2006/04/06/568563.aspx

In addition, for the problem exe program. You can use the Visual Studio
resource editor(or the resource hacker you used) to inspect the exe after
the setup program install it on Vista box.(you can also try installing it
on other OS to see whether the installed exe contains the manifest)

Please feel free to let me know if there is anything I missed or if you
have got any further finding.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.


.



Relevant Pages

  • RE: Windows Installer removes embedded resource manifest ?
    ... will need to embed an manifest file in the win32 resource collection. ... you found the res manifest occur in the built exe but disappear ... Since you said you have to use the "Post Build" event to inject the win32 ...
    (microsoft.public.vsnet.general)
  • C# and native resources
    ... The suggested solution on MSDN is unworkable (manually opening the ... EXE using VS as a resource editor and inserting the manifet resource). ... It seems like some kind of command-line tool to insert the manifest resource ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# and native resources
    ... The suggested solution on MSDN is unworkable (manually opening the EXE using VS as a resource editor and inserting the manifet resource). ... It seems like some kind of command-line tool to insert the manifest resource after the fact would be a good solution - there are a variety of such tools on that market, all of which seem overpriced for such a simple task. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Icon not shown?
    ... the icon shows ok at the development ... Sounds to me the resource is ... >>somehow not built into the executable. ... > You can check your idea by loading the EXE file into ...
    (microsoft.public.vc.language)
  • Re: How to load resorces of a form that is not loaded
    ... There is a *very* complicated API - updateresource I believe - but I've never seen a successful VB demo of it. ... picture on a form) using the VB resource editor, you can reference those from anywhere within your application to display as required wherever you want. ... I don't care if they are stored as standard resources or like the forms does, embedded somehow in the exe, as long as I can access then later at any time when the exe is compiled. ...
    (microsoft.public.vb.general.discussion)

Quantcast