Skip to content

Commit fa62a4c

Browse files
manodasanWSergio0694
authored andcommitted
Fix publishing for AOT (some tests still failing).
1 parent f6c2c0a commit fa62a4c

File tree

5 files changed

+33
-21
lines changed

5 files changed

+33
-21
lines changed

src/Tests/AuthoringConsumptionTest/AuthoringConsumptionTest.vcxproj

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,29 @@
105105
already publishing the project, so we just need to copy the .dll to the output.
106106
-->
107107
<PropertyGroup Condition="'$(Configuration)' == 'Release' and '$(Platform)' == 'x64'">
108-
<PropertyGroup>
109-
<NativeLibraryProjectName>AuthoringTest</NativeLibraryProjectName>
110-
<NativeLibraryProjectDirectory>$(MSBuildThisFileDirectory)..\$(NativeLibraryProjectName)\</NativeLibraryProjectDirectory>
111-
<NativeLibraryProjectFilePath>$(NativeLibraryProjectDirectory)$(NativeLibraryProjectName).csproj</NativeLibraryProjectFilePath>
112-
<NativeLibraryPublishFolder>$(NativeLibraryProjectDirectory)bin\$(Configuration)\net8.0\win-$(Platform)\publish\</NativeLibraryPublishFolder>
113-
<NativeLibraryPublishedDllPath>$(NativeLibraryPublishFolder)$(NativeLibraryProjectName).dll</NativeLibraryPublishedDllPath>
114-
</PropertyGroup>
108+
<NativeLibraryProjectName>AuthoringTest</NativeLibraryProjectName>
109+
<NativeLibraryProjectDirectory>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\$(NativeLibraryProjectName)'))\</NativeLibraryProjectDirectory>
110+
<NativeLibraryProjectFilePath>$(NativeLibraryProjectDirectory)$(NativeLibraryProjectName).csproj</NativeLibraryProjectFilePath>
111+
<NativeLibraryOutputFolder>$(NativeLibraryProjectDirectory)bin\$(Platform)\$(Configuration)\net8.0\</NativeLibraryOutputFolder>
112+
<NativeLibraryDllPath>$(NativeLibraryOutputFolder)$(NativeLibraryProjectName).dll</NativeLibraryDllPath>
113+
<NativeLibraryPublishFolder>$(NativeLibraryProjectDirectory)bin\$(Platform)\$(Configuration)\net8.0\win-$(Platform)\publish\</NativeLibraryPublishFolder>
114+
<NativeLibraryPublishedDllPath>$(NativeLibraryPublishFolder)$(NativeLibraryProjectName).dll</NativeLibraryPublishedDllPath>
115+
</PropertyGroup>
116+
117+
<Target Name="CsWinRTLink" DependsOnTargets="ComputeLinkSwitches" BeforeTargets="Link"
118+
Condition="'$(Configuration)' == 'Release' and '$(Platform)' == 'x64'"
119+
Inputs="$(NativeLibraryDllPath)"
120+
Outputs="@(ReferenceCopyLocalPaths)">
121+
<!-- Publish the managed library with NativeAOT -->
122+
<MSBuild Projects="$(NativeLibraryProjectFilePath)" Targets="Publish" Properties="Configuration=$(Configuration);Platform=$(Platform);RuntimeIdentifier=win-$(Platform);TargetFramework=net8.0" />
115123

116124
<!-- Copy the .dll to our output folder -->
117-
<Copy SourceFiles="$(NativeLibraryPublishedDllPath)" DestinationFolder="$(OutputPath)" />
118-
</PropertyGroup>
125+
<ItemGroup>
126+
<ReferenceCopyLocalPaths Remove="$(NativeLibraryDllPath)"/>
127+
<ReferenceCopyLocalPaths Include="$(NativeLibraryPublishedDllPath)"/>
128+
</ItemGroup>
129+
130+
</Target>
119131

120132
<ItemGroup>
121133
<Reference Include="AuthoringTest">

src/Tests/AuthoringTest/AuthoringTest.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<!-- CsWinRTEnableLogging helps to diagnose generation issues -->
99
<!-- <CsWinRTEnableLogging>true</CsWinRTEnableLogging> -->
1010
<!--<CsWinRTKeepGeneratedSources>true</CsWinRTKeepGeneratedSources>-->
11+
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
1112
</PropertyGroup>
1213

1314
<ItemGroup>
@@ -28,6 +29,7 @@
2829
<ProjectReference Include="..\..\Projections\Windows\Windows.csproj" />
2930
<ProjectReference Include="..\..\Projections\WinAppSDK\WinAppSDK.csproj" />
3031
<ProjectReference Include="..\..\Authoring\WinRT.SourceGenerator\WinRT.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
32+
3133
<ProjectReference Include="..\..\cswinrt\cswinrt.vcxproj" />
3234
<ProjectReference Include="..\..\WinRT.Runtime\WinRT.Runtime.csproj" />
3335
</ItemGroup>

src/Tests/AuthoringTest/Directory.Build.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<PropertyGroup Condition="'$(Configuration)' == 'Release' and '$(Platform)' == 'x64'">
1616
<IsAotCompatible>true</IsAotCompatible>
1717
<PublishAot>true</PublishAot>
18+
<NativeLib>Shared</NativeLib>
19+
<SelfContained>true</SelfContained>
1820
</PropertyGroup>
1921

2022
</Project>

src/build.cmd

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ call :exec %nuget_dir%\nuget.exe restore %nuget_params% %this_dir%cswinrt.sln
165165
rem: Calling nuget restore again on ObjectLifetimeTests.Lifted.csproj to prevent .props from \microsoft.testplatform.testhost\build\netcoreapp2.1 from being included. Nuget.exe erroneously imports props files. https://github.com/NuGet/Home/issues/9672
166166
call :exec %msbuild_path%msbuild.exe %this_dir%\Tests\ObjectLifetimeTests\ObjectLifetimeTests.Lifted.csproj /t:restore /p:platform=%cswinrt_platform%;configuration=%cswinrt_configuration%
167167

168+
if "%cswinrt_platform%" EQU "x64" (
169+
if /I "%cswinrt_configuration%" EQU "release" (
170+
rem We restore here as NAOT needs its own restore to pull in ILC
171+
call :exec %msbuild_path%msbuild.exe %this_dir%\Tests\AuthoringTest\AuthoringTest.csproj /t:restore /p:platform=%cswinrt_platform%;configuration=%cswinrt_configuration%;RuntimeIdentifier=win-%cswinrt_platform%
172+
)
173+
)
174+
168175
:build
169176
echo Building cswinrt for %cswinrt_platform% %cswinrt_configuration%
170177
call :exec %msbuild_path%msbuild.exe %cswinrt_build_params% /p:platform=%cswinrt_platform%;configuration=%cswinrt_configuration%;VersionNumber=%cswinrt_version_number%;VersionString=%cswinrt_version_string%;AssemblyVersionNumber=%cswinrt_assembly_version%;GenerateTestProjection=true;BaselineAllAPICompatError=%cswinrt_baseline_breaking_compat_errors%;BaselineAllMatchingRefApiCompatError=%cswinrt_baseline_assembly_version_compat_errors% %this_dir%cswinrt.sln
@@ -207,14 +214,6 @@ if "%cswinrt_platform%" EQU "x64" (
207214
)
208215
)
209216

210-
if "%cswinrt_platform%" EQU "x64" (
211-
if /I "%cswinrt_configuration%" EQU "release" (
212-
echo Publishing AOT authoring tests for %cswinrt_platform% %cswinrt_configuration%
213-
rem We also restore here as NAOT needs its own restore to pull in ILC
214-
call :exec %msbuild_path%msbuild.exe /restore -t:publish %cswinrt_build_params% /p:platform=%cswinrt_platform%;configuration=%cswinrt_configuration%;RuntimeIdentifier=win-%cswinrt_platform%;VersionNumber=%cswinrt_version_number%;VersionString=%cswinrt_version_string%;AssemblyVersionNumber=%cswinrt_assembly_version%;GenerateTestProjection=true;BaselineAllAPICompatError=%cswinrt_baseline_breaking_compat_errors%;BaselineAllMatchingRefApiCompatError=%cswinrt_baseline_assembly_version_compat_errors% /p:solutiondir=%this_dir% %this_dir%Tests\AuthoringTest\AuthoringTest.csproj
215-
)
216-
)
217-
218217
if "%cswinrt_build_only%"=="true" goto :eof
219218

220219
:buildembedded

src/cswinrt.sln

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestComponentCSharp", "Test
99
EndProject
1010
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTest", "Tests\UnitTest\UnitTest.csproj", "{9A9F52CA-F624-43A4-B5EF-C50861F584C2}"
1111
ProjectSection(ProjectDependencies) = postProject
12-
{AE3B0611-2FBB-42AB-A245-B4E79868A5F9} = {AE3B0611-2FBB-42AB-A245-B4E79868A5F9}
1312
{25244CED-966E-45F2-9711-1F51E951FF89} = {25244CED-966E-45F2-9711-1F51E951FF89}
13+
{AE3B0611-2FBB-42AB-A245-B4E79868A5F9} = {AE3B0611-2FBB-42AB-A245-B4E79868A5F9}
1414
EndProjectSection
1515
EndProject
1616
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cswinrt", "cswinrt\cswinrt.vcxproj", "{6ACFD2B2-E8AA-4CD4-AAD8-213CE8BB2637}"
17-
ProjectSection(ProjectDependencies) = postProject
18-
{25244CED-966E-45F2-9711-1F51E951FF89} = {25244CED-966E-45F2-9711-1F51E951FF89}
19-
EndProjectSection
2017
EndProject
2118
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Files", "Files", "{96495AB4-2D86-47D1-A174-27D0B436DC98}"
2219
ProjectSection(SolutionItems) = preProject

0 commit comments

Comments
 (0)