Compiling the Revit 2019 SDK Samples

I installed Revit 2019 and compiled the Revit 2019 SDK.

That was quite a struggle:

Installing Revit 2019

That was easy and unproblematic.

Installing the Revit 2019 SDK

I searched the installation subfolders for RevitSDK.exe and found it here:

That was easy to install as well.

Installing the .NET Framework 4.7

I set about compiling the SDK samples and discovered that this is not possible without first installing the .NET framework 4.7.

I am still using Visual Studio 2015, by the way.

For that information, all further API details and system requirements, please refer to the Revit 2019 API Developers Guide.

I searched for install .net 4.7 framework and was led to download it from the Microsoft download centre, providing NDP47-KB3186497-x86-x64-AllOS-ENU.exe.

The .NET framework 4.7 was still not listed in the Visual Studio 2015 target framework options, though.

How to fix that is explained in the StackOverflow thread on using Visual Studio 2015 to target .NET framework 4.7:

Having the 4.7 runtime and having the "4.7 Targeting pack" to write code in 4.7 are two very different things.

The targeting packs are available from microsoft.com/net/targeting.

Accordingly, I installed the 4.7 targeting pack NDP47-DevPack-KB3186612-ENU.exe (86492264 bytes).

Now the .NET framework 4.7 is indeed listed in the VS target framework options, and I can load the SDK samples successfully with no warnings.

Unfortunately, though, compiling them is quite another matter:

Compiling the Revit 2019 SDK Samples

The SDK samples solution now contains 186 projects.

On the first attempt, many of them compiled successfully.

In fact, there were 182 projects succeeded and 4 failed with 2 errors and 70 warnings, cf. the error and warning list.

Processor Architecture Mismatch Warnings

Many of the warnings concern an architecture mismatch warning:

These warnings can be suppressed using my DisableMismatchWarning exe utility to recursively disable architecture mismatch warnings.

After running that, the number of problems is reduced to 183 succeeded and 3 failed with 1 error and 40 warnings.

DimensionLeaderEnd OutputPath Missing

Next, I addressed the first serious hurdle for successful compilation, which took me a while to figure out:

After some head scratching, I finally fixed it very easily, by manually adding an OutputPath tag to Debug AnyCPU PropertyGroup the project file:

  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>9.0.30729</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{4E3C160F-1FC8-4BD7-8E01-B62C58E79CD4}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Revit.SDK.Samples.DimensionLeaderEnd.CS</RootNamespace>
    <AssemblyName>DimensionLeaderEnd</AssemblyName>
    <StartupObject>
    </StartupObject>
    <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
    <TargetFrameworkProfile />
    <OutputPath>bin\x64\Debug\</OutputPath>
  </PropertyGroup>

This results in 0 errors, 29 warnings, 184 succeeded, 2 failed.

Numerous Revit API Assembly Reference Conflicts

Some of the remaining warnings are caused by the AppearanceAssetEditing project and concern an assembly reference conflict:

I deleted the existing references to RevitAPI.dll and RevitAPIUI.dll and added them again manually, pointing to the installed assemblies in the Revit.exe folder.

That reduced the number of warnings from 29 to 25, so we now have 0 errors, 25 warnings, 184 succeeded, 2 failed.

I did the same for the RebarFreeForm project, resulting in 21 warnings, leaving 0 errors, 21 warnings, 184 succeeded, 2 failed.

RebarFreeForm still has a problem with the RevitAddInUtility reference, though:

That one did not even need re-referencing; it is superfluous.

I simply removed it entirely, resulting in 19 warnings, leaving 0 errors, 19 warnings, 184 succeeded, 2 failed.

SampleCommandsSteelElements Lacks Components

The SampleCommandsSteelElements cannot be compiled due to numerous unresolved references:

One of these references refers to the module ASObjectsMgd.

This is in fact available in the add-ins packaged with Revit itself, in the subdirectory /AddIns/SteelConnections:

/v/C/Program Files/Autodesk/Revit 2019 $ find . | grep ASObjectsMgd
./AddIns/SteelConnections/ASObjectsMgd.dll

I found and re-referenced all the required references:

SampleCommandsSteelElements references

It now compiles successfully, so we have just one failing project left.

SampleCommandsSteelElements is now producing other warnings, though.

AppearanceAssetEditing Using Deprecated API

The remaining failing project is AppearanceAssetEditing.

It is producing new errors, so we now see 185 succeeded, 1 failed, 7 errors, 9 warnings.

The seven errors in AppearanceAssetEditing are caused by deprecated API calls:

These calls are classed as errors instead of warnings, causing the project compilation to fail, because this is explicitly requested in the project build properties – treat all warnings as errors:

AppearanceAssetEditing build properties

I changed the setting from 'All' to 'None'.

Now I can build that project as well, and finally the Revit 2019 SDK compilation is complete.

186 projects succeeded, 0 failed and 0 were skipped.

Zero errors now, but 16 warnings still remain.

I will ask the development team to clean this up asap to avoid forcing other Revit add-in developers to repeat these utterly unneccessary and frustrating steps.