Build Dynamo from Source
Dynamo's source is hosted on Github for anyone to clone and make contributions to. In this chapter, we will walk through how to clone the repository using git, compile the source files with Visual Studio, run and debug a local build, and pull any new changes from Github.
Locating the Dynamo repositories on Github
Github is a hosting service based on git, a version control system for tracking changes and coordinating work between people. Git is a tool we can leverage to download Dynamo's source files, and keep them updated with a few commands. Using this method will avoid the unnecessary and inherently messy work of downloading and manually replacing the source files at every update. The git version control system will track any differences between a local and remote code repository.
Dynamo's source is hosted on the DynamoDS Github in this repository: https://github.com/DynamoDS/Dynamo
![](https://primer2.dynamobim.org/~gitbook/image?url=https%3A%2F%2F1734247194-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FY5ZuHF3yuXFWp1C46ZSo%252Fuploads%252Fgit-blob-f24202eacf5cb89e1b98d9b0d66fe4498abece8b%252Fgithub.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=164b3cd8&sv=1)
The Dynamo source files.
Clone or download the entire repository
View other DynamoDS repositories
Dynamo's source files
Git specific files
Pulling the Dynamo repository using git
Before we can clone the repository, we need to install git. Follow this short guide for installation steps, and how to setup a gihub username and email. For this example, we will be using git on the command line. This guide assumes you will be using windows but you can also use git on mac or linux to clone the dynamo source.
We need a URL for the Dynamo repository to clone from. This can be found in the "Clone or download" button on the repository page. Copy the URL to paste into command prompt.
![](https://primer2.dynamobim.org/~gitbook/image?url=https%3A%2F%2F1734247194-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FY5ZuHF3yuXFWp1C46ZSo%252Fuploads%252Fgit-blob-b5e11671afdacbfb38ff08ed0c26f71b67b979e9%252Fgithub-clone.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=af15db3e&sv=1)
Select "Clone or download"
Copy the URL
With git installed, we can clone the Dynamo repository. Start by opening command prompt. Then use the change directory command cd
to navigate to the folder where we want the source files to be cloned to. In this case, we have created a folder called Github
in Documents
.
cd C:\Users\username\Documents\GitHub
Replace "username" with your user name
![](https://primer2.dynamobim.org/~gitbook/image?url=https%3A%2F%2F1734247194-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FY5ZuHF3yuXFWp1C46ZSo%252Fuploads%252Fgit-blob-bd20fb5556614b7c4bf706baac8c50ae110fedca%252Fcli-1.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=a52873e8&sv=1)
In the next step we will run a git command to clone the Dynamo repository to the location we specified. The URL in the command is obtained by clicking on the "Clone or Download" button on Github. Run this command in the command terminal. Note that this will clone the Dynamo repo master branch which is most updated code for Dynamo, and will contain to the latest version of Dynamo code. This branch changes daily.
git clone https://github.com/DynamoDS/Dynamo.git
![](https://primer2.dynamobim.org/~gitbook/image?url=https%3A%2F%2F1734247194-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FY5ZuHF3yuXFWp1C46ZSo%252Fuploads%252Fgit-blob-2de914ebedd416bd171ffd5534f1328b12df551a%252Fcli-2.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=5c47bab3&sv=1)
We know git is working if the cloning operation completed successfully. In the file explorer, navigate to the directory where you cloned to see the source files. the directory structure should look identical to the Dynamo repository's master branch on Github.
![](https://primer2.dynamobim.org/~gitbook/image?url=https%3A%2F%2F1734247194-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FY5ZuHF3yuXFWp1C46ZSo%252Fuploads%252Fgit-blob-114be7d7a8f800947b7a60b389675dbfeab8116d%252Fsource-files.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=d4d816e2&sv=1)
Dynamo's source files
Git files
Building the repository using Visual Studio
With the source files now cloned to our local machine, we can build an executable file for Dynamo. In order to do this, we will need to set up the Visual Studio IDE and ensure that the .NET Framework and DirectX are installed.
Download and install Microsoft Visual Studio Community 2015, a free, fully-featured IDE (integrated development environment - later versions may work as well)
Download and install Microsoft .NET Framework 4.5 or later
Install Microsoft DirectX from the local Dynamo repository (
Dynamo\tools\install\Extra\DirectX\DXSETUP.exe
)
.NET and DirectX may already be installed.
Once everything is finished installing, we can start Visual Studio and open the Dynamo.All.sln
solution located in Dynamo\src
.
![](https://primer2.dynamobim.org/~gitbook/image?url=https%3A%2F%2F1734247194-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FY5ZuHF3yuXFWp1C46ZSo%252Fuploads%252Fgit-blob-883741e4bbd1ce98cbe79cdeee7f1e2f5346d471%252Fvs-open-dynamo.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=1a0ca4ef&sv=1)
Select
File > Open > Project/Solution
Browse to the Dynamo repository and open the
src
folderSelect the
Dynamo.All.sln
solution fileSelect
Open
Before we can build the solution, a few settings should be specified. We should first build a debug version of Dynamo so visual studio can gather more information while debugging to help us develop, and we want to target AnyCPU.
![](https://primer2.dynamobim.org/~gitbook/image?url=https%3A%2F%2F1734247194-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FY5ZuHF3yuXFWp1C46ZSo%252Fuploads%252Fgit-blob-4568c4f9ade376fb36a46df0c5876ff03acb6f9b%252Fvs-dynamo-build-settings.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=3c199098&sv=1)
These will become folders inside the
bin
folder
For this example we chose
Debug
as the Solution ConfigurationSet the Solution Platform to
Any CPU
With the project open, we can build the solution. This process will create a DynamoSandbox.exe file that we can run.
![](https://primer2.dynamobim.org/~gitbook/image?url=https%3A%2F%2F1734247194-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FY5ZuHF3yuXFWp1C46ZSo%252Fuploads%252Fgit-blob-41b8db25d60ec6fcaf90025fc5730e21651f407c%252Fvs-build-dynamo.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=65575dc8&sv=1)
Building the project will restore NuGet dependencies.
Select
Build > Build Solution
Verify that the build was successful in the Output window, it should read similar to
==== Build: 69 succeeded, 0 failed, 0 up-to-date, 0 skipped ====
Running a local build
If Dynamo builds successfully, a bin
folder will be created in the Dynamo repository with the DynamoSandbox.exe file. In our case, we're building with the Debug option, so the executable file is located in bin\AnyCPU\Debug
. Running this will open a local build of Dynamo.
![](https://primer2.dynamobim.org/~gitbook/image?url=https%3A%2F%2F1734247194-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FY5ZuHF3yuXFWp1C46ZSo%252Fuploads%252Fgit-blob-71975b42e7c413f00c7ff471b0d32fabac28bc85%252Fex-dynamosandbox.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=6d3becfa&sv=1)
The DynamoSandbox executable we just built. Run this to start Dynamo.
Now we are almost fully set up to start developing for Dynamo.
For instructions on building Dynamo for other platforms (e.g. Linux or OS X) visit this wiki page.
Debugging a local build using Visual Studio
Debugging is a process of identifying, isolating, and correcting a bug or issue. Once Dynamo has been successfully built from source, we can use several tools in Visual Studio to debug a running application, the DynamoRevit add-in for example. We can analyze its source code to find the root of an issue, or watch the currently executing code. For a more detailed explanation of how to debug and navigate code in Visual Studio, refer to the Visual Studio Docs.
For the standalone Dynamo application, DynamoSandbox, we will cover two options for debugging:
Build and start Dynamo directly from Visual Studio
Attach Visual Studio to a running process of Dynamo
Starting Dynamo from Visual Studio rebuilds the solution for every debugging session if required, so if we made changes to the source they will be incorporated when debugging. With the Dynamo.All.sln
solution still open, select Debug
, AnyCPU
, and DynamoSandbox
from the drop-down menus and then click Start
. This will build Dynamo and start a new process (DynamoSandbox.exe), and attach Visual Studio's debugger to it.
![](https://primer2.dynamobim.org/~gitbook/image?url=https%3A%2F%2F1734247194-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FY5ZuHF3yuXFWp1C46ZSo%252Fuploads%252Fgit-blob-9659ee42c5c1bdbd7c237dbd1f691bed813ae3f9%252Fvs-debug-options.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=1c285e84&sv=1)
Build and start the application directly from Visual Studio
Set configuration to
Debug
Set platform to
Any CPU
Set startup project to
DynamoSandbox
Click
Start
to begin the debugging process
Alternatively, we may want to debug a Dynamo process that is already running to troubleshoot an issue with a specific graph open or package. For this purpose, we would open the project's source files in Visual Studio and attach to a running Dynamo process using the Attach to Process
debug menu item.
![](https://primer2.dynamobim.org/~gitbook/image?url=https%3A%2F%2F1734247194-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FY5ZuHF3yuXFWp1C46ZSo%252Fuploads%252Fgit-blob-82298abe67816267907f0c2539c6890a20f6683e%252Fvs-attach-dynamosandbox.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=ede1170f&sv=1)
Attach a running process to Visual Studio
Select
Debug > Attach to Process...
Choose
DynamoSandbox.exe
Select
Attach
In both situations we are attaching the debugger to a process we wish to debug. We can set break points in the code before or after starting the debugger that will cause the process to pause immediately before executing that line of code. If an uncaught exception is thrown while debugging, Visual Studio will jump to where it occurred in the source code. This is an efficient method for finding simple crashes, unhandled exceptions, and to understand the execution flow of an application.
![](https://primer2.dynamobim.org/~gitbook/image?url=https%3A%2F%2F1734247194-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FY5ZuHF3yuXFWp1C46ZSo%252Fuploads%252Fgit-blob-6da6fcc123e3451b033006a8bbba9908a2f5fffb%252Fvs-debug-dynamocore.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=a200d30f&sv=1)
While debugging DynamoSandbox, we set a breakpoint in the Color.ByARGB node's constructor that causes the Dynamo process to pause when the node is instantiated. If this node was throwing an exception or causing Dynamo to crash, we could step through each line in the constructor to find where the issue was occurring.
The breakpoint
The call stack showing the function which is currently being executed and previous function calls.
In the next section, Build DynamoRevit from Source, we will walk through a specific example of debugging, and explain how to set break points, step through code, and read the call stack.
Pulling latest build
Since the Dynamo source is hosted on Github, the easiest way to keep local source files updated is by pulling changes using git commands.
Using the command line, set the current directory to the Dynamo repository:
cd C:\Users\username\Documents\GitHub\Dynamo
Replace
"username"
with your username
Use the following command to pull the latest changes:
git pull origin master
![](https://primer2.dynamobim.org/~gitbook/image?url=https%3A%2F%2F1734247194-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FY5ZuHF3yuXFWp1C46ZSo%252Fuploads%252Fgit-blob-16fccf38f3029f8d38fd1f3eaca36d7496722c5c%252Fcli-pull-changes.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=34bd77d9&sv=1)
Here we can see that the local repository has been updated with changes from the remote.
In addition to pulling updates, there are four more git workflows to be familiar with.
Fork the Dynamo repository to create a copy separate from the original. Any changes made here will not affect the original repository and updates can be fetched from or submitted with pull requests. Fork is not a git command, but is a workflow that github adds - the fork, pull request model is one of the most common workflows for contributing to open source projects online. It is worth learning if you want to contribute to Dynamo.
Branch - work on experiments or new features isolated from other work in branches. This makes sending pull requests easier.
Make commits often, after completing a unit of work, and after a change that may want to be undone. A commit records changes to the repository and will be visible when making a pull request to the main Dynamo repository.
Create pull requests when changes are ready to be officially proposed to the main Dynamo repository.
The Dynamo team has specific instructions on creating pull requests. Refer to the Pull Requests section in this documentation for more detailed items to address.
See this documentation page for a reference list of git commands.
Last updated