Skip to content

Commit 5301ddb

Browse files
authored
Package Windows Forms analyzers (#1693)
1 parent 0eb7c98 commit 5301ddb

File tree

4 files changed

+91
-19
lines changed

4 files changed

+91
-19
lines changed

eng/Version.Details.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,17 @@
7373
<Uri>https://github.com/dotnet/runtime</Uri>
7474
<Sha>cf52b7e38d28b7e28358cee052effe0ed47efb2e</Sha>
7575
</Dependency>
76-
<Dependency Name="Microsoft.Private.Winforms" Version="6.0.0-rc.1.21378.3" CoherentParentDependency="Microsoft.DotNet.Wpf.GitHub">
76+
<Dependency Name="Microsoft.Private.Winforms" Version="6.0.0-rc.1.21378.7" CoherentParentDependency="Microsoft.DotNet.Wpf.GitHub">
7777
<Uri>https://github.com/dotnet/winforms</Uri>
78-
<Sha>045879a501a5231a58ca3b3be6689379929f3a24</Sha>
78+
<Sha>b84073df0a41ffd8b6c37881ec19b315f9e1ef56</Sha>
7979
</Dependency>
80-
<Dependency Name="Microsoft.DotNet.Wpf.GitHub" Version="6.0.0-rc.1.21378.4">
80+
<Dependency Name="Microsoft.DotNet.Wpf.GitHub" Version="6.0.0-rc.1.21378.6">
8181
<Uri>https://github.com/dotnet/wpf</Uri>
82-
<Sha>ac1936f34a0d0451af866d93b8c8da0dd2cbf9fc</Sha>
82+
<Sha>ea83fcc3861dddf4d80f605cf994ce84967bf824</Sha>
8383
</Dependency>
84-
<Dependency Name="Microsoft.NET.Sdk.WindowsDesktop" Version="6.0.0-rc.1.21378.4">
84+
<Dependency Name="Microsoft.NET.Sdk.WindowsDesktop" Version="6.0.0-rc.1.21378.6">
8585
<Uri>https://github.com/dotnet/wpf</Uri>
86-
<Sha>ac1936f34a0d0451af866d93b8c8da0dd2cbf9fc</Sha>
86+
<Sha>ea83fcc3861dddf4d80f605cf994ce84967bf824</Sha>
8787
</Dependency>
8888
<Dependency Name="Microsoft.NETCore.App.Ref" Version="6.0.0-rc.1.21378.2" CoherentParentDependency="Microsoft.Private.Winforms">
8989
<Uri>https://github.com/dotnet/runtime</Uri>
@@ -101,13 +101,13 @@
101101
<Uri>https://github.com/dotnet/runtime</Uri>
102102
<Sha>cf52b7e38d28b7e28358cee052effe0ed47efb2e</Sha>
103103
</Dependency>
104-
<Dependency Name="Microsoft.Dotnet.WinForms.ProjectTemplates" Version="6.0.0-rc.1.21378.3" CoherentParentDependency="Microsoft.DotNet.Wpf.GitHub">
104+
<Dependency Name="Microsoft.Dotnet.WinForms.ProjectTemplates" Version="6.0.0-rc.1.21378.7" CoherentParentDependency="Microsoft.DotNet.Wpf.GitHub">
105105
<Uri>https://github.com/dotnet/winforms</Uri>
106-
<Sha>045879a501a5231a58ca3b3be6689379929f3a24</Sha>
106+
<Sha>b84073df0a41ffd8b6c37881ec19b315f9e1ef56</Sha>
107107
</Dependency>
108-
<Dependency Name="Microsoft.DotNet.Wpf.ProjectTemplates" Version="6.0.0-rc.1.21378.4">
108+
<Dependency Name="Microsoft.DotNet.Wpf.ProjectTemplates" Version="6.0.0-rc.1.21378.6">
109109
<Uri>https://github.com/dotnet/wpf</Uri>
110-
<Sha>ac1936f34a0d0451af866d93b8c8da0dd2cbf9fc</Sha>
110+
<Sha>ea83fcc3861dddf4d80f605cf994ce84967bf824</Sha>
111111
</Dependency>
112112
</ProductDependencies>
113113
<ToolsetDependencies>

eng/Versions.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
<NETCoreAppMaximumVersion>6.0</NETCoreAppMaximumVersion>
1919
<NETCoreAppFrameworkVersion>6.0</NETCoreAppFrameworkVersion>
2020
<NETCoreAppFramework>net$(NETCoreAppFrameworkVersion)</NETCoreAppFramework>
21-
<MicrosoftDotnetWinFormsProjectTemplatesVersion>6.0.0-rc.1.21378.3</MicrosoftDotnetWinFormsProjectTemplatesVersion>
22-
<MicrosoftDotNetWpfProjectTemplatesVersion>6.0.0-rc.1.21378.4</MicrosoftDotNetWpfProjectTemplatesVersion>
21+
<MicrosoftDotnetWinFormsProjectTemplatesVersion>6.0.0-rc.1.21378.7</MicrosoftDotnetWinFormsProjectTemplatesVersion>
22+
<MicrosoftDotNetWpfProjectTemplatesVersion>6.0.0-rc.1.21378.6</MicrosoftDotNetWpfProjectTemplatesVersion>
2323
</PropertyGroup>
2424
<!--
2525
Servicing build settings for setup packages. Instructions:
@@ -71,9 +71,9 @@
7171
<SystemThreadingAccessControlVersion>6.0.0-rc.1.21378.2</SystemThreadingAccessControlVersion>
7272
<SystemWindowsExtensionsVersion>6.0.0-rc.1.21378.2</SystemWindowsExtensionsVersion>
7373
<!-- winforms -->
74-
<MicrosoftPrivateWinformsVersion>6.0.0-rc.1.21378.3</MicrosoftPrivateWinformsVersion>
74+
<MicrosoftPrivateWinformsVersion>6.0.0-rc.1.21378.7</MicrosoftPrivateWinformsVersion>
7575
<!-- wpf -->
76-
<MicrosoftDotNetWpfGitHubVersion>6.0.0-rc.1.21378.4</MicrosoftDotNetWpfGitHubVersion>
76+
<MicrosoftDotNetWpfGitHubVersion>6.0.0-rc.1.21378.6</MicrosoftDotNetWpfGitHubVersion>
7777
<!-- Not auto-updated. -->
7878
<MicrosoftBuildVersion>15.7.179</MicrosoftBuildVersion>
7979
<MicrosoftBuildFrameworkVersion>$(MicrosoftBuildVersion)</MicrosoftBuildFrameworkVersion>

pkg/windowsdesktop/sfx/Microsoft.WindowsDesktop.App.Ref.sfxproj

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<Sdk Name="Microsoft.DotNet.SharedFramework.Sdk" />
33
<PropertyGroup>
44
<PlatformPackageType>TargetingPack</PlatformPackageType>
5-
<WindowsFormsClassificationProps>$(PkgMicrosoft_Private_Winforms)\FrameworkListFiles.props</WindowsFormsClassificationProps>
65
<RuntimePackProjectPath>$(MSBuildThisFileDirectory)Microsoft.WindowsDesktop.App.Runtime.sfxproj</RuntimePackProjectPath>
76
<ArchiveName>windowsdesktop-targeting-pack</ArchiveName>
87
<InstallerName>windowsdesktop-targeting-pack</InstallerName>
@@ -11,8 +10,8 @@
1110
</PropertyGroup>
1211

1312
<!--
14-
shared concerns, these shouldn't generally change
15-
for profile information refere to https://github.com/dotnet/cli/issues/10536#issuecomment-488871926
13+
Shared concerns, these shouldn't generally change
14+
For profile information refer to https://github.com/dotnet/cli/issues/10536#issuecomment-488871926
1615
-->
1716
<ItemGroup>
1817
<FrameworkListFileClass Include="Accessibility.dll" Profile="WindowsForms;WPF" />
@@ -36,9 +35,10 @@
3635

3736
<!--
3837
Windows Forms specific references
39-
see: https://github.com/dotnet/winforms/pull/2707/commits/50a5258f7039dc81d99b1c3896a94c578387a3be
38+
see: https://github.com/dotnet/winforms/tree/main/pkg/Microsoft.Private.Winforms/sdk/dotnet-windowsdesktop
4039
-->
41-
<Import Project="$(WindowsFormsClassificationProps)" Condition="Exists('$(WindowsFormsClassificationProps)')" />
40+
<Import Project="$(PkgMicrosoft_Private_Winforms)\sdk\dotnet-windowsdesktop\System.Windows.Forms.FileClassification.props"
41+
Condition="Exists('$(PkgMicrosoft_Private_Winforms)')" />
4242

4343
<!-- WPF specific references -->
4444
<ItemGroup>
@@ -68,4 +68,8 @@
6868
<!-- We don't have a ref assembly for DirectWriteForwarder -->
6969
<IgnoredReference Include="DirectWriteForwarder" />
7070
</ItemGroup>
71+
72+
<!-- Windows Forms validation and packaging -->
73+
<Import Project="WindowsForms.Packaging.targets" />
74+
7175
</Project>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<!--
2+
This props file comes from dotnet/winforms. It gets ingested by dotnet/windowsdesktop and processed by
3+
pkg\windowsdesktop\sfx\Microsoft.WindowsDesktop.App.Ref.sfxproj.
4+
-->
5+
6+
<Project>
7+
8+
<PropertyGroup>
9+
<_WindowsFormsNuGetPath>$(PkgMicrosoft_Private_Winforms)</_WindowsFormsNuGetPath>
10+
</PropertyGroup>
11+
12+
<!--
13+
============================================================
14+
_ValidateWindowsFormsPackagingContent
15+
Validates the content of Microsoft.Private.Winforms NuGet package
16+
to ensure we correctly import and reference props and targets.
17+
============================================================
18+
-->
19+
<Target Name="_ValidateWindowsFormsPackagingContent"
20+
BeforeTargets="PrepareForBuild">
21+
22+
<PropertyGroup>
23+
<_WindowsFormsRequiredFileName>System.Windows.Forms.FileClassification.props</_WindowsFormsRequiredFileName>
24+
</PropertyGroup>
25+
26+
<Error Text="Unable to resolve path to Microsoft.Private.Winforms NuGet package. Is %24(PkgMicrosoft_Private_Winforms) defined?"
27+
Condition="'$(_WindowsFormsNuGetPath)' == ''"/>
28+
29+
<ItemGroup>
30+
<!-- Enumerate all transported files -->
31+
<_WindowsFormsContent Include="$(_WindowsFormsNuGetPath)/sdk/analyzers/**/*.*" />
32+
<_WindowsFormsContent Include="$(_WindowsFormsNuGetPath)/sdk/dotnet-windowsdesktop/*" />
33+
34+
<!-- ...and verify System.Windows.Forms.FileClassification.props is present -->
35+
<_WindowsFormsContentFiles Include="@(_WindowsFormsContent->'%(FileName)%(Extension)')"
36+
Condition=" '%(FileName)%(Extension)' == '$(_WindowsFormsRequiredFileName)' "/>
37+
<!-- ...and analyzers are present too -->
38+
<_WindowsFormsContentFiles Include="@(_WindowsFormsContent->'%(FileName)%(Extension)')"
39+
Condition="$([System.String]::Copy('%(Filename)').Contains('Analyzer', StringComparison.OrdinalIgnoreCase)) "/>
40+
<!-- -->
41+
</ItemGroup>
42+
43+
<!-- Fail if the required files are missing -->
44+
<Error Text="Microsoft.Private.Winforms NuGet package does not contain $(_WindowsFormsRequiredFileName) or analyzers"
45+
Condition="@(_WindowsFormsContentFiles->Count()) &lt; 2"/>
46+
</Target>
47+
48+
49+
<!--
50+
============================================================
51+
_IdentifyWindowsFormsPackageAssets
52+
Add props/targets shipped by Windows Forms to the collection of files that get packaged
53+
in to Microsoft.NET.Sdk.WindowsDesktop.<configuration>.<version>.nupkg.
54+
============================================================
55+
-->
56+
<Target Name="_IdentifyWindowsFormsPackageAssets"
57+
BeforeTargets="_GenerateFrameworkList"
58+
DependsOnTargets="_ValidateWindowsFormsPackagingContent">
59+
60+
<!-- Package our analyzer into the Windows Desktop shipping bundles -->
61+
<ItemGroup>
62+
<WindowsFormsAnalyzers Include="$(PkgMicrosoft_Private_Winforms)/sdk/analyzers/**/*.*" />
63+
<FilesToPackage Include="@(WindowsFormsAnalyzers)" ExcludeFromValidation="true" TargetPath="analyzers/%(RecursiveDir)" />
64+
</ItemGroup>
65+
</Target>
66+
67+
68+
</Project>

0 commit comments

Comments
 (0)