Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Light throws an exception if access to the msi is denied #4097

Closed
wixbot opened this Issue Sep 3, 2013 · 14 comments

Comments

Projects
None yet
1 participant
Collaborator

wixbot commented Sep 3, 2013

During the Light stage of our build we have gotten these errors sporadically. We have had these issues within a XP virtual machine and now a Windows Server 2012.

Not only does this affect our builds success, it also pops up a error box that waits to be dismissed. This holds up the entire build queue.

It appears that the file is missing from this location.

[exec] 2>       Unhandled Exception: System.UnauthorizedAccessException: Access to the path 'C:\Users\buildrd\AppData\Local\Temp\2\0g3e0mzf\ToolRoom.msi' is denied.
[exec] 2>          at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
[exec] 2>          at System.IO.File.SetAttributes(String path, FileAttributes fileAttributes)
[exec] 2>          at Microsoft.Tools.WindowsInstallerXml.Common.RecursiveFileAttributes(String path, FileAttributes fileAttribute, Boolean markAttribute)
[exec] 2>          at Microsoft.Tools.WindowsInstallerXml.Common.DeleteTempFiles(String path, IMessageHandler messageHandler)
[exec] 2>          at Microsoft.Tools.WindowsInstallerXml.Validator.DeleteTempFiles()
[exec] 2>          at Microsoft.Tools.WindowsInstallerXml.Binder.Cleanup(Boolean tidy)
[exec] 2>          at Microsoft.Tools.WindowsInstallerXml.Tools.Light.Run(String[] args)
[exec] 2>          at Microsoft.Tools.WindowsInstallerXml.Tools.Light.Main(String[] args)
[exec] 2>C:\Program Files (x86)\MSBuild\Microsoft\WiX\v3.x\wix200x.targets(2496,5): error MSB6006: "Light.exe" exited with code -532462766.

We are using Light version 3.8.1128.0

Originally opened by cameron

Collaborator

wixbot commented Sep 4, 2013

What's the version of light.exe?

Originally posted by barnson

Collaborator

wixbot commented Sep 4, 2013

We are using light 3.7.1224.0

Originally posted by cameron

Collaborator

wixbot commented Sep 19, 2013

Can you post a screen shot of the error dialog so we can see what it's throwing?

Originally posted by barnson

Collaborator

wixbot commented Sep 24, 2013

Sorry, what did you need a screenshot of? On our build server we usually get a standard windows crash dialog, and the stack trace we get in Jenkins is posted above. The exception that is thrown is System.UnauthorizedAccessException. If you really need a screenshot of the dialog, I will try get one next time it crashes.

Originally posted by cameron

Collaborator

wixbot commented Sep 26, 2013

Here are the screenshots of the error dialog
Image Text
Image Text

Originally posted by cameron

Collaborator

wixbot commented Sep 26, 2013

Okay, so dropbox links dont work with your image tag:

https://www.dropbox.com/s/3wax7g6w44m5klv/wix1.png
https://www.dropbox.com/s/ovsigtsox8f0l87/wix2.png

Originally posted by cameron

Collaborator

wixbot commented Nov 12, 2013

I have narrowed the exception down to the following code:

foreach (string filePath in Directory.GetFiles(path))
{
    FileAttributes attributes = File.GetAttributes(filePath);
    if (markAttribute)
    {
        attributes = attributes | fileAttribute; // add to list of attributes
    }
    else if (fileAttribute == (attributes & fileAttribute)) // if attribute set
    {
        attributes = attributes ^ fileAttribute; // remove from list of attributes
    }
    File.SetAttributes(filePath, attributes); <---- Exception thrown here.
}

I tried to fix this like so:

foreach (string filePath in Directory.GetFiles(path))
{
    FileAttributes attributes = File.GetAttributes(filePath);
    if (markAttribute)
    {
        attributes = attributes | fileAttribute; // add to list of attributes
    }
    else if (fileAttribute == (attributes & fileAttribute)) // if attribute set
    {
        attributes = attributes ^ fileAttribute; // remove from list of attributes
    }
    try
    {
        if (File.Exists(filePath)) {
            File.SetAttributes(filePath, attributes);
        }
    }
    catch (UnauthorizedAccessException)
    {
        Console.WriteLine("Could not take ownership of file: "+filePath);
    }
}

But I cant seem to compile the WiX project properly with Visual Studio 2010. It does appear to be a trivial fix though.

Note that the file that this exception is thrown for, is never actually there after stopping the build process, so it is getting deleted regardless of this error.

Originally posted by cameron

Collaborator

wixbot commented Jan 17, 2014

This issue is still present in wix 3.8. Are there any plans to fix this?

Originally posted by cameron

Collaborator

wixbot commented Jan 17, 2014

Originally changed by cameron
Release changed from v3.x to v3.8

Collaborator

wixbot commented Jan 21, 2014

The most common cause of errors like this is things like anti-virus scanners that lock WiX's intermediate files. However, WiX should always gracefully handle exceptions, so this is open to be fixed in the WiX v3.x series.

Originally posted by barnson
Release changed from v3.8 to v3.x

Collaborator

wixbot commented Jun 9, 2014

Originally changed by champloo
AssignedTo set to champloo

Collaborator

wixbot commented Jun 9, 2014

I've submitted a pull request that fixes this issue. I would like to see this make it into the 3.9 release.

My hunch on why the issue occurs intermittently is that Directory.Delete is non-blocking and Windows merely marks the files for deletion. So there is a chance that RecursiveFileAttributes will enumerate the file in the for loop, but by the time it gets to the File.SetAttributes the file may no longer exist.

Originally posted by champloo
Status changed from Open to Untriaged

Collaborator

wixbot commented Jun 12, 2014

Release changed from v3.x to v3.9

Collaborator

wixbot commented Jul 10, 2014

Resolution set to fixed
Status changed from Open to Resolved

@wixbot wixbot added bug linker labels Dec 20, 2015

@wixbot wixbot added this to the v3.9 milestone Dec 20, 2015

@wixbot wixbot closed this Dec 20, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment