Trouble setting up Multi-Versioning

Trouble setting up Multi-Versioning

Maltezc
Advocate Advocate
969 Views
2 Replies
Message 1 of 3

Trouble setting up Multi-Versioning

Maltezc
Advocate
Advocate

 

 

Hi all, I have a plugin that I'm trying to get working on Revit 2022 however I am having issues with assigning the correct .pbd file to the version and debugging.

 

Context:

I have Revit 2020, 2021, and 2022 on my computer(mac running Parallels) and Revit 2022 API has deprecated `Autodesk.Revit.DB.UnitType` and is now using `Autodesk.Revit.DB.SpectTypeId` so that means I have to figure this out. 

 

I am working on setting up the multi-versioning according to Jeremey Tammik's post and this thread here

 

I have set up my .csproj so that it tries to run the references based upon what version of Revit is running as opposed to what .net framework version is running although I am not sure if this is correct.

 

This might be a lot for some but any and all help is appreciated. Been at this for 2 days.

 

My Revit API is the .dll from Revit 2022. 

 

What currently happens is when I run in 2020, I get this error: 

 

MYAPPNAME.dll	MYAPPNAME.dll	C:\Users\MYNAME\AppData\Roaming\Autodesk\Revit\Addins\2020\MYAPPNAME.dll	No	N/A	Symbols loaded.	\\Mac\Home\Desktop\RevitAPI-CSharp\MYAPPNAME\MYAPPNAME\obj\Debug2020\MYAPPNAME.pdb	200	2020.0.0.0	6/2/2021 7:02 PM	00000177017C0000-00000177017E8000	[10976] Revit.exe: Managed (v4.0.30319)		

 

When I check what .pbd module is found and running in Modules, I see that it's searching for the .pbd in the wrong location. it's searching the addins folder when it should be searching the bin/debug2020 folder.

It shows me this from the Symbol Load Information:

C:\Users\MYNAME\AppData\Roaming\Autodesk\Revit\Addins\2020\MYAPPNAME.pdb: Cannot find or open the PDB file.
\\Mac\Home\Desktop\RevitAPI-CSharp\MYAPPNAME\MYAPPNAME\obj\Debug2020\MYAPPNAME.pdb: Symbols loaded.

 

Here is my setup:

.csproj

<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{70F64388-E18B-493B-8CCB-AF58A39B5688}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>MYAPPNAME</RootNamespace>
    <AssemblyName>MYAPPNAME</AssemblyName>
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug2020|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE;REVIT2020</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <RevitVersion>2020</RevitVersion>
    <StartAction>Program</StartAction>
    <StartProgram>$(ProgramW6432)\Autodesk\Revit 2020\Revit.exe</StartProgram>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <StartAction>Program</StartAction>
    <StartProgram>$(ProgramW6432)\Autodesk\Revit 2020\Revit.exe</StartProgram>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug2021|AnyCPU'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\Debug2021\</OutputPath>
    <DefineConstants>DEBUG;TRACE;REVIT2021</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <ErrorReport>prompt</ErrorReport>
    <RevitVersion>2021</RevitVersion>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug2022|AnyCPU'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\Debug2022\</OutputPath>
    <DefineConstants>DEBUG;TRACE;REVIT2022</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <ErrorReport>prompt</ErrorReport>
    <RevitVersion>2022</RevitVersion>
  </PropertyGroup>

<!--...SOME OTHERCODE HERE...-->

<ItemGroup Condition=" '$(RevitVersion)' == '2020' ">
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
    <Reference Include="RevitAPI">
      <HintPath>C:\Program Files\Autodesk\Revit 2020\RevitAPI.dll</HintPath>
    </Reference>
    <Reference Include="RevitAPIUI">
      <HintPath>C:\Program Files\Autodesk\Revit 2020\RevitAPIUI.dll</HintPath>
    </Reference>
[...OTHER REFERENCES HERE...]
</ItemGroup>

<ItemGroup Condition=" '$(RevitVersion)' == '2021' ">
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
    <Reference Include="RevitAPI">
      <HintPath>C:\Program Files\Autodesk\Revit 2021\RevitAPI.dll</HintPath>
    </Reference>
    <Reference Include="RevitAPIUI">
      <HintPath>C:\Program Files\Autodesk\Revit 2021\RevitAPIUI.dll</HintPath>
    </Reference>
[...OTHER REFERENCES HERE...]
</ItemGroup>

<ItemGroup Condition=" '$(RevitVersion)' == '2022' ">
    <Reference Include="RevitAPI">
      <HintPath>C:\Program Files\Autodesk\Revit 2022\RevitAPI.dll</HintPath>
    </Reference>
    <Reference Include="RevitAPIUI">
      <HintPath>C:\Program Files\Autodesk\Revit 2022\RevitAPIUI.dll</HintPath>
    </Reference>
[...OTHER REFERENCES HERE...]
</ItemGroup>

 

 

 

 

 

 

0 Likes
970 Views
2 Replies
Replies (2)
Message 2 of 3

David_Robison
Advocate
Advocate

Based on my experiences, I am going to make a suggestion:

 

Create separate SLN and CSPROJ files for each version of Revit.

 

What you are doing is the more "correct" way. I tried doing it that way too. Getting the conditionals to work for the references was complicated and fragile. I ended up with tons of headaches like you are experiencing.

 

I finally gave up and created a separate project for each version.

 

The drawback is that when you add files, you have to remember to add it to all your project versions. Yes, it is a pain. But it is only a little extra work and a fairly mechanical copy and paste between files. It is much less of a pain I have found than trying to get the references right.

0 Likes
Message 3 of 3

Maltezc
Advocate
Advocate

@David_Robison I've seemed to have gotten it working for now. 

 

To my surprise, it turns out I had the .csproj file set up correctly. 

 

After that, I ended up having to do a couple of steps:

 

1. clean all builds and remove any residual files.

 

2. write a line in the post-build that copies the newly created .pdb from the bin/debug folder over to the addins folder where the debugger was looking for it. After researching a bit how the debugger checks for .pdb files, It checks where the .dll is created first apparently, if it can't find that then it ends up finding the one in the obj/bin folder. If it can't find it there then it searches the very very first Debug folder that was originally created when you first ran the build. 

 

For some reason, I wasn't able to set the path using the Tools --> Options --> Debugging --> Symbols --> Set Symbol File Locations as shown in the previous hyperlink. 

 

We'll see how long this lasts. Hopefully, it doesn't break. 

 

Feel free to pm me if you give it another try and need help. 

0 Likes