Skip to content

Commit

Permalink
fix(windows): fix run-windows not launching apps built with New Arch
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 committed Sep 24, 2024
1 parent 52d14ec commit ce14e1e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
27 changes: 27 additions & 0 deletions windows/Win32/ReactApp.Package.wapproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
</PropertyGroup>
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.WindowsSdk.Default.props" />
<PropertyGroup>
<!--
`AppxManifest.xml` is output relative to the `.wapproj` file and
`run-windows` cannot find it because it expects `.wapproj` to be in the
same directory as the solution. We need to change the output directory so
that `run-windows` can find the file.
Note that we don't use `OutDir` because the project name is always
appended to it, e.g. `x64/Debug/ReactApp.Package`.
-->
<BaseOutputPath>$([MSBuild]::MakeRelative($(MSBuildThisFileDirectory), $(SolutionDir)))\$(MSBuildProjectName)\bin\</BaseOutputPath>
<OutputPath>$(BaseOutputPath)\$(Platform)\$(Configuration)\</OutputPath>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
</PropertyGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
Expand Down Expand Up @@ -88,4 +99,20 @@
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.props')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.props'))" />
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.targets'))" />
</Target>
<Target Name="CopyAppPackagesToOutputDirectory" AfterTargets="_GenerateAppxPackage">
<!--
`AppPackages` is output relative to the `.wapproj` file and `run-windows`
cannot find it because it expects `.wapproj` to be in the same directory
as the solution. We need to copy the files to the output directory so that
`run-windows` can find them.
-->
<ItemGroup>
<AppPackagesFiles Include="$(MSBuildThisFileDirectory)\AppPackages\**\*.*"/>
</ItemGroup>
<Copy
SourceFiles="@(AppPackagesFiles)"
DestinationFolder="$(BaseOutputPath)\..\AppPackages\%(RecursiveDir)"
UseSymbolicLinksIfPossible="true"
/>
</Target>
</Project>
5 changes: 4 additions & 1 deletion windows/Win32/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#include <unknwn.h>

// WinRT Header Files
// clang-format off
#include <winrt/base.h>
// clang-format on

#include <CppWinRTIncludes.h>

#include <winrt/Microsoft.ReactNative.Composition.h>
Expand All @@ -22,7 +26,6 @@
#include <winrt/Microsoft.UI.Dispatching.h>
#include <winrt/Microsoft.UI.Windowing.h>
#include <winrt/Microsoft.UI.interop.h>
#include <winrt/base.h>

// C RunTime Header Files
#include <malloc.h>
Expand Down

0 comments on commit ce14e1e

Please sign in to comment.