|
| 1 | +<Project> |
| 2 | + |
| 3 | + <PropertyGroup> |
| 4 | + <_WindowsFormsNuGetPath>$(PkgMicrosoft_Private_Winforms)</_WindowsFormsNuGetPath> |
| 5 | + </PropertyGroup> |
| 6 | + |
| 7 | + <!-- |
| 8 | + ============================================================ |
| 9 | + _ValidateWindowsFormsPackagingContent |
| 10 | + Validates the content of Microsoft.Private.Winforms NuGet package |
| 11 | + to ensure we correctly import and reference props and targets. |
| 12 | + ============================================================ |
| 13 | + --> |
| 14 | + <Target Name="_ValidateWindowsFormsPackagingContent"> |
| 15 | + <PropertyGroup> |
| 16 | + <_WindowsFormsContentPath>$(_WindowsFormsNuGetPath)\sdk\dotnet-wpf\*</_WindowsFormsContentPath> |
| 17 | + <_WindowsFormsRequiredFileName>Microsoft.NET.SDk.WindowsDesktop.WindowsForms</_WindowsFormsRequiredFileName> |
| 18 | + </PropertyGroup> |
| 19 | + |
| 20 | + <Error Text="Unable to resolve path to Microsoft.Private.Winforms NuGet package. Is %24(PkgMicrosoft_Private_Winforms) defined?" |
| 21 | + Condition="'$(_WindowsFormsNuGetPath)' == ''"/> |
| 22 | + |
| 23 | + <ItemGroup> |
| 24 | + <!-- Enumerate all transported files --> |
| 25 | + <_WindowsFormsContent Include="$(_WindowsFormsContentPath)" /> |
| 26 | + <!-- ...and verify Microsoft.NET.SDk.WindowsDesktop.WindowsForms.props/.targets are present --> |
| 27 | + <_WindowsFormsContentFiles Include="@(_WindowsFormsContent->'%(FileName)%(Extension)')" |
| 28 | + Condition=" '%(FileName)%(Extension)' == '$(_WindowsFormsRequiredFileName).props' |
| 29 | + or '%(FileName)%(Extension)' == '$(_WindowsFormsRequiredFileName).targets' "/> |
| 30 | + </ItemGroup> |
| 31 | + |
| 32 | + <!-- Fail if the required files are missing --> |
| 33 | + <Error Text="Microsoft.Private.Winforms NuGet package does not contain $(_WindowsFormsRequiredFileName).props or $(_WindowsFormsRequiredFileName).targets" |
| 34 | + Condition="@(_WindowsFormsContentFiles->Count()) != 2"/> |
| 35 | + </Target> |
| 36 | + |
| 37 | + |
| 38 | + <!-- |
| 39 | + ============================================================ |
| 40 | + _IdentifyWindowsFormsPackageAssets |
| 41 | + Add props/targets shipped by Windows Forms to the collection of files that get packaged |
| 42 | + in to Microsoft.NET.Sdk.WindowsDesktop.<configuration>.<version>.nupkg. |
| 43 | + ============================================================ |
| 44 | + --> |
| 45 | + <Target Name="_IdentifyWindowsFormsPackageAssets" BeforeTargets="IdentifyPackageAssets" DependsOnTargets="_ValidateWindowsFormsPackagingContent"> |
| 46 | + <ItemGroup> |
| 47 | + <PackagingContent Include="$(_WindowsFormsContentPath)" SubFolder="root\targets" /> |
| 48 | + </ItemGroup> |
| 49 | + </Target> |
| 50 | + |
| 51 | +</Project> |
0 commit comments