Revit 二次开发多版本架构
一、选对项目模板
二、选择 " .Net Standard 2.0 "
三、请直接Copy至项目配置中 (各版本API需要提前准备好,路径引用即可)
<PropertyGroup> <TargetFramework>net48</TargetFramework> <Configurations>Debug;Release;RVT_18;RVT_19;RVT_20;RVT_21;RVT_22;RVT_23;RVT_24;RVT_25</Configurations> <UseWindowsForms>True</UseWindowsForms> <UseWPF>true</UseWPF> <Authors>Shaw Black</Authors> <Copyright>BlackBox</Copyright> <StartAction>Program</StartAction> <PlatformTarget>x64</PlatformTarget> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)'=='Debug'"> <StartProgram>C:\Program Files\Autodesk\Revit 2018\Revit.exe</StartProgram> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)'=='RVT_18'"> <StartProgram>C:\Program Files\Autodesk\Revit 2018\Revit.exe</StartProgram> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)'=='RVT_20'"> <StartProgram>C:\Program Files\Autodesk\Revit 2020\Revit.exe</StartProgram> </PropertyGroup> <ItemGroup> <Reference Include="RevitAPI" Condition="'$(Configuration)'=='Debug'"> <HintPath>..\RevitAPI\2018\RevitAPI.dll</HintPath> </Reference> <Reference Include="RevitAPIIFC" Condition="'$(Configuration)'=='Debug'"> <HintPath>..\RevitAPI\2018\RevitAPIIFC.dll</HintPath> </Reference> <Reference Include="RevitAPIUI" Condition="'$(Configuration)'=='Debug'"> <HintPath>..\RevitAPI\2018\RevitAPIUI.dll</HintPath> </Reference> <Reference Include="RevitAPI" Condition="'$(Configuration)'=='RVT_18'"> <HintPath>..\RevitAPI\2018\RevitAPI.dll</HintPath> </Reference> <Reference Include="RevitAPIIFC" Condition="'$(Configuration)'=='RVT_18'"> <HintPath>..\RevitAPI\2018\RevitAPIIFC.dll</HintPath> </Reference> <Reference Include="RevitAPIUI" Condition="'$(Configuration)'=='RVT_18'"> <HintPath>..\RevitAPI\2018\RevitAPIUI.dll</HintPath> </Reference> <Reference Include="RevitAPI" Condition="'$(Configuration)'=='RVT_20'"> <HintPath>..\RevitAPI\2020\RevitAPI.dll</HintPath> </Reference> <Reference Include="RevitAPIIFC" Condition="'$(Configuration)'=='RVT_20'"> <HintPath>..\RevitAPI\2020\RevitAPIIFC.dll</HintPath> </Reference> <Reference Include="RevitAPIUI" Condition="'$(Configuration)'=='RVT_20'"> <HintPath>..\RevitAPI\2020\RevitAPIUI.dll</HintPath> </Reference> </ItemGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RVT_18|AnyCPU'"> <Optimize>True</Optimize> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RVT_19|AnyCPU'"> <Optimize>True</Optimize> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RVT_20|AnyCPU'"> <Optimize>True</Optimize> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RVT_21|AnyCPU'"> <Optimize>True</Optimize> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RVT_22|AnyCPU'"> <Optimize>True</Optimize> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RVT_23|AnyCPU'"> <Optimize>True</Optimize> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RVT_24|AnyCPU'"> <Optimize>True</Optimize> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RVT_25|AnyCPU'"> <Optimize>True</Optimize> </PropertyGroup>
四、到配置管理器中,新建一个个版本
对于配置好的版本,需要将配置选到对应版本
五、创建资源