Skip to content

Commit

Permalink
Merge pull request dotnet#4568 from dotnet/developer-guide-targetfile
Browse files Browse the repository at this point in the history
Debugging locally built WPF assemblies with WPF Application
  • Loading branch information
singhashish-wpf authored Sep 29, 2021
2 parents 2c07197 + dfaaad8 commit 55bce96
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Documentation/developer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ If there were any failures, you can cd into $(RepoRoot)\artifacts\test\$(Configu

*NOTE: This requires being run from an admin window at the moment. Removing this restriction is tracked by https://github.com/dotnet/wpf/issues/816.*

### Debugging locally built WPF assemblies with WPF Application
This section is intended to simplify the steps needed to be able to debug the locally built WPF Assemblies, with any sample app.
Configure the project to build x86 or x64, as per the platform architecture you have selected while performing the build for WPF assemblies.
Go to the csproj file and append this line at the bottom of it. `<Import Project="$(WpfRepoRoot)\eng\wpf-debug.targets" />`. The resultant csproj will look like this:
```xml
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>

<PropertyGroup>
<WpfRepoRoot>C:\wpf</WpfRepoRoot>
</PropertyGroup>
<Import Project="$(WpfRepoRoot)\eng\wpf-debug.targets" />
```


### Testing Locally built WPF assemblies (excluding PresentationBuildTasks)
This section of guide is intended to discuss the different approaches for ad-hoc testing of WPF assemblies,
and not automated testing. For automated testing, see the [Running DRTs locally](#Running-DRTs-locally) section above. There are a few different ways this can be done, and for the most part, it depends on what you are trying to accomplish. This section tries to lay out which scenarios require which workflow.
Expand Down
23 changes: 23 additions & 0 deletions eng/wpf-debug.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
Copy PropertyGroup and Import item into the csproj file.
Update the path, as per the path to repo.
<PropertyGroup>
<WpfRepoRoot>C:\wpf</WpfRepoRoot>
</PropertyGroup>
<Import Project="$(WpfRepoRoot)\eng\wpf-debug.targets" />
-->

<PropertyGroup>
<WpfConfig Condition="'$(WpfConfig)'==''">Debug</WpfConfig>
<RuntimeIdentifier>win-$(PlatformTarget)</RuntimeIdentifier>
<WPFArtifactsPath>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\'))\artifacts\packaging\$(WpfConfig)\Microsoft.DotNet.Wpf.GitHub.$(WpfConfig)</WPFArtifactsPath>
</PropertyGroup>

<ItemGroup>
<Reference Include="$(WPFArtifactsPath)\lib\$(TargetFramework.Split('-')[0])\*.dll" />
<ReferenceCopyLocalPaths Include="$(WPFArtifactsPath)\runtimes\$(RuntimeIdentifier)\native\*.dll" />
</ItemGroup>
</Project>

0 comments on commit 55bce96

Please sign in to comment.