Skip to content

Commit

Permalink
Ingest and import Windows Forms analyzer props
Browse files Browse the repository at this point in the history
Provide a mechanism to ingest Windows Forms specific analyzer props and
targets into Microsoft.NET.Sdk.WindowsDesktop from Windows Forms transport
package, and copy these files into `targets` folder of the SDK, so that
the props files are resolved and imported when a developer builds a Windows
Forms app.

In the end the new props file will end up in a location similar to this:
`C:\Program Files\dotnet\sdk\6.0.<version>\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\`.

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 ae0bc97 commit 443a26e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,30 @@
<PackageDescription>WindowsDesktop SDK</PackageDescription>
</PropertyGroup>

<PropertyGroup>
<_WinFormsNuGetPath>$(PkgMicrosoft_Private_Winforms)</_WinFormsNuGetPath>
<_WinFormsContentPath>$(_WinFormsNuGetPath)\Wpf.Sdk.WindowsDesktop\*</_WinFormsContentPath>
</PropertyGroup>

<ItemGroup>
<PackagingContent Include="Sdk\*" SubFolder="root\Sdk" />
<PackagingContent Include="targets\*" SubFolder="root\targets" />
<PackagingContent Include="useSharedDesignerContext.txt" SubFolder="root" />

<!-- Windows Forms specific -->
<PackagingContent Include="$(_WinFormsContentPath)" SubFolder="root\targets" />
</ItemGroup>

<Target Name="_EnsureWindowsFormsPackagingContent" BeforeTargets="IdentifyPackageAssets">
<Error Text="Unable to resolve path to Microsoft.Private.Winforms NuGet package. Is %24(PkgMicrosoft_Private_Winforms) defined?"
Condition="'$(_WinFormsNuGetPath)' == ''"/>

<ItemGroup>
<_WinFormsContent Include="$(_WinFormsContentPath)" />
</ItemGroup>

<Error Text="Microsoft.Private.Winforms NuGet package contains no content. Is this expected?"
Condition="@(_WinFormsContent->Count()) == 0"/>
</Target>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,7 @@
<ImportFrameworkWinFXTargets Condition="'$(ImportFrameworkWinFXTargets)' == ''">false</ImportFrameworkWinFXTargets>
</PropertyGroup>

<!-- Import Windows Forms specific props -->
<Import Project="System.Windows.Forms.Analyzers.props" />

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,7 @@
<!-- Import WPF Build logic only when we don't import NETFX's WinFX targets -->
<Import Project="Microsoft.WinFX.targets" Condition="'$(ImportFrameworkWinFXTargets)' != 'true'"/>

<!-- Import Windows Forms specific targets -->
<Import Project="System.Windows.Forms.Analyzers.targets" />

</Project>

0 comments on commit 443a26e

Please sign in to comment.