Skip to content

Commit fa0d1f6

Browse files
committed
Import System.Windows.Forms global usings
Enables dotnet/winforms#5183 Relates to dotnet/sdk#18459
1 parent ab1e156 commit fa0d1f6

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

eng/WindowsForms.targets

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project>
2+
3+
<!--
4+
This target *only* validates the content of Microsoft.Private.Winforms NuGet package
5+
to ensure we correctly import and reference props and targets.
6+
-->
7+
<Target Name="_EnsureWindowsFormsPackagingContent" BeforeTargets="IdentifyPackageAssets">
8+
<Error Text="Unable to resolve path to Microsoft.Private.Winforms NuGet package. Is %24(PkgMicrosoft_Private_Winforms) defined?"
9+
Condition="'$(_WinFormsNuGetPath)' == ''"/>
10+
11+
<ItemGroup>
12+
<_WinFormsContent Include="$(_WinFormsContentPath)" />
13+
</ItemGroup>
14+
15+
<Error Text="Microsoft.Private.Winforms NuGet package contains no content. Is this expected?"
16+
Condition="@(_WinFormsContent->Count()) == 0"/>
17+
</Target>
18+
19+
</Project>

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
34
<ProjectGuid>{440d06b8-e3de-4c0d-ad25-cd4f43d836e1}</ProjectGuid>
45
<TargetFramework>net6.0</TargetFramework>
@@ -25,4 +26,18 @@
2526
<PackagingContent Include="targets\*" SubFolder="root\targets" />
2627
<PackagingContent Include="useSharedDesignerContext.txt" SubFolder="root" />
2728
</ItemGroup>
29+
30+
<!-- Windows Forms specific -->
31+
<Import Project="$(RepositoryEngineeringDir)WindowsForms.targets" />
32+
33+
<PropertyGroup>
34+
<!-- These properties are used by _EnsureWindowsFormsPackagingContent target -->
35+
<_WinFormsNuGetPath>$(PkgMicrosoft_Private_Winforms)</_WinFormsNuGetPath>
36+
<_WinFormsContentPath>$(_WinFormsNuGetPath)\sdk\dotnet-wpf\*</_WinFormsContentPath>
37+
</PropertyGroup>
38+
39+
<ItemGroup>
40+
<PackagingContent Include="$(_WinFormsContentPath)" SubFolder="root\targets" />
41+
</ItemGroup>
42+
2843
</Project>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,6 @@
161161
<SupportedTargetFramework Remove="@(_UnsupportedNETCoreAppTargetFramework);@(_UnsupportedNETStandardTargetFramework);@(_UnsupportedNETFrameworkTargetFramework)" />
162162
</ItemGroup>
163163

164+
<Import Project="System.Windows.Forms.GlobalUsings.props" />
165+
164166
</Project>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,6 @@
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 Project="System.Windows.Forms.GlobalUsings.targets" />
159+
158160
</Project>

0 commit comments

Comments
 (0)