|
| 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()) < 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