Skip to content

Commit 8ec21fd

Browse files
committed
Package analyzers
1 parent 93e774e commit 8ec21fd

File tree

7 files changed

+97
-22
lines changed

7 files changed

+97
-22
lines changed

eng/packageContent.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<PropertyGroup Condition="'$(PackagePath)' == ''">
1414
<PackagePath>lib/$(TargetFramework)</PackagePath>
1515
<PackagePath Condition="'$(IsFacadeAssembly)' == 'true'">lib/$(TargetFramework);$(RefPackagePath)</PackagePath>
16+
<PackagePath Condition="'$(IsAnalyzerAssembly)' == 'true'">$(RefPackagePath)</PackagePath>
1617
</PropertyGroup>
1718

1819
<PropertyGroup>
@@ -39,7 +40,7 @@
3940
This means we build a real assembly that has no associated official intellisense docs.
4041
Contact the intellisense team for guidance.
4142
-->
42-
<Error Condition="!Exists('$(IntellisenseXmlFileSource)') and '$(IsFacadeAssembly)' != 'true'"
43+
<Error Condition="!Exists('$(IntellisenseXmlFileSource)') and '$(IsFacadeAssembly)' != 'true' and '$(IsAnalyzerAssembly)' != 'true'"
4344
Text="$(AssemblyName).xml not found in dotnet-api-docs package. Contact the intellisense team about adding the docs for this assembly."
4445
/>
4546

pkg/Microsoft.Private.Winforms/Directory.Build.targets

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,28 @@
44

55
<PropertyGroup>
66
<_PowerShellExe Condition="'$(_PowerShellExe)' == ''">C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</_PowerShellExe>
7-
<_ScriptLocation Condition="'$(_ScriptLocation)' == ''">$(MSBuildProjectDirectory)\ProcessFrameworkListFiles.ps1</_ScriptLocation>
8-
<_ManifestFile>$(MSBuildProjectDirectory)\FrameworkListFiles.props</_ManifestFile>
7+
<_ScriptLocation Condition="'$(_ScriptLocation)' == ''">$(MSBuildProjectDirectory)\WindowsDesktop.App.Ref\UpdateManifest.ps1</_ScriptLocation>
8+
<_ManifestFile>$(MSBuildProjectDirectory)\WindowsDesktop.App.Ref\System.Windows.Forms.Analyzers.props</_ManifestFile>
99
<GenerateManifest>false</GenerateManifest>
1010
</PropertyGroup>
1111

1212
<!--
1313
(Re)generate the list of transport assemblies by inspecting Microsoft.Private.Winforms nuspec.
1414
-->
15-
<Target Name="UpdateTransportPackage"
15+
<Target Name="UpdateTransportPackage"
1616
AfterTargets="GenerateNuspec"
1717
DependsOnTargets="GenerateNuspec">
1818
<ItemGroup>
1919
<_NuspecFile Include="@(NuGetPackOutput)" Condition="'%(Extension)' == '.nuspec'" />
2020
</ItemGroup>
2121

22+
<Error Text="'$(_ScriptLocation)' is missing." Condition="!Exists('$(_ScriptLocation)')" />
23+
<Error Text="'$(_ManifestFile)' is missing." Condition="!Exists('$(_ManifestFile)')" />
24+
2225
<Exec
2326
Command="$(_PowerShellExe) -NonInteractive -ExecutionPolicy Unrestricted -Command &quot;&amp; { &amp;&apos;$(_ScriptLocation)&apos; &apos;@(_NuspecFile)&apos; &apos;$(_ManifestFile)&apos; $(GenerateManifest) } &quot;"
2427
ContinueOnError="False" />
25-
28+
2629
</Target>
2730

2831
</Project>

pkg/Microsoft.Private.Winforms/Microsoft.Private.Winforms.csproj

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,44 +53,59 @@
5353
</ItemDefinitionGroup>
5454

5555
<ItemGroup>
56-
<None Include="FrameworkListFiles.props">
56+
<None Include="..\..\src\System.Windows.Forms.Analyzers\src\System.Windows.Forms.Analyzers.props" Link="Wpf.Sdk.WindowsDesktop\System.Windows.Forms.Analyzers.props">
5757
<Pack>True</Pack>
58-
<PackagePath></PackagePath>
58+
<PackagePath>Wpf.Sdk.WindowsDesktop</PackagePath>
59+
</None>
60+
<None Include="..\..\src\System.Windows.Forms.Analyzers\src\System.Windows.Forms.Analyzers.targets" Link="Wpf.Sdk.WindowsDesktop\System.Windows.Forms.Analyzers.targets">
61+
<Pack>True</Pack>
62+
<PackagePath>Wpf.Sdk.WindowsDesktop</PackagePath>
63+
</None>
64+
<None Include="WindowsDesktop.App.Ref\*" Exclude="WindowsDesktop.App.Ref\*.ps1">
65+
<Pack>True</Pack>
66+
<PackagePath>WindowsDesktop.App.Ref</PackagePath>
5967
</None>
6068
</ItemGroup>
6169

6270
<!-- Any projects referenced here will have their outputs automatically put into the package -->
6371
<!-- If you add a new csproj, and you want the outputs in the package, you must add it here -->
6472
<ItemGroup>
65-
<!-- Facade for System.Drawing include -->
73+
<!-- Facade for System.Drawing -->
6674
<ProjectReference Include="..\..\src\System.Drawing\src\System.Drawing.Facade.csproj" />
6775

68-
<!-- Facade for System.Design include -->
76+
<!-- Facade for System.Design -->
6977
<ProjectReference Include="..\..\src\System.Design\src\System.Design.Facade.csproj" />
7078

71-
<!-- Facade for System.Drawing.Design include -->
79+
<!-- Facade for System.Drawing.Design -->
7280
<ProjectReference Include="..\..\src\System.Drawing.Design\src\System.Drawing.Design.Facade.csproj" />
7381

74-
<!-- Reference and Source System.Windows.Forms includes -->
82+
<!-- Reference and Source System.Windows.Forms -->
7583
<ProjectReference Include="..\..\src\System.Windows.Forms\src\System.Windows.Forms.csproj" />
7684

77-
<!-- Reference and Source System.Windows.Forms.Primitives includes -->
85+
<!-- Reference and Source System.Windows.Forms.Primitives -->
7886
<ProjectReference Include="..\..\src\System.Windows.Forms.Primitives\src\System.Windows.Forms.Primitives.csproj" />
7987

80-
<!-- Reference and Source System.Windows.Forms.Design includes -->
88+
<!-- Reference and Source System.Windows.Forms.Design -->
8189
<ProjectReference Include="..\..\src\System.Windows.Forms.Design\src\System.Windows.Forms.Design.csproj" />
8290

83-
<!-- Facade for System.Windows.Forms.Design.Editors includes -->
91+
<!-- Facade for System.Windows.Forms.Design.Editors -->
8492
<ProjectReference Include="..\..\src\System.Windows.Forms.Design.Editors\src\System.Windows.Forms.Design.Editors.Facade3x.csproj" />
8593

86-
<!-- Facade for Microsoft.VisualBasic include -->
94+
<!-- Facade for Microsoft.VisualBasic -->
8795
<ProjectReference Include="..\..\src\Microsoft.VisualBasic\src\Microsoft.VisualBasic.Facade.csproj" />
8896

89-
<!-- Reference and Source Microsoft.VisualBasic.Forms includes -->
97+
<!-- Reference and Source Microsoft.VisualBasic.Forms -->
9098
<ProjectReference Include="..\..\src\Microsoft.VisualBasic.Forms\src\Microsoft.VisualBasic.Forms.vbproj" />
9199

92100
<ProjectReference Include="..\..\src\Accessibility\src\Accessibility.ilproj" />
93101

102+
<!--
103+
Analyzer System.Windows.Forms.Analyzers
104+
Please note that analyzers aren't recorded into FrameworkListFiles.props
105+
-->
106+
<ProjectReference Include="..\..\src\System.Windows.Forms.Analyzers\src\System.Windows.Forms.Analyzers.csproj" />
107+
<ProjectReference Include="..\..\src\System.Windows.Forms.Analyzers.CSharp\src\System.Windows.Forms.Analyzers.CSharp.csproj" />
108+
94109
</ItemGroup>
95110

96111
<!-- Force the output item type for all project references to "TfmSpecificPackageFile", which makes them get packed -->

pkg/Microsoft.Private.Winforms/README.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,53 @@
22

33
This is a transport package consumed by [WPF](https://github.com/dotnet/wpf/) and [WindowsDesktop](https://github.com/dotnet/windowsdesktop/).
44

5-
WindowsDesktop relies on [`FrameworkListFiles.props` manifest](FrameworkListFiles.props) to list all our assemblies that form "WindowsForms" SDK[&#x00B9;](#ref1).
6-
The props file is then imported by [WindowsDesktop projects](https://github.com/dotnet/windowsdesktop/blob/master/pkg/windowsdesktop/pkg/Directory.Build.props).
75

6+
## WindowsDesktop.App.Ref folder
7+
8+
This folder contains props and targets used to ingest our assemblies into the [Windows Desktop SDK](https://github.com/dotnet/windowsdesktop/) for purpose of bundling of our analyzers into Microsoft.WindowsDesktop.App.Ref pack.
9+
10+
* [`System.Windows.Forms.Analyzers.props`](WindowsDesktop.App.Ref\System.Windows.Forms.Analyzers.props) contains a manifest for the "WindowsForms" SDK[&#x00B9;](#ref1), i.e. a list of our assemblies that form it.
11+
The file is imported by [Microsoft.WindowsDesktop.App.Ref project](https://github.com/dotnet/windowsdesktop/blob/main/pkg/windowsdesktop/sfx/Microsoft.WindowsDesktop.App.Ref.sfxproj).<br/>
812
The manifest will need to be rebuilt if there are changes in the solution with respect to the SDK assemblies, e.g. a new assembly is added or an existing assembly is removed.
913

10-
## How it works
14+
* [`System.Windows.Forms.Analyzers.targets`](WindowsDesktop.App.Ref\System.Windows.Forms.Analyzers.targets) contains targets that help packaging our analyzers into the Microsoft.WindowsDesktop.App.Ref pack. The file is imported by [Microsoft.WindowsDesktop.App.Ref project](https://github.com/dotnet/windowsdesktop/blob/main/pkg/windowsdesktop/sfx/Microsoft.WindowsDesktop.App.Ref.sfxproj).
15+
1116

12-
[`FrameworkListFiles.props`](FrameworkListFiles.props) will be compared against the list of assemblies in `Microsoft.Private.Winforms.[version].nuspec`[&#x00B2;](#ref2) generated as part of the `pack` command.
17+
18+
### How to update System.Windows.Forms.Analyzers.props
19+
20+
The existing `System.Windows.Forms.Analyzers.props` is be compared against the list of assemblies in `Microsoft.Private.Winforms.[version].nuspec`[&#x00B2;](#ref2) generated as part of the `pack` command.
1321

1422
If the content of these files differ - the build will fail.
1523

1624
:warning: The process is purposefully made manual to ensure changes in the manifest are made consciously.
1725

18-
## How to update the manifest
26+
To update the manifest
1927

2028
* Build the solution as normal:
2129
```
2230
.\build.cmd
2331
```
24-
* To update the manifest [`FrameworkListFiles.props`](FrameworkListFiles.props) run the following command from a developer prompt:
32+
* To update the manifest [`System.Windows.Forms.Analyzers.props`](System.Windows.Forms.Analyzers.props) run the following command from a developer prompt:
2533
```
2634
msbuild .\pkg\Microsoft.Private.Winforms\Microsoft.Private.Winforms.csproj /t:UpdateTransportPackage /p:GenerateManifest=true /v:m
2735
```
2836
37+
## Wpf.Sdk.WindowsDesktop folder
38+
39+
This folder contains props for our analyzers and targets that reference our analyzers into a consumer Windows Forms application.
40+
41+
* [`System.Windows.Forms.Analyzers.props`](Wpf.Sdk.WindowsDesktop\System.Windows.Forms.Analyzers.props) contains the list of properties required by our source generators.
42+
43+
* [`System.Windows.Forms.Analyzers.targets`](Wpf.Sdk.WindowsDesktop\System.Windows.Forms.Analyzers.targets) contains targets that reference our analyzers into comsumer projects.
44+
45+
These files are ingested by the WPF via [Microsoft.NET.Sdk.WindowsDesktop project](https://github.com/dotnet/wpf/blob/main/packaging/Microsoft.NET.Sdk.WindowsDesktop/Microsoft.NET.Sdk.WindowsDesktop.ArchNeutral.csproj). When this project is being built, it copies the files from our transport NuGet package to a Microsoft.NET.Sdk.WindowsDesktop bundle, and thus facilitates the seamless refernce of our analyzers by Windows Forms apps.
46+
47+
2948
3049
50+
<br/>
51+
<br/>
3152
3253
----
3354

pkg/Microsoft.Private.Winforms/FrameworkListFiles.props renamed to pkg/Microsoft.Private.Winforms/WindowsDesktop.App.Ref/System.Windows.Forms.Analyzers.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
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+
17
<Project>
28
<ItemGroup Condition="'$(PackageTargetRuntime)' == ''">
39
<FrameworkListFileClass Include="Microsoft.VisualBasic.dll" Profile="WindowsForms" />
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
7+
<Project>
8+
9+
<Target Name="_SetWindowsFormsAnalyzersNuspecTargetPaths" BeforeTargets="GenerateNuspec">
10+
<Error Text="Unable to resolve path to Microsoft.Private.Winforms NuGet package. Is %24(PkgMicrosoft_Private_Winforms) defined?"
11+
Condition="'$(PkgMicrosoft_Private_Winforms)' == ''"/>
12+
13+
<ItemGroup>
14+
<_WinFormsAnalyzers Include="$(PkgMicrosoft_Private_Winforms)\ref\netstandard2.0\*" />
15+
</ItemGroup>
16+
17+
<Error Text="Microsoft.Private.Winforms NuGet package contains no analyzers. Is this expected?"
18+
Condition="@(_WinFormsAnalyzers->Count()) == 0"/>
19+
20+
<ItemGroup>
21+
<_PackageFiles Include="@(_WinFormsAnalyzers)">
22+
<GeneratedBuildFile>true</GeneratedBuildFile>
23+
<PackagePath>ref/$(MicrosoftNETBuildTasksTFM)/</PackagePath>
24+
<TargetPath>ref/$(MicrosoftNETBuildTasksTFM)/</TargetPath>
25+
</_PackageFiles>
26+
</ItemGroup>
27+
</Target>
28+
29+
</Project>

pkg/Microsoft.Private.Winforms/ProcessFrameworkListFiles.ps1 renamed to pkg/Microsoft.Private.Winforms/WindowsDesktop.App.Ref/UpdateManifest.ps1

File renamed without changes.

0 commit comments

Comments
 (0)