New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary files directory cannot be created #5920

Open
andersfrisk77 opened this Issue Dec 14, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@andersfrisk77
Copy link

andersfrisk77 commented Dec 14, 2018

Bugs

If this issue is a bug:

  • Which version of WiX are you building with?
    v3.14.0.1703

  • Which version of Visual Studio are you building with (if any)?
    Visual Studio Professional 15.9.2

  • Which version of the WiX Toolset Visual Studio Extension are you building with (if any)?
    3.11.1

  • Which version of .NET are you building with?
    net472

  • If the problem occurs when installing your packages built with WiX, what is the version of Windows the package is running on?
    Windows 10 Pro x64 10.0.15063

  • Describe the problem and the steps to reproduce it.

I use Gitlab and its CI pipelines to build, test and deploy an application. I have created a project in Gitlab where I use Wix to produce an installer. Everything goes fine when I build the installer myself (when I log in as a normal user) but when the Gitlab runner (installed as service) tries to build the installer an error occurs. (The Gitlab runner is installed on a similiar Windows machine and the runner is an administrative user).

When I run the pipeline a strange error occurs. The runner cannot create a temporary directory , see stack trace below;:

light.exe : error LGHT0001: A required privilege is not held by the client [C:\Multi-Runner\builds\2eac19ee\0\SES\Installation\WindowsInstaller\WindowsInstaller.wixproj]

Exception Type: System.ComponentModel.Win32Exception

Stack Trace:
at Microsoft.Win32.NativeMethods.CreateDirectory(String path, SafeLocalMemHandle acl)
at System.CodeDom.Compiler.TempFileCollection.CreateTempDirectoryWithAce(String directory, String identity)
at System.CodeDom.Compiler.TempFileCollection.GetTempFileName(String tempDir)
at System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated()
at Microsoft.Tools.WindowsInstallerXml.WixBinder.get_TempFilesLocation()
at Microsoft.Tools.WindowsInstallerXml.WixBinder..ctor()
at Microsoft.Tools.WindowsInstallerXml.Binder..ctor()
at Microsoft.Tools.WindowsInstallerXml.Tools.Light.Run(String[] args)
Done Building Project "C:\Multi-Runner\builds\2eac19ee\0\SES\Installation\WindowsInstaller\WindowsInstaller.wixproj" (default targets) -- FAILED.

According to the documentation it is possible override temporary directory with an enviromental variable:
WIX_TEMP overrides the temporary directory used for cab creation, msm exploding, ...

Following the stack trace above and looking at the source code I see that a object of class Binder is created and Binder inherits from WixBinder. In the constructor of WixBinder the TempFilesLocation property is called. Then the property BasePath of TempFileCollection is used which causes after some steps a directory to be created
(see NativeMethods.CreateDirectory(directory, acl)) but not where I specify according to the enviromental variable. This causes the crash because I am not allowed to create this directory.

The code tries to set the path later (see row
this.fileManager.TempFilesLocation = this.tempFiles.BasePath;)
but then it is too late.

My suggestion is to rewrite the code to use the contructor
TempFileCollection(string tempDir) to set the specified path.

@barnson

This comment has been minimized.

Copy link
Member

barnson commented Dec 20, 2018

Sounds like #5859. Does GitLab CI run elevated?

@andersfrisk77

This comment has been minimized.

Copy link

andersfrisk77 commented Dec 20, 2018

Yes,
I have added whoami command before doing the msbuild of my wix project.

The whoami returns
nt authority\system

Relatered to this user I have also seen that the nuget package cache is under C:\Windows\System32\config\systemprofile folder which can also be problematic.

@barnson

This comment has been minimized.

Copy link
Member

barnson commented Dec 20, 2018

OK, that's the same issue then, in a different place.

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