Skip to content

Commit 7db0031

Browse files
Sergio0694Copilot
andcommitted
Fix Windows SDK projection smoke tests after projection target split
PR #2487 split the projection target: the "Windows Metadata not provided or detected" check moved out of CsWinRTGenerateProjection into a new private _CsWinRTComputeProjectionRefGenInputs target, which runs as a dependency of CsWinRTGenerateProjection. MSBuild runs a target's DependsOnTargets before its BeforeTargets hooks, so the smoke tests' _StageWindowsSdkContractsInputs target (BeforeTargets=CsWinRTGenerateProjection) now added the SDK winmds to @(CsWinRTInputs) *after* the check had already run against an empty list and failed. Feed the SDK contract winmds into @(CsWinRTInputs) via a static, evaluation-time ItemGroup instead of a target, matching how every in-repo projection project (src/Projections/*, Projection/Projection.csproj) does it. This makes the inputs independent of how the CsWinRT projection targets are factored. NuGetPackageRoot and the restored winmds are both available at evaluation time (the smoke tests always run a full build, which restores first). The folder-existence diagnostic is kept in a small target anchored to the standard PrepareForBuild target so it stays ordering-independent. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 435af478-1759-4c7e-8176-3b92f72136ec
1 parent 681851d commit 7db0031

1 file changed

Lines changed: 31 additions & 19 deletions

File tree

src/Tests/SmokeTests/WindowsSdkContracts.targets

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,41 @@
2828
</ItemGroup>
2929

3030
<!--
31-
Stage the SDK '.winmd' files as projection inputs before the reference projection generator runs.
32-
The metadata lives in the downloaded package's 'ref/netstandard2.0' folder. We exclude the union
33-
'Windows.winmd' (it would duplicate every contract) and the handful of contracts that the desktop
34-
'Microsoft.Windows.SDK.NET.Ref' package omits (phone/embedded/etc.), matching the official Windows
35-
SDK projection build in 'WinRT.Sdk.Projection.csproj'.
31+
Stage the SDK '.winmd' files as projection inputs. The metadata lives in the downloaded package's
32+
'ref/netstandard2.0' folder. We exclude the union 'Windows.winmd' (it would duplicate every contract)
33+
and the handful of contracts that the desktop 'Microsoft.Windows.SDK.NET.Ref' package omits
34+
(phone/embedded/etc.), matching the official Windows SDK projection build in 'WinRT.Sdk.Projection.csproj'.
35+
36+
These inputs are added statically (at evaluation time), exactly like the in-repo projection projects
37+
feed '@(CsWinRTInputs)' (e.g. 'src/Projections/*/*.csproj' and the sibling 'Projection/Projection.csproj').
38+
Doing it statically instead of from a target keeps the inputs in place regardless of how the CsWinRT
39+
projection targets are factored: the 'Windows Metadata not provided or detected' check now runs in a
40+
private '_CsWinRTComputeProjectionRefGenInputs' target (a dependency of 'CsWinRTGenerateProjection'), so
41+
a 'BeforeTargets="CsWinRTGenerateProjection"' hook would add these inputs *after* that check has already
42+
run and failed. 'NuGetPackageRoot' and the restored '.winmd' files are both available at evaluation time
43+
(the smoke tests always run a full 'dotnet build', which restores first).
3644
-->
37-
<Target Name="_StageWindowsSdkContractsInputs" BeforeTargets="CsWinRTGenerateProjection">
45+
<PropertyGroup>
46+
<_SdkContractsWinMDFolder>$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', '$(_SdkContractsPackageName)', '$(_SdkContractsPackageVersion)', 'ref', 'netstandard2.0'))</_SdkContractsWinMDFolder>
47+
</PropertyGroup>
3848

39-
<PropertyGroup>
40-
<_SdkContractsWinMDFolder>$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', '$(_SdkContractsPackageName)', '$(_SdkContractsPackageVersion)', 'ref', 'netstandard2.0'))</_SdkContractsWinMDFolder>
41-
</PropertyGroup>
49+
<ItemGroup>
50+
<CsWinRTInputs Include="$(_SdkContractsWinMDFolder)*.winmd"
51+
Exclude="$(_SdkContractsWinMDFolder)Windows.winmd;
52+
$(_SdkContractsWinMDFolder)Windows.Embedded.DeviceLockdown.DeviceLockdownContract.winmd;
53+
$(_SdkContractsWinMDFolder)Windows.Networking.NetworkOperators.NetworkOperatorsFdnContract.winmd;
54+
$(_SdkContractsWinMDFolder)Windows.Phone.PhoneContract.winmd;
55+
$(_SdkContractsWinMDFolder)Windows.Phone.StartScreen.DualSimTileContract.winmd;
56+
$(_SdkContractsWinMDFolder)Windows.UI.WebUI.Core.WebUICommandBarContract.winmd" />
57+
</ItemGroup>
4258

59+
<!--
60+
Fail fast with a targeted message if the SDK metadata didn't restore, before the projection generator
61+
reports the generic 'Windows Metadata not provided or detected' error. Anchored to the standard
62+
'PrepareForBuild' target (not a CsWinRT-internal one) so it stays independent of target ordering.
63+
-->
64+
<Target Name="_ValidateWindowsSdkContractsInputs" BeforeTargets="PrepareForBuild">
4365
<Error Condition="!Exists('$(_SdkContractsWinMDFolder)')"
4466
Text="Windows SDK metadata folder not found at '$(_SdkContractsWinMDFolder)'. Check that the PackageDownload for $(_SdkContractsPackageName) $(_SdkContractsPackageVersion) succeeded." />
45-
46-
<ItemGroup>
47-
<CsWinRTInputs Include="$(_SdkContractsWinMDFolder)*.winmd"
48-
Exclude="$(_SdkContractsWinMDFolder)Windows.winmd;
49-
$(_SdkContractsWinMDFolder)Windows.Embedded.DeviceLockdown.DeviceLockdownContract.winmd;
50-
$(_SdkContractsWinMDFolder)Windows.Networking.NetworkOperators.NetworkOperatorsFdnContract.winmd;
51-
$(_SdkContractsWinMDFolder)Windows.Phone.PhoneContract.winmd;
52-
$(_SdkContractsWinMDFolder)Windows.Phone.StartScreen.DualSimTileContract.winmd;
53-
$(_SdkContractsWinMDFolder)Windows.UI.WebUI.Core.WebUICommandBarContract.winmd" />
54-
</ItemGroup>
5567
</Target>
5668
</Project>

0 commit comments

Comments
 (0)