Skip to content

Commit 415fd32

Browse files
authored
fix(windows): fix run-windows not launching apps built with New Arch (#2256)
1 parent 52d14ec commit 415fd32

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

windows/Win32/ReactApp.Package.wapproj

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@
1313
</PropertyGroup>
1414
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.WindowsSdk.Default.props" />
1515
<PropertyGroup>
16+
<!--
17+
`AppxManifest.xml` is output relative to the `.wapproj` file and
18+
`run-windows` cannot find it because it expects `.wapproj` to be in the
19+
same directory as the solution. We need to change the output directory so
20+
that `run-windows` can find the file.
21+
22+
Note that we don't use `OutDir` because the project name is always
23+
appended to it, e.g. `x64/Debug/ReactApp.Package`.
24+
-->
25+
<BaseOutputPath>$([MSBuild]::MakeRelative($(MSBuildThisFileDirectory), $(SolutionDir)))\$(MSBuildProjectName)\bin\</BaseOutputPath>
26+
<OutputPath>$(BaseOutputPath)\$(Platform)\$(Configuration)\</OutputPath>
1627
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
1728
</PropertyGroup>
1829
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
@@ -88,4 +99,20 @@
8899
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.props')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.props'))" />
89100
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.targets'))" />
90101
</Target>
102+
<Target Name="CopyAppPackagesToOutputDirectory" AfterTargets="_GenerateAppxPackage">
103+
<!--
104+
`AppPackages` is output relative to the `.wapproj` file and `run-windows`
105+
cannot find it because it expects `.wapproj` to be in the same directory
106+
as the solution. We need to copy the files to the output directory so that
107+
`run-windows` can find them.
108+
-->
109+
<ItemGroup>
110+
<AppPackagesFiles Include="$(MSBuildThisFileDirectory)\AppPackages\**\*.*"/>
111+
</ItemGroup>
112+
<Copy
113+
SourceFiles="@(AppPackagesFiles)"
114+
DestinationFolder="$(BaseOutputPath)\..\AppPackages\%(RecursiveDir)"
115+
UseSymbolicLinksIfPossible="true"
116+
/>
117+
</Target>
91118
</Project>

windows/Win32/pch.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#include <unknwn.h>
1414

1515
// WinRT Header Files
16+
// clang-format off
17+
#include <winrt/base.h>
18+
// clang-format on
19+
1620
#include <CppWinRTIncludes.h>
1721

1822
#include <winrt/Microsoft.ReactNative.Composition.h>
@@ -22,7 +26,6 @@
2226
#include <winrt/Microsoft.UI.Dispatching.h>
2327
#include <winrt/Microsoft.UI.Windowing.h>
2428
#include <winrt/Microsoft.UI.interop.h>
25-
#include <winrt/base.h>
2629

2730
// C RunTime Header Files
2831
#include <malloc.h>

0 commit comments

Comments
 (0)