Skip to content

Package Windows Forms analyzers #1693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>cf52b7e38d28b7e28358cee052effe0ed47efb2e</Sha>
</Dependency>
<Dependency Name="Microsoft.Private.Winforms" Version="6.0.0-rc.1.21378.3" CoherentParentDependency="Microsoft.DotNet.Wpf.GitHub">
<Dependency Name="Microsoft.Private.Winforms" Version="6.0.0-rc.1.21378.7" CoherentParentDependency="Microsoft.DotNet.Wpf.GitHub">
<Uri>https://github.com/dotnet/winforms</Uri>
<Sha>045879a501a5231a58ca3b3be6689379929f3a24</Sha>
<Sha>b84073df0a41ffd8b6c37881ec19b315f9e1ef56</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Wpf.GitHub" Version="6.0.0-rc.1.21378.4">
<Dependency Name="Microsoft.DotNet.Wpf.GitHub" Version="6.0.0-rc.1.21378.6">
<Uri>https://github.com/dotnet/wpf</Uri>
<Sha>ac1936f34a0d0451af866d93b8c8da0dd2cbf9fc</Sha>
<Sha>ea83fcc3861dddf4d80f605cf994ce84967bf824</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Sdk.WindowsDesktop" Version="6.0.0-rc.1.21378.4">
<Dependency Name="Microsoft.NET.Sdk.WindowsDesktop" Version="6.0.0-rc.1.21378.6">
<Uri>https://github.com/dotnet/wpf</Uri>
<Sha>ac1936f34a0d0451af866d93b8c8da0dd2cbf9fc</Sha>
<Sha>ea83fcc3861dddf4d80f605cf994ce84967bf824</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Ref" Version="6.0.0-rc.1.21378.2" CoherentParentDependency="Microsoft.Private.Winforms">
<Uri>https://github.com/dotnet/runtime</Uri>
Expand All @@ -101,13 +101,13 @@
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>cf52b7e38d28b7e28358cee052effe0ed47efb2e</Sha>
</Dependency>
<Dependency Name="Microsoft.Dotnet.WinForms.ProjectTemplates" Version="6.0.0-rc.1.21378.3" CoherentParentDependency="Microsoft.DotNet.Wpf.GitHub">
<Dependency Name="Microsoft.Dotnet.WinForms.ProjectTemplates" Version="6.0.0-rc.1.21378.7" CoherentParentDependency="Microsoft.DotNet.Wpf.GitHub">
<Uri>https://github.com/dotnet/winforms</Uri>
<Sha>045879a501a5231a58ca3b3be6689379929f3a24</Sha>
<Sha>b84073df0a41ffd8b6c37881ec19b315f9e1ef56</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Wpf.ProjectTemplates" Version="6.0.0-rc.1.21378.4">
<Dependency Name="Microsoft.DotNet.Wpf.ProjectTemplates" Version="6.0.0-rc.1.21378.6">
<Uri>https://github.com/dotnet/wpf</Uri>
<Sha>ac1936f34a0d0451af866d93b8c8da0dd2cbf9fc</Sha>
<Sha>ea83fcc3861dddf4d80f605cf994ce84967bf824</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
8 changes: 4 additions & 4 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<NETCoreAppMaximumVersion>6.0</NETCoreAppMaximumVersion>
<NETCoreAppFrameworkVersion>6.0</NETCoreAppFrameworkVersion>
<NETCoreAppFramework>net$(NETCoreAppFrameworkVersion)</NETCoreAppFramework>
<MicrosoftDotnetWinFormsProjectTemplatesVersion>6.0.0-rc.1.21378.3</MicrosoftDotnetWinFormsProjectTemplatesVersion>
<MicrosoftDotNetWpfProjectTemplatesVersion>6.0.0-rc.1.21378.4</MicrosoftDotNetWpfProjectTemplatesVersion>
<MicrosoftDotnetWinFormsProjectTemplatesVersion>6.0.0-rc.1.21378.7</MicrosoftDotnetWinFormsProjectTemplatesVersion>
<MicrosoftDotNetWpfProjectTemplatesVersion>6.0.0-rc.1.21378.6</MicrosoftDotNetWpfProjectTemplatesVersion>
</PropertyGroup>
<!--
Servicing build settings for setup packages. Instructions:
Expand Down Expand Up @@ -71,9 +71,9 @@
<SystemThreadingAccessControlVersion>6.0.0-rc.1.21378.2</SystemThreadingAccessControlVersion>
<SystemWindowsExtensionsVersion>6.0.0-rc.1.21378.2</SystemWindowsExtensionsVersion>
<!-- winforms -->
<MicrosoftPrivateWinformsVersion>6.0.0-rc.1.21378.3</MicrosoftPrivateWinformsVersion>
<MicrosoftPrivateWinformsVersion>6.0.0-rc.1.21378.7</MicrosoftPrivateWinformsVersion>
<!-- wpf -->
<MicrosoftDotNetWpfGitHubVersion>6.0.0-rc.1.21378.4</MicrosoftDotNetWpfGitHubVersion>
<MicrosoftDotNetWpfGitHubVersion>6.0.0-rc.1.21378.6</MicrosoftDotNetWpfGitHubVersion>
<!-- Not auto-updated. -->
<MicrosoftBuildVersion>15.7.179</MicrosoftBuildVersion>
<MicrosoftBuildFrameworkVersion>$(MicrosoftBuildVersion)</MicrosoftBuildFrameworkVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Sdk Name="Microsoft.DotNet.SharedFramework.Sdk" />
<PropertyGroup>
<PlatformPackageType>TargetingPack</PlatformPackageType>
<WindowsFormsClassificationProps>$(PkgMicrosoft_Private_Winforms)\FrameworkListFiles.props</WindowsFormsClassificationProps>
<RuntimePackProjectPath>$(MSBuildThisFileDirectory)Microsoft.WindowsDesktop.App.Runtime.sfxproj</RuntimePackProjectPath>
<ArchiveName>windowsdesktop-targeting-pack</ArchiveName>
<InstallerName>windowsdesktop-targeting-pack</InstallerName>
Expand All @@ -11,8 +10,8 @@
</PropertyGroup>

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

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

<!-- WPF specific references -->
<ItemGroup>
Expand Down Expand Up @@ -68,4 +68,8 @@
<!-- We don't have a ref assembly for DirectWriteForwarder -->
<IgnoredReference Include="DirectWriteForwarder" />
</ItemGroup>

<!-- Windows Forms validation and packaging -->
<Import Project="WindowsForms.Packaging.targets" />

</Project>
68 changes: 68 additions & 0 deletions pkg/windowsdesktop/sfx/WindowsForms.Packaging.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<!--
This props file comes from dotnet/winforms. It gets ingested by dotnet/windowsdesktop and processed by
pkg\windowsdesktop\sfx\Microsoft.WindowsDesktop.App.Ref.sfxproj.
-->

<Project>

<PropertyGroup>
<_WindowsFormsNuGetPath>$(PkgMicrosoft_Private_Winforms)</_WindowsFormsNuGetPath>
</PropertyGroup>

<!--
============================================================
_ValidateWindowsFormsPackagingContent
Validates the content of Microsoft.Private.Winforms NuGet package
to ensure we correctly import and reference props and targets.
============================================================
-->
<Target Name="_ValidateWindowsFormsPackagingContent"
BeforeTargets="PrepareForBuild">

<PropertyGroup>
<_WindowsFormsRequiredFileName>System.Windows.Forms.FileClassification.props</_WindowsFormsRequiredFileName>
</PropertyGroup>

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

<ItemGroup>
<!-- Enumerate all transported files -->
<_WindowsFormsContent Include="$(_WindowsFormsNuGetPath)/sdk/analyzers/**/*.*" />
<_WindowsFormsContent Include="$(_WindowsFormsNuGetPath)/sdk/dotnet-windowsdesktop/*" />

<!-- ...and verify System.Windows.Forms.FileClassification.props is present -->
<_WindowsFormsContentFiles Include="@(_WindowsFormsContent->'%(FileName)%(Extension)')"
Condition=" '%(FileName)%(Extension)' == '$(_WindowsFormsRequiredFileName)' "/>
<!-- ...and analyzers are present too -->
<_WindowsFormsContentFiles Include="@(_WindowsFormsContent->'%(FileName)%(Extension)')"
Condition="$([System.String]::Copy('%(Filename)').Contains('Analyzer', StringComparison.OrdinalIgnoreCase)) "/>
<!-- -->
</ItemGroup>

<!-- Fail if the required files are missing -->
<Error Text="Microsoft.Private.Winforms NuGet package does not contain $(_WindowsFormsRequiredFileName) or analyzers"
Condition="@(_WindowsFormsContentFiles->Count()) &lt; 2"/>
</Target>


<!--
============================================================
_IdentifyWindowsFormsPackageAssets
Add props/targets shipped by Windows Forms to the collection of files that get packaged
in to Microsoft.NET.Sdk.WindowsDesktop.<configuration>.<version>.nupkg.
============================================================
-->
<Target Name="_IdentifyWindowsFormsPackageAssets"
BeforeTargets="_GenerateFrameworkList"
DependsOnTargets="_ValidateWindowsFormsPackagingContent">

<!-- Package our analyzer into the Windows Desktop shipping bundles -->
<ItemGroup>
<WindowsFormsAnalyzers Include="$(PkgMicrosoft_Private_Winforms)/sdk/analyzers/**/*.*" />
<FilesToPackage Include="@(WindowsFormsAnalyzers)" ExcludeFromValidation="true" TargetPath="analyzers/%(RecursiveDir)" />
</ItemGroup>
</Target>


</Project>