Search code examples
installationwixcustom-actiondtf

Do managed CA's use streamwriter differently?


Has anyone experienced an error in which the custom action's temporary extraction path is appended when creating a file?

I have a managed custom action (64-bit C# DLL using Microsoft.Deployment.WindowsInstaller) that performs some system checks. It writes an inf style key=value file in a deferred CA. There's really nothing fancy going on here just a File.Create(FullPathToFile).

But when I attempt to write the file the temporary directory the CA is extracted to is included for some reason.

MSI (s) (3C:E4) [10:19:36:712]: Hello, I'm your 64bit Elevated custom action server.

SFXCA: Extracting custom action to temporary directory: C:\Windows\Installer\MSIC451.tmp-\

SFXCA: Binding to CLR version v2.0.50727

System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Windows Installer\MSIC451.tmp-*C:\Program Files\Path the property file should be written to*'. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at .....

Is there something strange with the way managed CA's use stream writer?


Solution

  • I finally figured out that the variable I was trying to use included a property ie:[TARGETDIR]\otherstuff. When I used the variable for as a file path I expected the path C:\Program Files\productname\otherstuff\mystuff. But not the property. When used with some operations (StreamWriter in this case) the property would not resolve properly gave me the error above.

    After I figured out that part of the path was actually resolved from a property I was able to make changes to resolve the path I needed from the property and everything works as expected.

    session.Format(Property) or session[Property]