I installed Revit 2019 and compiled the Revit 2019 SDK.
That was quite a struggle:
- Installing Revit 2019
- Installing the Revit 2019 SDK
- Installing the .NET Framework 4.7
- Compiling the Revit 2019 SDK samples
- Processor architecture mismatch warnings
- DimensionLeaderEnd
OutputPath
missing - Numerous Revit API assembly reference conflicts
- SampleCommandsSteelElements lacks components
- AppearanceAssetEditing using deprecated API
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:
- C:\Autodesk\Revit_2019_G1_Win_64bit_dlm\Utilities\SDK\RevitSDK.exe
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 82 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:
- Warning: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "RevitAPI", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. RebarFreeForm
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:
- Error: The OutputPath property is not set for project 'DimensionLeaderEnd.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='AnyCPU'. This error may also appear if some other project is trying to follow a project-to-project reference to this project, this project has been unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Configuration or Platform. DimensionLeaderEnd
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:
- Warning: Could not resolve this reference. Could not locate the assembly "RevitAPIUI". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. AppearanceAssetEditing
- Warning: No way to resolve conflict between "RevitAPIUI, Version=19.0.0.0, Culture=neutral, PublicKeyToken=null" and "RevitAPIUI". Choosing "RevitAPIUI, Version=19.0.0.0, Culture=neutral, PublicKeyToken=null" arbitrarily. AppearanceAssetEditing
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:
- Warning: Could not resolve this reference. Could not locate the assembly "RevitAddInUtility". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. RebarFreeForm
- Warning: No way to resolve conflict between "RevitAddInUtility, Version=19.0.0.0, Culture=neutral, PublicKeyToken=null" and "RevitAddInUtility". Choosing "RevitAddInUtility, Version=19.0.0.0, Culture=neutral, PublicKeyToken=null" arbitrarily. RebarFreeForm
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:
- Warning: Could not resolve this reference. Could not locate the assembly "RevitAddInUtility". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. SampleCommandsSteelElements
- Warning: Could not resolve this reference. Could not locate the assembly "RvtDwgAddon". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. SampleCommandsSteelElements
- Warning: Could not resolve this reference. Could not locate the assembly "ASObjectsMgd". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. SampleCommandsSteelElements
- Warning: Could not resolve this reference. Could not locate the assembly "RevitAPI". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. SampleCommandsSteelElements
- Warning: No way to resolve conflict between "RevitAddInUtility, Version=19.0.0.0, Culture=neutral, PublicKeyToken=null" and "RevitAddInUtility". Choosing "RevitAddInUtility, Version=19.0.0.0, Culture=neutral, PublicKeyToken=null" arbitrarily. SampleCommandsSteelElements
- Warning: The referenced component 'RevitAPISteel' could not be found. SampleCommandsSteelElements
- Warning: Could not resolve this reference. Could not locate the assembly "RevitAPISteel". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. SampleCommandsSteelElements
- Warning: The referenced component 'RvtDwgAddon' could not be found. SampleCommandsSteelElements
- Warning: Could not resolve this reference. Could not locate the assembly "ASCADLinkMgd". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. SampleCommandsSteelElements
- Warning: The referenced component 'ASCADLinkMgd' could not be found. SampleCommandsSteelElements
- Warning: No way to resolve conflict between "RevitAPIUI, Version=19.0.0.0, Culture=neutral, PublicKeyToken=null" and "RevitAPIUI". Choosing "RevitAPIUI, Version=19.0.0.0, Culture=neutral, PublicKeyToken=null" arbitrarily. SampleCommandsSteelElements
- Warning: Could not resolve this reference. Could not locate the assembly "ASGeometryMgd". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. SampleCommandsSteelElements
- Warning: The referenced component 'ASGeometryMgd' could not be found. SampleCommandsSteelElements
- Warning: Could not resolve this reference. Could not locate the assembly "RevitAPIUI". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. SampleCommandsSteelElements
- Warning: No way to resolve conflict between "RevitAPI, Version=19.0.0.0, Culture=neutral, PublicKeyToken=null" and "RevitAPI". Choosing "RevitAPI, Version=19.0.0.0, Culture=neutral, PublicKeyToken=null" arbitrarily. SampleCommandsSteelElements
- Warning: The referenced component 'ASObjectsMgd' could not be found. SampleCommandsSteelElements
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:
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:
- Error CS0618: 'AssetProperties.this[string]' is obsolete: ' This property is deprecated in Revit 2019 and will be removed in the next version of Revit. We suggest you use the 'FindByName(String)' or 'Get(int)' method instead.' AppearanceAssetEditing C:\a\lib\revit\2019\SDK\Samples\AppearanceAssetEditing\CS\Application.cs 208 Active
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:
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.