Skip to content
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

Allow dropping native host for NativeAOT WinRT components #1395

Merged
merged 72 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
270f2a4
Add property/logic to generate WinRT native exports
Sergio0694 Nov 22, 2023
af87b27
Make CsWinRTAotExportsEnabled compiler visible
Sergio0694 Nov 22, 2023
3b4401e
Automatically set CsWinRTAotExportsEnabled if needed
Sergio0694 Nov 22, 2023
6354f4a
Update authoring targets for NativeAOT scenario
Sergio0694 Nov 22, 2023
ed6bb9f
Refactor items in authoring .targets for clarity
Sergio0694 Nov 23, 2023
6ae4341
Fix two typos in generated native exports
Sergio0694 Nov 23, 2023
5596f81
Return REGDB_E_CLASSNOTREG for class not registered
Sergio0694 Nov 25, 2023
282c652
Enable testing authoring scenario with NativeAOT
Sergio0694 Nov 25, 2023
19ef41f
Return CLASS_E_CLASSNOTAVAILABLE instead
Sergio0694 Nov 25, 2023
b43a60e
Update WinRT.Host.runtimeconfig.json for .NET 8
Sergio0694 Nov 25, 2023
26979d9
Update .NET 8 SDK to 8.0.100 stable
Sergio0694 Nov 25, 2023
987db7c
Update AuthoringConsumptionTest.vcxproj
Sergio0694 Nov 25, 2023
dc3f311
Skip native host copy target for NAOT
Sergio0694 Nov 25, 2023
d887b4a
Fix AuthoringTest .NET TFM in AuthoringWinUITest projects
Sergio0694 Nov 27, 2023
38098bf
Update unit test for class not registered
Sergio0694 Nov 28, 2023
a6c49f0
Update CsWinRTExeTFM for .NET 7 and .NET 8
Sergio0694 Nov 30, 2023
c4180b2
Handle .NET 8 in generator
Sergio0694 Dec 1, 2023
d0225f7
Fix version causing debug build failures
manodasanW Dec 2, 2023
c2ac695
Add target to publish AuthoringTest from consuming test
Sergio0694 Dec 2, 2023
92451c8
Publish AuthoringTest with NAOT in build.cmd
Sergio0694 Dec 3, 2023
67dc5c2
Fix publishing for AOT (some tests still failing).
manodasanW Dec 20, 2023
f561450
Merge pull request #1422 from microsoft/staging/AOT
manodasanW Dec 23, 2023
55aa7da
Fix gaps found from AuthoringTest being built for AOT
manodasanW Dec 26, 2023
2d1709b
Add property/logic to generate WinRT native exports
Sergio0694 Nov 22, 2023
1ce610b
Make CsWinRTAotExportsEnabled compiler visible
Sergio0694 Nov 22, 2023
bce52e6
Automatically set CsWinRTAotExportsEnabled if needed
Sergio0694 Nov 22, 2023
6b20fef
Update authoring targets for NativeAOT scenario
Sergio0694 Nov 22, 2023
14a1d82
Refactor items in authoring .targets for clarity
Sergio0694 Nov 23, 2023
ea1a82e
Fix two typos in generated native exports
Sergio0694 Nov 23, 2023
22456bd
Return REGDB_E_CLASSNOTREG for class not registered
Sergio0694 Nov 25, 2023
98b79a7
Enable testing authoring scenario with NativeAOT
Sergio0694 Nov 25, 2023
0afd56e
Return CLASS_E_CLASSNOTAVAILABLE instead
Sergio0694 Nov 25, 2023
b381692
Update WinRT.Host.runtimeconfig.json for .NET 8
Sergio0694 Nov 25, 2023
e2d9173
Update .NET 8 SDK to 8.0.100 stable
Sergio0694 Nov 25, 2023
f7faec2
Update AuthoringConsumptionTest.vcxproj
Sergio0694 Nov 25, 2023
4498c02
Skip native host copy target for NAOT
Sergio0694 Nov 25, 2023
6703c83
Fix AuthoringTest .NET TFM in AuthoringWinUITest projects
Sergio0694 Nov 27, 2023
dce62a0
Update unit test for class not registered
Sergio0694 Nov 28, 2023
8843654
Update CsWinRTExeTFM for .NET 7 and .NET 8
Sergio0694 Nov 30, 2023
c407c76
Handle .NET 8 in generator
Sergio0694 Dec 1, 2023
2db4e9d
Fix version causing debug build failures
manodasanW Dec 2, 2023
62a2fdd
Add target to publish AuthoringTest from consuming test
Sergio0694 Dec 2, 2023
f6c2c0a
Publish AuthoringTest with NAOT in build.cmd
Sergio0694 Dec 3, 2023
fa62a4c
Fix publishing for AOT (some tests still failing).
manodasanW Dec 20, 2023
535fdf2
Fix issue with IID optimizer for certain scenarios and fix missing vt…
manodasanW Jan 8, 2024
2410694
Merge branch 'user/sergiopedri/naot-winrt-exports' into manodasanw/na…
manodasanW Jan 8, 2024
d57f6a6
Fix bug where generics in class names caused issues
manodasanW Jan 8, 2024
c8be139
Add property/logic to generate WinRT native exports
Sergio0694 Nov 22, 2023
6afe330
Make CsWinRTAotExportsEnabled compiler visible
Sergio0694 Nov 22, 2023
167af6c
Automatically set CsWinRTAotExportsEnabled if needed
Sergio0694 Nov 22, 2023
e51ace7
Update authoring targets for NativeAOT scenario
Sergio0694 Nov 22, 2023
c459580
Refactor items in authoring .targets for clarity
Sergio0694 Nov 23, 2023
b7ddbb3
Fix two typos in generated native exports
Sergio0694 Nov 23, 2023
c880161
Return REGDB_E_CLASSNOTREG for class not registered
Sergio0694 Nov 25, 2023
e6aa352
Enable testing authoring scenario with NativeAOT
Sergio0694 Nov 25, 2023
be2df6b
Return CLASS_E_CLASSNOTAVAILABLE instead
Sergio0694 Nov 25, 2023
3a7ba56
Update WinRT.Host.runtimeconfig.json for .NET 8
Sergio0694 Nov 25, 2023
c57d1a4
Update .NET 8 SDK to 8.0.100 stable
Sergio0694 Nov 25, 2023
786a513
Update AuthoringConsumptionTest.vcxproj
Sergio0694 Nov 25, 2023
57391f7
Skip native host copy target for NAOT
Sergio0694 Nov 25, 2023
10cae72
Fix AuthoringTest .NET TFM in AuthoringWinUITest projects
Sergio0694 Nov 27, 2023
a51bcae
Update unit test for class not registered
Sergio0694 Nov 28, 2023
4239ec7
Update CsWinRTExeTFM for .NET 7 and .NET 8
Sergio0694 Nov 30, 2023
29d3bbf
Handle .NET 8 in generator
Sergio0694 Dec 1, 2023
4ded797
Fix version causing debug build failures
manodasanW Dec 2, 2023
2521a0b
Add target to publish AuthoringTest from consuming test
Sergio0694 Dec 2, 2023
00fc51b
Publish AuthoringTest with NAOT in build.cmd
Sergio0694 Dec 3, 2023
f02bf33
Fix publishing for AOT (some tests still failing).
manodasanW Dec 20, 2023
f2a0c6b
Merge branch 'user/sergiopedri/naot-winrt-exports' into manodasanw/na…
manodasanW Jan 9, 2024
2453f07
Address PR feedback
manodasanW Jan 9, 2024
9fea72b
Merge pull request #1432 from microsoft/manodasanw/naot-winrt-exports…
manodasanW Jan 9, 2024
3253e5d
PR feedback from other PR
manodasanW Jan 9, 2024
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
79 changes: 48 additions & 31 deletions nuget/Microsoft.Windows.CsWinRT.Authoring.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Copyright (C) Microsoft Corporation. All rights reserved.

<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- Generate a RuntimeConfig -->
<EnableDynamicLoading>true</EnableDynamicLoading>
<!-- Generate a RuntimeConfig (only for the managed, hosted scenario) -->
<EnableDynamicLoading Condition="'$(CsWinRTAotExportsEnabled)' != 'true'">true</EnableDynamicLoading>
<!-- Name the RuntimeConfig properly -->
<ProjectRuntimeConfigFileName>WinRT.Host.runtimeconfig.json</ProjectRuntimeConfigFileName>
<ProjectRuntimeConfigFileName Condition="'$(CsWinRTAotExportsEnabled)' != 'true'">WinRT.Host.runtimeconfig.json</ProjectRuntimeConfigFileName>
<CsWinRTDetectDependentAuthoringWinMDs Condition="'$(CsWinRTDetectDependentAuthoringWinMDs)'==''">true</CsWinRTDetectDependentAuthoringWinMDs>
<GetCopyToOutputDirectoryItemsDependsOn>$(GetCopyToOutputDirectoryItemsDependsOn);CsWinRTAuthoring_AddManagedDependencies</GetCopyToOutputDirectoryItemsDependsOn>
</PropertyGroup>
Expand Down Expand Up @@ -55,8 +55,11 @@ Copyright (C) Microsoft Corporation. All rights reserved.

</Target>

<!-- For Project Reference consumers, copy the necessary WinRT DLLs to output directory -->
<ItemGroup>
<!--
For Project Reference consumers, copy the necessary WinRT DLLs to output directory.
Only include these if we are not generating native exports for NativeAOT.
-->
<ItemGroup Condition="'$(CsWinRTAotExportsEnabled)' != 'true'">

<None Condition="Exists('$(CsWinRTPath)lib\net6.0\WinRT.Host.Shim.dll')" Include="$(CsWinRTPath)lib\net6.0\WinRT.Host.Shim.dll">
<TargetPath>WinRT.Host.Shim.dll</TargetPath>
Expand All @@ -77,13 +80,16 @@ Copyright (C) Microsoft Corporation. All rights reserved.

</ItemGroup>

<!-- Any managed dependencies of the WinRT component won't automatically be brought
in by a referencing C++ app, so we manually set them to be copied here -->
<!--
Any managed dependencies of the WinRT component won't automatically be brought
in by a referencing C++ app, so we manually set them to be copied here. Only
needed when not using NativeAOT (as there's no additional managed .dll-s there).
-->
<Target Name="CsWinRTAuthoring_AddManagedDependencies"
BeforeTargets="GetCopyToOutputDirectoryItems"
Returns="@(AllItemsFullPathWithTargetPath)">

<ItemGroup>
<ItemGroup Condition="'$(CsWinRTAotExportsEnabled)' != 'true'">

<!-- Make sure all managed binaries/projections are shared across project references made by native apps -->
<AllItemsFullPathWithTargetPath Include="@(ReferenceCopyLocalPaths)"
Expand All @@ -101,7 +107,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
AfterTargets="GenerateBuildRuntimeConfigurationFiles"
BeforeTargets="GetCopyToOutputDirectoryItems;_GetCopyToOutputDirectoryItemsFromThisProject">

<ItemGroup>
<ItemGroup Condition="'$(CsWinRTAotExportsEnabled)' != 'true'">

<AllItemsFullPathWithTargetPath Include="$(ProjectRuntimeConfigFilePath)">
<TargetPath>$([System.IO.Path]::GetFileName($(ProjectRuntimeConfigFilePath)))</TargetPath>
Expand Down Expand Up @@ -148,8 +154,9 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<TargetPathWithTargetPlatformMoniker Remove="@(TargetPathWithTargetPlatformMoniker)" />
<!-- Add the .winmd -->
<TargetPathWithTargetPlatformMoniker Include="$(TargetDir)$(AssemblyName).winmd">
<!-- implementation is NOT $(AssemblyName).dll -->
<Implementation>WinRT.Host.dll</Implementation>
<!-- implementation is NOT $(AssemblyName).dll (unless NativeAOT publishing is used) -->
<Implementation Condition="'$(CsWinRTAotExportsEnabled)' != 'true'">WinRT.Host.dll</Implementation>
<Implementation Condition="'$(CsWinRTAotExportsEnabled)' == 'true'">$(AssemblyName).dll</Implementation>
<!-- show to c++ compiler (native case) and dotnet sdk (managed case) -->
<ResolveableAssembly>true</ResolveableAssembly>
<!-- Used by the dotnet sdk -->
Expand Down Expand Up @@ -250,10 +257,38 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<!-- When an authored component makes a nupkg, add the necessary hosting assets to the package -->
<Target Name="CsWinRTIncludeHostDlls" DependsOnTargets="CsWinRTGenerateTransitiveTargets" BeforeTargets="AfterBuild" Outputs="@(Content)">

<!-- When packing, include all necessary DLLs and the targets file for DLL copying on the native side -->
<!--
Include all assets that are shared across all configurations.
For instance, the .winmd file is always needed.
-->
<ItemGroup>

<Content Include="$(CsWinRTPath)lib\net6.0\WinRT.Host.Shim.dll">
<!-- Pack any XAML resource PRI files next to the .winmd -->
<Content Include="$(ProjectPriFullPath)">
<Pack>true</Pack>
<PackagePath>lib\$(TargetFramework)\winmd</PackagePath>
</Content>

<!-- Pack the WinMD we generated in its own folder, under the managed TFM folder -->
<Content Include="$(TargetDir)$(AssemblyName).winmd">
<Pack>true</Pack>
<PackagePath>lib\$(TargetFramework)\winmd</PackagePath>
</Content>

<!-- Use a targets file generated for the component -->
<Content Include="$(AuthoringTransitiveTargets)">
<Pack>true</Pack>
<PackagePath>buildTransitive\$(AssemblyName).targets;build\$(AssemblyName).targets</PackagePath>
</Content>
</ItemGroup>

<!--
Include all necessary DLLs and the targets file for DLL copying on the native side.
These additional assets are only used when the WinRT component is a managed assembly.
-->
<ItemGroup Condition="'$(CsWinRTAotExportsEnabled)' != 'true'">

<Content Include="$(CsWinRTPath)lib\net6.0\WinRT.Host.Shim.dll">
<Pack>true</Pack>
<PackagePath>lib\$(TargetFramework)</PackagePath>
</Content>
Expand Down Expand Up @@ -281,24 +316,6 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<PackagePath>lib\$(TargetFramework)</PackagePath>
</Content>

<!-- Pack any XAML resource PRI files next to the .winmd -->
<Content Include="$(ProjectPriFullPath)">
<Pack>true</Pack>
<PackagePath>lib\$(TargetFramework)\winmd</PackagePath>
</Content>

<!-- Pack the WinMD we generated in its own folder, under the managed TFM folder -->
<Content Include="$(TargetDir)$(AssemblyName).winmd">
<Pack>true</Pack>
<PackagePath>lib\$(TargetFramework)\winmd</PackagePath>
</Content>

<!-- Use a targets file generated for the component -->
<Content Include="$(AuthoringTransitiveTargets)">
<Pack>true</Pack>
<PackagePath>buildTransitive\$(AssemblyName).targets;build\$(AssemblyName).targets</PackagePath>
</Content>

<!-- We package a version of WinRT.Host.dll for each possible architecture -->
<Content Condition="Exists('$(CsWinRTPath)hosting\x64\native\WinRT.Host.dll')" Include="$(CsWinRTPath)hosting\x64\native\WinRT.Host.dll">
<Pack>true</Pack>
Expand Down
12 changes: 11 additions & 1 deletion nuget/Microsoft.Windows.CsWinRT.targets
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<TrackFileAccess Condition="'$(CsWinRTComponent)' != 'true'">false</TrackFileAccess>
<CsWinRTAotOptimizerEnabled Condition="'$(CsWinRTAotOptimizerEnabled)' == '' and $([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) >= 6">true</CsWinRTAotOptimizerEnabled>
<CsWinRTAotOptimizerEnabled Condition="'$(CsWinRTAotOptimizerEnabled)' != 'true'">false</CsWinRTAotOptimizerEnabled>

<!--
If the AOT optimizer is enabled, and we're publishing with NativeAOT, automatically set CsWinRTAotExportsEnabled as well.
Only do this if the property is not already set by the user, so we respect any existing preference.
-->
<CsWinRTAotExportsEnabled Condition="'$(CsWinRTAotExportsEnabled)' == '' and '$(CsWinRTAotOptimizerEnabled)' == 'true' and '$(PublishAot)' == 'true'">true</CsWinRTAotExportsEnabled>
<CsWinRTAotExportsEnabled Condition="'$(CsWinRTAotExportsEnabled)' != 'true'">false</CsWinRTAotExportsEnabled>
</PropertyGroup>

<ItemGroup>
<CompilerVisibleProperty Include="CsWinRTAotOptimizerEnabled" />
<CompilerVisibleProperty Include="CsWinRTAotExportsEnabled" />
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)Microsoft.Windows.CsWinRT.Embedded.targets" Condition="'$(CsWinRTEmbedded)' == 'true'"/>
Expand Down Expand Up @@ -152,7 +160,9 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<CsWinRTEmbeddedProjection Condition="'$(CsWinRTEmbedded)' == 'true'">-embedded</CsWinRTEmbeddedProjection>
<CsWinRTEmbeddedEnums Condition="'$(CsWinRTEmbeddedPublicEnums)' == 'true'">-public_enums</CsWinRTEmbeddedEnums>
<CsWinRTExeTFM Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) == 5">net5.0</CsWinRTExeTFM>
<CsWinRTExeTFM Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) > 5">net6.0</CsWinRTExeTFM>
<CsWinRTExeTFM Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) == 6">net6.0</CsWinRTExeTFM>
<CsWinRTExeTFM Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) == 7">net7.0</CsWinRTExeTFM>
<CsWinRTExeTFM Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) >= 8">net8.0</CsWinRTExeTFM>
<CsWinRTExeTFM Condition="'$(CsWinRTExeTFM)' == ''">netstandard2.0</CsWinRTExeTFM>

<CsWinRTParams Condition="'$(CsWinRTParams)' == ''">
Expand Down
Loading