I am currently trying to build MSI files to install our Autodesk Revit add-ins. For this I use Wix 4 (4.0.1). Now it is so that I get 125 errors during the first build process with "dotnet build", which are the same in the end, for example:
error WIX0204: ICE38: Component cmpzmkEAcTZtTI0KSrp2ZJdAgISCqI installs to user profile. It must use a registry key under HKCU as its KeyPath, not a file.
or:
error WIX0204: ICE64: The directory dirDJNwmpPrhlGvVgcLiGNLNVrKCYs is in the user profile but is not listed in the RemoveFile table.
For 3-4 folders I could solve the problem by using "RemoveFolder".
Now I use HarvestDirectory to include all necessary .DLL and .addin files in the installer. This works so far, but then I get the above mentioned error messages. The funny thing is: When I run dotnet build the first time, I get the errors. As soon as I run it a second time, the errors are gone and everything works. If I now run dotnet clean and then run dotnet build again, the errors are there again until I run dotnet build a second time.
Can anyone help me here ? I only read "You have to delete the Directories with RemoveDirectory", which I do, for the 4 folders. But not for HarvestDirectory. Is there a way that HarvestDirectory creates the entries itself? Because if I now have to manually enter the files and folders to delete, I might as well not bother harvesting.
It wouldn't necessarily bother me now in general if the MSI is only created after the 2nd dotnet build. However, the installer should be created automatically in our CI/CD pipeline afterwards. And there I would not like to have to run dotnet build 2 times and ignore the first run.
Am I missing something here?
And regarding the deletion of the Autodesk/Revit/Addin/YEAR folders: Actually, I don't want to remove the folders at all. I understand that the folders are not deleted if there are still files in them (e.g. other Revit add-ins), however I don't really want to remove the folders under any circumstances. Optimal would be: What I create is deleted afterwards, the rest is not touched. Is there a solution for this? I mean, that must be common practice that you delete only those things from the system that you yourself have put there, or am I wrong there ?
TestInstaller.wixproj:
<Project Sdk="WixToolset.Sdk/4.0.1">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DefineConstants>Debug</DefineConstants>
<SuppressValidation>true</SuppressValidation>
<SuppressSpecificWarnings>
</SuppressSpecificWarnings>
<SuppressIces>
</SuppressIces>
</PropertyGroup>
<ItemGroup>
<HarvestDirectory Include="AddInFiles/Revit20200/AddIn">
<ComponentGroupName>Revit20200AddInFilesCompontent</ComponentGroupName>
<DirectoryRefId>_2020_INSTALLFOLDER</DirectoryRefId>
<SuppressRootDirectory>true</SuppressRootDirectory>
</HarvestDirectory>
<BindPath Include="AddInFiles/Revit20200/AddIn" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="WixToolset.Heat" Version="4.0.1" />
</ItemGroup>
</Project>
Product.wxs:
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package InstallerVersion="200"
Language="1033"
Manufacturer="Plandata GmbH"
Name="TestInstaller"
UpgradeCode="e049d997-c8f5-48b3-932f-1e630368e985"
Version="1.0.0.0">
<Feature Id="R2020_0" Title="Revit 2020.0" Level="1">
<ComponentGroupRef Id="Revit20200" />
</Feature>
<StandardDirectory Id="AppDataFolder">
<Directory Id="AutodeskFolder" Name="Autodesk">
<Directory Id="RevitFolder" Name="Revit">
<Directory Id="AddinsFolder" Name="Addins">
<Directory Id="_2020_INSTALLFOLDER" Name="2020" />
</Directory>
</Directory>
</Directory>
</StandardDirectory>
</Package>
</Wix>
Revit20200.wxs
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<ComponentGroup Id="Revit20200" Directory="_2020_INSTALLFOLDER">
<Component Id="Uninstall_20200" Guid="4BF7FEE0-310B-4A29-80EE-D578A7646B94">
<RemoveFolder On="uninstall" />
<RemoveFolder Directory="AutodeskFolder" On="uninstall" />
<RemoveFolder Directory="RevitFolder" On="uninstall" />
<RemoveFolder Directory="AddinsFolder" On="uninstall" />
<RegistryValue Key="Software\PlandataAddIns\Remove_20200"
KeyPath="yes"
Root="HKCU"
Value="Test" />
</Component>
<ComponentGroupRef Id="Revit20200AddInFilesCompontent" />
</ComponentGroup>
</Fragment>
</Wix>