-
Notifications
You must be signed in to change notification settings - Fork 33
Third party files
By default, the .dll and .addin files are copied to the output project folder. But often it becomes necessary to add Nuget packages, localization files, configs and other things. To add such files, you need to do three steps in the .csproj project file.
All files that will be copied to the Revit Add-ins folder and also added to the installer must be tagged. Initially, the .addin file is assigned the Tag RootItem, for the main project file AddinItem.
<ItemGroup>
<RootItem Include="$(ProjectDir)*.addin" />
<AddinItem Include="$(TargetDir)$(AssemblyName).dll" />
</ItemGroup>
All project files from bin folder:
<ItemGroup>
<RootItem Include="$(ProjectDir)*.addin" />
<AddinItem Include="$(TargetDir)*" />
</ItemGroup>
You can add both individual files and groups of files. It makes sense to add different tag names only when the output folder is different. You can find the names of the dll files in the bin folder.
<ItemGroup>
<RootItem Include="$(ProjectDir)*.addin" />
<AddinItem Include="$(TargetDir)$(AssemblyName).dll" />
<!--Files to copy to Revit add-ins folder-->
<AddinItem Include="$(TargetDir)Azure.Core.dll" />
<AddinItem Include="$(TargetDir)Azure.Data.Tables.dll" />
<AddinItem Include="$(TargetDir)Azure.Storage.Common.dll" />
<AddinItem Include="$(TargetDir)Azure.Storage.Files.Shares.dll" />
<DataItem Include="Resources\Data\config.txt" />
<FamilyItem Include="Resources\Families\$(RevitVersion)\Family.rfa" />
<LocalizationDeItem Include="$(TargetDir)de\$(AssemblyName).resources.dll" />
</ItemGroup>
Remember to use wildcards when adding libraries with similar names. The example above can be optimized to look like:
<ItemGroup>
<RootItem Include="$(ProjectDir)*.addin" />
<AddinItem Include="$(TargetDir)$(AssemblyName).dll" />
<!--Files to copy to Revit add-ins folder-->
<AddinItem Include="$(TargetDir)Azure.*.dll" />
<DataItem Include="Resources\Data\*" />
<FamilyItem Include="Resources\Families\$(RevitVersion)\*" />
<LocalizationDeItem Include="$(TargetDir)de\*" />
</ItemGroup>
Added all packages that start with Azure, added all files from the Data and Families folders.
Initially, the structure of the output folders looks like this:
- The .addin manifest is located at the root, it is necessary for Revit to detect it.
- All other files are located in the folder that corresponds to the name of the project.
<PropertyGroup>
<RootDir>bin\AddIn $(RevitVersion) $(Configuration)\</RootDir>
<AddinDir>$(RootDir)$(AssemblyName)\</AddinDir>
</PropertyGroup>
RootDir is a buffer folder where all marked files will be copied. Then an installer will be created based on it and the files will be copied to the Revit add-ins folder.
To keep the Revit add-ins folder clean, specify subdirectories based on the AddinDir tag only or his descendants.
<PropertyGroup>
<RootDir>bin\AddIn $(RevitVersion) $(Configuration)\</RootDir>
<AddinDir>$(RootDir)$(AssemblyName)\</AddinDir>
<DataDir>$(AddinDir)\Data</DataDir>
<FamiliesDir>$(AddinDir)\Families</FamiliesDir>
<LocalizationDeDir>$(AddinDir)\de</FamiliesDir>
</PropertyGroup>
After we have marked all files and output folders, we need to add a task for Msbuild, copy the first to the second.
Reminder: syntax for calling item @(ItemTag), property $(PropertyTag).
<Copy SourceFiles="@(RootItem)" DestinationFolder="$(RootDir)" />
<Copy SourceFiles="@(AddinItem)" DestinationFolder="$(AddinDir)" />
Establish the relationship between files and folders as you need.
<Copy SourceFiles="@(RootItem)" DestinationFolder="$(RootDir)" />
<Copy SourceFiles="@(AddinItem)" DestinationFolder="$(AddinDir)" />
<Copy SourceFiles="@(DataItem)" DestinationFolder="$(DataDir)" />
<Copy SourceFiles="@(FamilyItem)" DestinationFolder="$(FamiliesDir)" />
<Copy SourceFiles="@(LocalizationDeItem)" DestinationFolder="$(LocalizationDeDir)" />
📂Root
┣📜RevitAddIn.addin
┗📂RevitAddIn
┣📂de
┃ ┗📜RevitAddIn.resources.dll
┣📂Data
┃ ┗📜config.txt
┣📂Families
┃ ┗📜Family.rfa
┣📜Azure.Core.dll
┣📜Azure.Data.Tables.dll
┣📜Azure.Storage.Common.dll
┣📜Azure.Storage.Files.Shares.dll
┗📜RevitAddIn.dll