Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove NetCoreReference #9914

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Documentation/LocalMarkupCompilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,4 @@ It can be enabled for a project by setting this:
In addition to these, care must be taken for the following:

- Use `<EmbeddedResource>` instead of `<Resource>`
- `PresentationBuildTask` will strip out `<Resource>` items during `_CompileTemporaryAssembly` phase. Using `EmbeddedResource` is equivalent (esp. in for `Xlf` based string resource generation with `Arcade.Sdk`) and will not be adversely affected by `PresentationBuildTasks` transformations.
- Always use `<NetCoreReference>` instead of implicitly acquiring the full set of `Microsoft.NetCore.App` references.
- `Microsoft.NetCore.App` contains a version `WindowsBase` that clashes with WPF's `WindowsBase` during markup compilation.
- To avoid this clash, we must always specify the references we need explicitly.
- Also, our code-base requires that all references be specified explicitly anyway to avoid inadvertent reference-creep to bug-fixes.
- `PresentationBuildTask` will strip out `<Resource>` items during `_CompileTemporaryAssembly` phase. Using `EmbeddedResource` is equivalent (esp. in for `Xlf` based string resource generation with `Arcade.Sdk`) and will not be adversely affected by `PresentationBuildTasks` transformations.
117 changes: 71 additions & 46 deletions Microsoft.Dotnet.Wpf.sln
Original file line number Diff line number Diff line change
Expand Up @@ -239,21 +239,48 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OSVersionHelper", "src\Micr
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PresentationNative", "src\Microsoft.DotNet.Wpf\redist\PresentationNative\PresentationNative.vcxproj", "{AF9084C3-BF37-4A56-A851-89F3BAE731B3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F3F4DFE8-A29C-4BA1-964D-954AB6732744}"
JeremyKuhne marked this conversation as resolved.
Show resolved Hide resolved
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Microsoft.DotNet.Wpf", "Microsoft.DotNet.Wpf", "{C9ECC1A1-917F-43D3-B340-2035B4938507}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{34B64A4A-7C83-4F92-8C47-80E9FA10D660}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnitTests", "UnitTests", "{A48B585E-6AB0-4F8D-8484-77F37CB44437}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xaml.Tests", "src\Microsoft.DotNet.Wpf\tests\UnitTests\System.Xaml.Tests\System.Xaml.Tests.csproj", "{B2F2A89C-55C9-41B1-A645-0948609BD8BE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PresentationFramework.Fluent", "src\Microsoft.DotNet.Wpf\src\Themes\PresentationFramework.Fluent\PresentationFramework.Fluent.csproj", "{3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PresentationFramework.Fluent-ref", "src\Microsoft.DotNet.Wpf\src\Themes\PresentationFramework.Fluent\ref\PresentationFramework.Fluent-ref.csproj", "{3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PresentationCore.Tests", "src\Microsoft.DotNet.Wpf\tests\UnitTests\PresentationCore.Tests\PresentationCore.Tests.csproj", "{A4377D3F-6BA1-4994-945C-88667993E4F3}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "eng", "eng", "{92968783-2008-4A16-A823-6737224FEB9E}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
eng\WpfArcadeSdk\Sdk\Sdk.props = eng\WpfArcadeSdk\Sdk\Sdk.props
eng\WpfArcadeSdk\Sdk\Sdk.targets = eng\WpfArcadeSdk\Sdk\Sdk.targets
eng\WpfArcadeSdk\tools\SdkReferences.targets = eng\WpfArcadeSdk\tools\SdkReferences.targets
eng\Versions.props = eng\Versions.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentation", "{B90B3D18-1B80-4FAF-A8DF-146C4F930AF9}"
ProjectSection(SolutionItems) = preProject
Documentation\acceptance_criteria.md = Documentation\acceptance_criteria.md
Documentation\api-compat.md = Documentation\api-compat.md
Documentation\C++-notes.md = Documentation\C++-notes.md
Documentation\c++-private-tools.md = Documentation\c++-private-tools.md
Documentation\codegen.md = Documentation\codegen.md
Documentation\contributing.md = Documentation\contributing.md
Documentation\cycle-breakers.md = Documentation\cycle-breakers.md
Documentation\developer-guide.md = Documentation\developer-guide.md
Documentation\gen-api.md = Documentation\gen-api.md
Documentation\getting-started.md = Documentation\getting-started.md
Documentation\issue-guide.md = Documentation\issue-guide.md
Documentation\localization_untranslated_strings.md = Documentation\localization_untranslated_strings.md
Documentation\LocalMarkupCompilation.md = Documentation\LocalMarkupCompilation.md
Documentation\packaging.md = Documentation\packaging.md
Documentation\projects-and-assemblies.md = Documentation\projects-and-assemblies.md
Documentation\redistributables.md = Documentation\redistributables.md
Documentation\report-on-adding-new-property.md = Documentation\report-on-adding-new-property.md
Documentation\solution-and-project-configurations.md = Documentation\solution-and-project-configurations.md
Documentation\testing-in-helix.md = Documentation\testing-in-helix.md
Documentation\wpf.vsconfig = Documentation\wpf.vsconfig
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PresentationCore.Tests", "src\Microsoft.DotNet.Wpf\tests\UnitTests\PresentationCore.Tests\PresentationCore.Tests.csproj", "{398CD1C6-A92E-4B63-97CD-4CABD96FA868}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Xaml.Tests", "src\Microsoft.DotNet.Wpf\tests\UnitTests\System.Xaml.Tests\System.Xaml.Tests.csproj", "{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -1926,22 +1953,6 @@ Global
{AF9084C3-BF37-4A56-A851-89F3BAE731B3}.Release|x86.ActiveCfg = Release|Win32
{AF9084C3-BF37-4A56-A851-89F3BAE731B3}.Release|x86.Build.0 = Release|Win32
{AF9084C3-BF37-4A56-A851-89F3BAE731B3}.Release|x86.Deploy.0 = Release|Win32
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Debug|ARM64.ActiveCfg = Debug|ARM64
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Debug|ARM64.Build.0 = Debug|ARM64
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Debug|x64.ActiveCfg = Debug|x64
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Debug|x64.Build.0 = Debug|x64
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Debug|x86.ActiveCfg = Debug|x86
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Debug|x86.Build.0 = Debug|x86
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Release|Any CPU.Build.0 = Release|Any CPU
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Release|ARM64.ActiveCfg = Release|ARM64
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Release|ARM64.Build.0 = Release|ARM64
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Release|x64.ActiveCfg = Release|x64
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Release|x64.Build.0 = Release|x64
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Release|x86.ActiveCfg = Release|x86
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Release|x86.Build.0 = Release|x86
{3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Debug|ARM64.ActiveCfg = Debug|arm64
Expand Down Expand Up @@ -1974,22 +1985,38 @@ Global
{3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Release|x64.Build.0 = Release|x64
{3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Release|x86.ActiveCfg = Release|Any CPU
{3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Release|x86.Build.0 = Release|Any CPU
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Debug|ARM64.ActiveCfg = Debug|ARM64
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Debug|ARM64.Build.0 = Debug|ARM64
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Debug|x64.ActiveCfg = Debug|x64
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Debug|x64.Build.0 = Debug|x64
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Debug|x86.ActiveCfg = Debug|x86
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Debug|x86.Build.0 = Debug|x86
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Release|Any CPU.Build.0 = Release|Any CPU
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Release|ARM64.ActiveCfg = Release|ARM64
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Release|ARM64.Build.0 = Release|ARM64
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Release|x64.ActiveCfg = Release|x64
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Release|x64.Build.0 = Release|x64
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Release|x86.ActiveCfg = Release|x86
{A4377D3F-6BA1-4994-945C-88667993E4F3}.Release|x86.Build.0 = Release|x86
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Debug|Any CPU.Build.0 = Debug|Any CPU
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Debug|ARM64.ActiveCfg = Debug|ARM64
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Debug|ARM64.Build.0 = Debug|ARM64
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Debug|x64.ActiveCfg = Debug|x64
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Debug|x64.Build.0 = Debug|x64
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Debug|x86.ActiveCfg = Debug|x86
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Debug|x86.Build.0 = Debug|x86
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Release|Any CPU.ActiveCfg = Release|Any CPU
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Release|Any CPU.Build.0 = Release|Any CPU
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Release|ARM64.ActiveCfg = Release|ARM64
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Release|ARM64.Build.0 = Release|ARM64
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Release|x64.ActiveCfg = Release|x64
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Release|x64.Build.0 = Release|x64
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Release|x86.ActiveCfg = Release|x86
{398CD1C6-A92E-4B63-97CD-4CABD96FA868}.Release|x86.Build.0 = Release|x86
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Debug|ARM64.ActiveCfg = Debug|ARM64
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Debug|ARM64.Build.0 = Debug|ARM64
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Debug|x64.ActiveCfg = Debug|x64
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Debug|x64.Build.0 = Debug|x64
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Debug|x86.ActiveCfg = Debug|x86
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Debug|x86.Build.0 = Debug|x86
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Release|Any CPU.Build.0 = Release|Any CPU
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Release|ARM64.ActiveCfg = Release|ARM64
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Release|ARM64.Build.0 = Release|ARM64
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Release|x64.ActiveCfg = Release|x64
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Release|x64.Build.0 = Release|x64
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Release|x86.ActiveCfg = Release|x86
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2106,13 +2133,11 @@ Global
{7EE0E965-7DA4-4A94-9441-801E8D2CC1CD} = {4557C5C6-10B1-475C-8279-5511955D1C29}
{3801B5AE-6871-4A72-B400-1F6ABCBF9045} = {7EE0E965-7DA4-4A94-9441-801E8D2CC1CD}
{AF9084C3-BF37-4A56-A851-89F3BAE731B3} = {DDED00A7-24FD-4AEF-B264-2150F0E59B4D}
{C9ECC1A1-917F-43D3-B340-2035B4938507} = {F3F4DFE8-A29C-4BA1-964D-954AB6732744}
{34B64A4A-7C83-4F92-8C47-80E9FA10D660} = {C9ECC1A1-917F-43D3-B340-2035B4938507}
{A48B585E-6AB0-4F8D-8484-77F37CB44437} = {34B64A4A-7C83-4F92-8C47-80E9FA10D660}
{B2F2A89C-55C9-41B1-A645-0948609BD8BE} = {A48B585E-6AB0-4F8D-8484-77F37CB44437}
{A48B585E-6AB0-4F8D-8484-77F37CB44437} = {B0EFDB12-C931-4E7F-A6C2-D4AC111D7EDF}
{3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9} = {5ACFB055-649D-4A01-98C2-B0BFE7E543D6}
{3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD} = {60F4058B-D35B-42D2-B276-D44B3AC579BD}
{A4377D3F-6BA1-4994-945C-88667993E4F3} = {A48B585E-6AB0-4F8D-8484-77F37CB44437}
{398CD1C6-A92E-4B63-97CD-4CABD96FA868} = {A48B585E-6AB0-4F8D-8484-77F37CB44437}
{93C6A5C8-4545-49DD-8D48-DDD6665ADFC0} = {A48B585E-6AB0-4F8D-8484-77F37CB44437}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B4340004-DAC0-497D-B69D-CFA7CD93F567}
Expand Down
15 changes: 0 additions & 15 deletions eng/WpfArcadeSdk/tools/Pbt.targets
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,6 @@
-->
<EmbedUntrackedSources Condition="'$(InternalMarkupCompilation)'=='true'">false</EmbedUntrackedSources>
</PropertyGroup>
<!--
Internal PBT compilation requires that we use <NetCoreReference>
This is so that the copy of ref\WindowsBase.dll inherited from Microsoft.NetCore.App
does not make its way through to markup-compilation.

In addition to this, our codebase requires that all references to Microsoft.NetCore.App
be explicitly enumerated through the use of <NetCoreReference> to avoid inadvertent additions
to assembly references during code-changes.
-->
<ItemGroup Condition="'$(InternalMarkupCompilation)'=='true'">
<NetCoreReference Include="mscorlib" />
<NetCoreReference Include="System" />
<NetCoreReference Include="System.ComponentModel.TypeConverter" />
<NetCoreReference Include="System.Runtime" />
</ItemGroup>

<PropertyGroup Condition="'$(InternalMarkupCompilation)'=='true' And Exists('$(LocalMicrosoftWinFXTargets)')">
<PrepareResourceNamesDependsOn>
Expand Down
120 changes: 32 additions & 88 deletions eng/WpfArcadeSdk/tools/SdkReferences.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,14 @@
Version="$(MicrosoftPrivateWinformsVersion)"
ExcludeAssets="All"
GeneratePathProperty="True"
Condition="'$(MSBuildProjectExtension)'!='.vcxproj'
Condition="'$(MSBuildProjectExtension)' != '.vcxproj'
And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'
And $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '3.0'))
And '$(NoAutoMicrosoftPrivateWinformsReference)'!='true'"/>

<!--
When @(NetCoreReference) is non-empty, exclude all assets (ExcludeAssets = All) and re-add them in
ResolveMicrosoftNetCoreAppReferences target
-->
<PackageReference Update="Microsoft.NETCore.App"
GeneratePathProperty="true"
ExcludeAssets="All"
Condition="'@(NetCoreReference)'!='' And '$(DoNotLimitMicrosoftNetCoreReferences)'!='true' And '$(MSBuildProjectExtension)'!='.vcxproj' And '$(DisableImplicitFrameworkReferences)' != 'true' And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'" />
And '$(NoAutoMicrosoftPrivateWinformsReference)' != 'true'"/>

<PackageReference Update="Microsoft.NETCore.App"
GeneratePathProperty="true"
Condition="('@(NetCoreReference)'=='' Or '$(DoNotLimitMicrosoftNetCoreReferences)' == 'true') And '$(MSBuildProjectExtension)'!='.vcxproj' And '$(DisableImplicitFrameworkReferences)' != 'true' And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'" />
Condition="'$(MSBuildProjectExtension)'!='.vcxproj' And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'" />
</ItemGroup>

<Target Name="GeneratePathPropertyforMicrosoftWindowsDesktopApp"
Expand All @@ -40,82 +31,6 @@
</ResolveAssemblyReferencesDependsOn>
</PropertyGroup>


<Target
Name="LimitNetCoreAppReferences"
AfterTargets="ResolveTargetingPackAssets;ResolveTargetingPacks"
Returns="@(Reference)"
Condition="'@(NetCoreReference)' != '' And '@(Reference)' != ''">
<!--
Example
<NetCoreReference Include="Microsoft.CSharp" />
-->

<!--
Save Microsoft.NETCore.App.Ref assemblies, and remove those from @(Reference)
-->
<ItemGroup>
<_netCoreAppSdkReference Remove="@(_netCoreAppSdkReference)" />
<_netCoreAppSdkReference Include="@(Reference)"
Condition="'%(Reference.NuGetPackageId)'=='Microsoft.NETCore.App.Ref'">
<OriginalPath>%(Reference.Identity)</OriginalPath>
</_netCoreAppSdkReference>

<Reference Remove="@(_netCoreAppSdkReference)" />
</ItemGroup>

<ItemGroup>
<_netCoreAppReferences Remove="@(_netCoreAppReferences)" />
</ItemGroup>
<FilterItem1ByItem2 Item1="@(_netCoreAppSdkReference->'%(FileName)')"
Item2="@(NetCoreReference)"
Metadata2="Identity"
PreserveItem1Metadata="true">
<Output ItemName="_netCoreAppReferences" TaskParameter="Result" />
</FilterItem1ByItem2>

<ItemGroup>
<Reference Include="@(_netCoreAppReferences->'%(OriginalPath)')" />
</ItemGroup>
</Target>

<Target Name="LimitWindowsDesktopAppReferences"
AfterTargets="ResolveTargetingPacks;ResolveTargetingPackAsssets"
Returns="@(Reference)"
Condition="'@(WindowsDesktopReference)'!='' and '@(Reference)' != ''">
<!--
Example
<WindowsDesktopReference Include="PresentationCore" />
-->

<!--
Save Microsoft.WindowsDesktop.App.Ref assemblies, and remove those from @(Reference)
-->
<ItemGroup>
<_windowsDesktopAppSdkReference Remove="@(_windowsDesktopAppSdkReference)" />
<_windowsDesktopAppSdkReference Include="@(Reference)"
Condition="'%(Reference.NuGetPackageId)'=='Microsoft.WindowsDesktop.App.Ref'">
<OriginalPath>%(Reference.Identity)</OriginalPath>
</_windowsDesktopAppSdkReference>

<Reference Remove="@(_windowsDesktopAppSdkReference)" />
</ItemGroup>

<ItemGroup>
<_windowsDesktopAppReferences Remove="@(_windowsDesktopAppReferences)" />
</ItemGroup>
<FilterItem1ByItem2 Item1="@(_windowsDesktopAppSdkReference->'%(FileName)')"
Item2="@(WindowsDesktopReference)"
Metadata2="Identity"
PreserveItem1Metadata="true">
<Output ItemName="_windowsDesktopAppReferences" TaskParameter="Result" />
</FilterItem1ByItem2>

<ItemGroup>
<Reference Include="@(_windowsDesktopAppReferences->'%(OriginalPath)')" />
</ItemGroup>
</Target>

<Target
Name="ResolveMicrosoftDotNetWpfGitHubReferences"
Returns="@(ReferencePath)"
Expand Down Expand Up @@ -210,4 +125,33 @@
</Reference>
</ItemGroup>
</Target>

<ItemGroup>
<!-- We always want to use the local WindowsBase, not the one coming from the .NET runtime. -->
<DefaultReferenceExclusion Include="WindowsBase"/>
</ItemGroup>

<!--
Allows excluding specific .NET runtime libraries from being implicitly referenced.
For example, to exclude WindowsBase from being implicitly referenced, add the following to your project file:

<ItemGroup>
<DefaultReferenceExclusion Include="WindowsBase" />
</ItemGroup>
-->
<Target Name="FilterImplicitAssemblyReferences"
Condition="'@(DefaultReferenceExclusion)' != ''"
DependsOnTargets="ResolveProjectReferences"
AfterTargets="ResolveTargetingPackAssets">
<ItemGroup>
<_referenceExclusion Include="@(DefaultReferenceExclusion)">
<AssemblyName>%(DefaultReferenceExclusion.Identity)</AssemblyName>
<FrameworkReferenceName>Microsoft.NETCore.App</FrameworkReferenceName>
<ExternallyResolved>true</ExternallyResolved>
</_referenceExclusion>

<Reference Remove="@(_referenceExclusion)"
MatchOnMetadata="AssemblyName;FrameworkReferenceName;ExternallyResolved"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you need all of this - I guess you did this so you wouldn't need to intersect DefaultReferenceExclusion with Reference

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried a number of different ways, and this seemed to be the cleanest and easiest to maintain.

</ItemGroup>
</Target>
</Project>
Loading