Skip to content

Commit

Permalink
Fix publishing for AOT (some tests still failing).
Browse files Browse the repository at this point in the history
  • Loading branch information
manodasanW authored and Sergio0694 committed Jan 3, 2024
1 parent f6c2c0a commit fa62a4c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,29 @@
already publishing the project, so we just need to copy the .dll to the output.
-->
<PropertyGroup Condition="'$(Configuration)' == 'Release' and '$(Platform)' == 'x64'">
<PropertyGroup>
<NativeLibraryProjectName>AuthoringTest</NativeLibraryProjectName>
<NativeLibraryProjectDirectory>$(MSBuildThisFileDirectory)..\$(NativeLibraryProjectName)\</NativeLibraryProjectDirectory>
<NativeLibraryProjectFilePath>$(NativeLibraryProjectDirectory)$(NativeLibraryProjectName).csproj</NativeLibraryProjectFilePath>
<NativeLibraryPublishFolder>$(NativeLibraryProjectDirectory)bin\$(Configuration)\net8.0\win-$(Platform)\publish\</NativeLibraryPublishFolder>
<NativeLibraryPublishedDllPath>$(NativeLibraryPublishFolder)$(NativeLibraryProjectName).dll</NativeLibraryPublishedDllPath>
</PropertyGroup>
<NativeLibraryProjectName>AuthoringTest</NativeLibraryProjectName>
<NativeLibraryProjectDirectory>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\$(NativeLibraryProjectName)'))\</NativeLibraryProjectDirectory>
<NativeLibraryProjectFilePath>$(NativeLibraryProjectDirectory)$(NativeLibraryProjectName).csproj</NativeLibraryProjectFilePath>
<NativeLibraryOutputFolder>$(NativeLibraryProjectDirectory)bin\$(Platform)\$(Configuration)\net8.0\</NativeLibraryOutputFolder>
<NativeLibraryDllPath>$(NativeLibraryOutputFolder)$(NativeLibraryProjectName).dll</NativeLibraryDllPath>
<NativeLibraryPublishFolder>$(NativeLibraryProjectDirectory)bin\$(Platform)\$(Configuration)\net8.0\win-$(Platform)\publish\</NativeLibraryPublishFolder>
<NativeLibraryPublishedDllPath>$(NativeLibraryPublishFolder)$(NativeLibraryProjectName).dll</NativeLibraryPublishedDllPath>
</PropertyGroup>

<Target Name="CsWinRTLink" DependsOnTargets="ComputeLinkSwitches" BeforeTargets="Link"
Condition="'$(Configuration)' == 'Release' and '$(Platform)' == 'x64'"
Inputs="$(NativeLibraryDllPath)"
Outputs="@(ReferenceCopyLocalPaths)">
<!-- Publish the managed library with NativeAOT -->
<MSBuild Projects="$(NativeLibraryProjectFilePath)" Targets="Publish" Properties="Configuration=$(Configuration);Platform=$(Platform);RuntimeIdentifier=win-$(Platform);TargetFramework=net8.0" />

<!-- Copy the .dll to our output folder -->
<Copy SourceFiles="$(NativeLibraryPublishedDllPath)" DestinationFolder="$(OutputPath)" />
</PropertyGroup>
<ItemGroup>
<ReferenceCopyLocalPaths Remove="$(NativeLibraryDllPath)"/>
<ReferenceCopyLocalPaths Include="$(NativeLibraryPublishedDllPath)"/>
</ItemGroup>

</Target>

<ItemGroup>
<Reference Include="AuthoringTest">
Expand Down
2 changes: 2 additions & 0 deletions src/Tests/AuthoringTest/AuthoringTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<!-- CsWinRTEnableLogging helps to diagnose generation issues -->
<!-- <CsWinRTEnableLogging>true</CsWinRTEnableLogging> -->
<!--<CsWinRTKeepGeneratedSources>true</CsWinRTKeepGeneratedSources>-->
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
</PropertyGroup>

<ItemGroup>
Expand All @@ -28,6 +29,7 @@
<ProjectReference Include="..\..\Projections\Windows\Windows.csproj" />
<ProjectReference Include="..\..\Projections\WinAppSDK\WinAppSDK.csproj" />
<ProjectReference Include="..\..\Authoring\WinRT.SourceGenerator\WinRT.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />

<ProjectReference Include="..\..\cswinrt\cswinrt.vcxproj" />
<ProjectReference Include="..\..\WinRT.Runtime\WinRT.Runtime.csproj" />
</ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/Tests/AuthoringTest/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<PropertyGroup Condition="'$(Configuration)' == 'Release' and '$(Platform)' == 'x64'">
<IsAotCompatible>true</IsAotCompatible>
<PublishAot>true</PublishAot>
<NativeLib>Shared</NativeLib>
<SelfContained>true</SelfContained>
</PropertyGroup>

</Project>
15 changes: 7 additions & 8 deletions src/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ call :exec %nuget_dir%\nuget.exe restore %nuget_params% %this_dir%cswinrt.sln
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
call :exec %msbuild_path%msbuild.exe %this_dir%\Tests\ObjectLifetimeTests\ObjectLifetimeTests.Lifted.csproj /t:restore /p:platform=%cswinrt_platform%;configuration=%cswinrt_configuration%

if "%cswinrt_platform%" EQU "x64" (
if /I "%cswinrt_configuration%" EQU "release" (
rem We restore here as NAOT needs its own restore to pull in ILC
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%
)
)

:build
echo Building cswinrt for %cswinrt_platform% %cswinrt_configuration%
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
Expand Down Expand Up @@ -207,14 +214,6 @@ if "%cswinrt_platform%" EQU "x64" (
)
)

if "%cswinrt_platform%" EQU "x64" (
if /I "%cswinrt_configuration%" EQU "release" (
echo Publishing AOT authoring tests for %cswinrt_platform% %cswinrt_configuration%
rem We also restore here as NAOT needs its own restore to pull in ILC
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
)
)

if "%cswinrt_build_only%"=="true" goto :eof

:buildembedded
Expand Down
5 changes: 1 addition & 4 deletions src/cswinrt.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestComponentCSharp", "Test
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTest", "Tests\UnitTest\UnitTest.csproj", "{9A9F52CA-F624-43A4-B5EF-C50861F584C2}"
ProjectSection(ProjectDependencies) = postProject
{AE3B0611-2FBB-42AB-A245-B4E79868A5F9} = {AE3B0611-2FBB-42AB-A245-B4E79868A5F9}
{25244CED-966E-45F2-9711-1F51E951FF89} = {25244CED-966E-45F2-9711-1F51E951FF89}
{AE3B0611-2FBB-42AB-A245-B4E79868A5F9} = {AE3B0611-2FBB-42AB-A245-B4E79868A5F9}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cswinrt", "cswinrt\cswinrt.vcxproj", "{6ACFD2B2-E8AA-4CD4-AAD8-213CE8BB2637}"
ProjectSection(ProjectDependencies) = postProject
{25244CED-966E-45F2-9711-1F51E951FF89} = {25244CED-966E-45F2-9711-1F51E951FF89}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Files", "Files", "{96495AB4-2D86-47D1-A174-27D0B436DC98}"
ProjectSection(SolutionItems) = preProject
Expand Down

0 comments on commit fa62a4c

Please sign in to comment.