Skip to content

building WPF from source for advanced instrumentation and debugging in Dynamo

Michael Kirschner edited this page Jan 22, 2025 · 3 revisions

why?

  • You want to profile or trace parts of WPF that the standard WPF trace loggers can't help you with.
  • You are curious how WPF works.
  • You want to modify WPF and bundle it with Dynamo because you are out of all other options. 😬

building:

  1. Clone the GitHub Repository:
    • git clone https://github.com/dotnet/wpf.git
  2. Switch to the .NET 8 Release Tag version 8.0.12 (since Dynamo is currently targeting net8)
    • git checkout v8.0.12
  3. Install Required Build Workflows:
    • Ensure you have installed necessary tools like the Windows 10 SDK version 10.0.19041.0 or later.
    • You can import an install configuration using Visual Studio Installer by using the import config option and pointing to:
    • Make sure you use the correct config for the branch/tag you are on.
  4. Navigate to the Repository and Build:
    • cd <repository-directory>
    • build.cmd -platform x64

debugging:

To make Dynamo load your newly built WPF binaries the simplest approach I found was to make a few modifications to the DynamoSandbox.csproj add the following to the bottom of the file.

<PropertyGroup>
    <SelfContained>true</SelfContained>
<!-- you'll need to adjust this path if you built wpf for x86 or release etc -->
<WPFArtifactsPath>path\To\WPF_REPO\wpf\artifacts\packaging\Debug\x64\Microsoft.DotNet.Wpf.GitHub.Debug</WPFArtifactsPath>
</PropertyGroup>
<ItemGroup>
      <Reference Include="$(WPFArtifactsPath)\lib\$(TargetFramework.Split('-')[0])\*.dll" />
      <ReferenceCopyLocalPaths Include="$(WPFArtifactsPath)\runtimes\$(RuntimeIdentifier)\native\*.dll" />
</ItemGroup>

This does two things:

  1. sets sandbox as a non framework dependent app, (standalone) this means the runtime binaries are copied to the output path, and critically it will try to load framework binaries from there.
  2. The reference statements copy the wpf binaries to our output path instead of the ones from the shared runtime location. This is because msbuild will prefer newer file version numbers. Locally built copies of WPF have this crazy version number: 42.42.42.42424 ... someone loves Hitchhiker's Guide. Because it's likely that this is > 8.0.0 or 9.0.0 these binaries get copied.

Unfortunately, we can no longer startup DynamoSandbox in visual studio under debug. We get this mysterious error I have not been able to resolve.

The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
The program '[39080] DynamoSandbox.exe' has exited with code 2147516545 (0x80008081).

but what we can do is start it via dotnet exec and then attach after it boots.

C:\Users\user\source\repos\Dynamo\bin\AnyCPU\Release>dotnet exec DynamoSandbox.dll
FindAncestorOfType took: 0ms
FindAncestorOfType took: 0ms
FindAncestorOfType took: 0ms

Releases

Roadmap

How To

Dynamo Internals

Contributing

Python3 Upgrade Work

Libraries

FAQs

API and Dynamo Nodes

Clone this wiki locally