Skip to content

Commit

Permalink
Package Windows Forms analyzers
Browse files Browse the repository at this point in the history
Provide a mechanism to import Windows Forms specific analyzers from
Windows Forms transport package, and and package those into
Microsoft.WindowsDesktop.App.Ref bundle, so that they are available in
Windows Forms app out of the box.

The analyzers are referenced via props and targets located in
`C:\Program Files\dotnet\sdk\6.0.<version>\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\`,
which is facilitated by dotnet/wpf#4605.

This work relates to dotnet/designs#223, and acts
as a workaround until dotnet/designs#181 is
approved and implemented.
  • Loading branch information
RussKie committed Jun 2, 2021
1 parent 8449682 commit ca1d451
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pkg/windowsdesktop/sfx/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
and it was removed in .NET 5.
-->
<IgnoredReference Include="System.Runtime.InteropServices.WindowsRuntime" />

<IgnoredReference Include="Microsoft.CodeAnalysis" />
</ItemGroup>

<Target Name="ReturnProductVersion" Returns="$(Version)" />
Expand Down
11 changes: 9 additions & 2 deletions pkg/windowsdesktop/sfx/Microsoft.WindowsDesktop.App.Ref.sfxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
<Sdk Name="Microsoft.DotNet.SharedFramework.Sdk" />
<PropertyGroup>
<PlatformPackageType>TargetingPack</PlatformPackageType>
<WindowsFormsClassificationProps>$(PkgMicrosoft_Private_Winforms)\FrameworkListFiles.props</WindowsFormsClassificationProps>
<RuntimePackProjectPath>$(MSBuildThisFileDirectory)Microsoft.WindowsDesktop.App.Runtime.sfxproj</RuntimePackProjectPath>
<ArchiveName>windowsdesktop-targeting-pack</ArchiveName>
<InstallerName>windowsdesktop-targeting-pack</InstallerName>
<InstallerRuntimeIdentifiers>win-x64;win-x86;win-arm64</InstallerRuntimeIdentifiers>
<VSInsertionShortComponentName>WindowsDesktop.TargetingPack</VSInsertionShortComponentName>

<_WinFormsContentPath>$(PkgMicrosoft_Private_Winforms)\WindowsDesktop.App.Ref</_WinFormsContentPath>
<_WindowsFormsContentProps>$(_WinFormsContentPath)\System.Windows.Forms.Analyzers.props</_WindowsFormsContentProps>
<_WindowsFormsContentTargets>$(_WinFormsContentPath)\System.Windows.Forms.Analyzers.targets</_WindowsFormsContentTargets>
</PropertyGroup>

<!--
Expand Down Expand Up @@ -43,7 +46,7 @@
Windows Forms specific references
see: https://github.com/dotnet/winforms/pull/2707/commits/50a5258f7039dc81d99b1c3896a94c578387a3be
-->
<Import Project="$(WindowsFormsClassificationProps)" Condition="Exists('$(WindowsFormsClassificationProps)')" />
<Import Project="$(_WindowsFormsContentProps)" Condition="Exists('$(_WindowsFormsContentProps)')" />

<!-- WPF specific references -->
<ItemGroup>
Expand Down Expand Up @@ -73,4 +76,8 @@
<!-- We don't have a ref assembly for DirectWriteForwarder -->
<IgnoredReference Include="DirectWriteForwarder" />
</ItemGroup>

<!-- Import Windows Forms specific targets -->
<Import Project="$(_WindowsFormsContentTargets)" Condition="Exists('$(_WindowsFormsContentTargets)')" />

</Project>

0 comments on commit ca1d451

Please sign in to comment.