Wix# using standard Path.GetTempPath
& Path.GetTempFileName
methods to get location for temp files.
Per the documentation these methods checks for the existence of environment variables in the following order and returns the first path found:
- The path specified by the
TMP
environment variable.
- The path specified by the
TEMP
environment variable.
- The path specified by the
USERPROFILE
environment variable.
- The Windows directory.
So, you can change the temp folder location by changing TMP
environment variable for the project during the build and msi authoring.
To do so you need to add the following into your wix# csproj (tested for sdk-style project)
<UsingTask TaskName="SetEnvironmentVariableTask"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Name ParameterType="System.String" Required="true" />
<Value ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Code Type="Fragment" Language="cs">
<![CDATA[
Environment.SetEnvironmentVariable(Name, Value);
]]>
</Code>
</Task>
</UsingTask>
<Target Name="SampleTarget" BeforeTargets="MSIAuthoring">
<SetEnvironmentVariableTask Name="TMP" Value="D:\temp\" />
</Target>
Here we can see:
SetEnvironmentVariableTask
inline task which executes the C# code specified inside a Code
node
SampleTarget
target which is called before wix# MSIAuthoring
target and calls SetEnvironmentVariableTask
to set %tmp%
to the D:\temp\
.
Notes:
- you need to create your new
%temp%
folder before authoring msi. You can do this manually or add appropriate code into the Main
before any wix# actions.
- this code relies on the wix# target name
MSIAuthoring
(source) which is subject to change on the wix#-side. So, you need to control this aspect on every wix# update and update your code accordingly.