Skip to content

Commit 443a26e

Browse files
committed
Ingest and import Windows Forms analyzer props
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.
1 parent ae0bc97 commit 443a26e

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

packaging/Microsoft.NET.Sdk.WindowsDesktop/Microsoft.NET.Sdk.WindowsDesktop.ArchNeutral.csproj

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,30 @@
2020
<PackageDescription>WindowsDesktop SDK</PackageDescription>
2121
</PropertyGroup>
2222

23+
<PropertyGroup>
24+
<_WinFormsNuGetPath>$(PkgMicrosoft_Private_Winforms)</_WinFormsNuGetPath>
25+
<_WinFormsContentPath>$(_WinFormsNuGetPath)\Wpf.Sdk.WindowsDesktop\*</_WinFormsContentPath>
26+
</PropertyGroup>
27+
2328
<ItemGroup>
2429
<PackagingContent Include="Sdk\*" SubFolder="root\Sdk" />
2530
<PackagingContent Include="targets\*" SubFolder="root\targets" />
2631
<PackagingContent Include="useSharedDesignerContext.txt" SubFolder="root" />
32+
33+
<!-- Windows Forms specific -->
34+
<PackagingContent Include="$(_WinFormsContentPath)" SubFolder="root\targets" />
2735
</ItemGroup>
36+
37+
<Target Name="_EnsureWindowsFormsPackagingContent" BeforeTargets="IdentifyPackageAssets">
38+
<Error Text="Unable to resolve path to Microsoft.Private.Winforms NuGet package. Is %24(PkgMicrosoft_Private_Winforms) defined?"
39+
Condition="'$(_WinFormsNuGetPath)' == ''"/>
40+
41+
<ItemGroup>
42+
<_WinFormsContent Include="$(_WinFormsContentPath)" />
43+
</ItemGroup>
44+
45+
<Error Text="Microsoft.Private.Winforms NuGet package contains no content. Is this expected?"
46+
Condition="@(_WinFormsContent->Count()) == 0"/>
47+
</Target>
48+
2849
</Project>

packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,7 @@
171171
<ImportFrameworkWinFXTargets Condition="'$(ImportFrameworkWinFXTargets)' == ''">false</ImportFrameworkWinFXTargets>
172172
</PropertyGroup>
173173

174+
<!-- Import Windows Forms specific props -->
175+
<Import Project="System.Windows.Forms.Analyzers.props" />
176+
174177
</Project>

packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.targets

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,7 @@
155155
<!-- Import WPF Build logic only when we don't import NETFX's WinFX targets -->
156156
<Import Project="Microsoft.WinFX.targets" Condition="'$(ImportFrameworkWinFXTargets)' != 'true'"/>
157157

158+
<!-- Import Windows Forms specific targets -->
159+
<Import Project="System.Windows.Forms.Analyzers.targets" />
160+
158161
</Project>

0 commit comments

Comments
 (0)