Skip to content

Commit 9ffa62e

Browse files
authored
Merge pull request #238 from TatianaKapos/tk-upgradesamples
Upgrade Samples to RNW 0.71.0
2 parents a3534f9 + 1ccbc01 commit 9ffa62e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+4542
-4050
lines changed

.github/workflows/SetUpAppForNuget.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ param (
33
[switch]
44
$UseNuGet,
55
[Version]
6-
$WinUIVersion = "2.6.0"
6+
$WinUIVersion = "2.7.0"
77
)
88

99
$AppName = Split-Path $PWD -Leaf

.github/workflows/main.yml

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1414
jobs:
1515
codegen:
16-
runs-on: windows-2019
16+
runs-on: windows-2022
1717
steps:
1818
- name: setup git
1919
run: |
@@ -22,15 +22,21 @@ jobs:
2222
2323
- uses: actions/checkout@v2
2424

25+
- name: yarn install
26+
run: yarn install
27+
2528
- uses: nuget/setup-nuget@v1
2629

2730
- name: NuGet restore
2831
run: nuget restore example\windows\example.sln
2932

3033
- name: run CodeGen
31-
run: dotnet run -verbose -winmd ..\..\example\windows\packages\Microsoft.UI.Xaml.2.6.0\lib\uap10.0\Microsoft.UI.Xaml.winmd
34+
run: dotnet run -verbose -winmd $env:USERPROFILE\.nuget\packages\microsoft.ui.xaml\2.7.0\lib\uap10.0\Microsoft.UI.Xaml.winmd
3235
working-directory: package\Codegen
3336

37+
- name: build TS
38+
run: yarn build
39+
3440
- name: verify no changes from CodeGen
3541
shell: powershell
3642
run: |
@@ -39,9 +45,10 @@ jobs:
3945
if ($changed -ne $null) { throw "CodeGen detected changes" }
4046
4147
examplenuget:
42-
runs-on: windows-2019
48+
runs-on: windows-2022
4349
steps:
4450
- uses: actions/checkout@v2
51+
4552
- name: yarn install
4653
run: yarn install
4754

@@ -56,19 +63,67 @@ jobs:
5663
uses: actions/upload-artifact@v2
5764
with:
5865
name: ExampleNuget appx
59-
path: exampleNuget\windows\AppPackages\exampleNuget\exampleNuget_1.0.0.0_Win32_Debug_Test
66+
path: examplenuget\windows\AppPackages\examplenuget\examplenuget_1.0.0.0_x64_Debug_Test
6067
if-no-files-found: error
6168

6269

63-
testcli:
70+
testcli-old:
6471
runs-on: windows-2019
6572
strategy:
6673
fail-fast: false
6774
matrix:
6875
rnwSource: ['Source', 'NuGet'] # test building with both RNW source and RNW NuGet
69-
rnwVersion: ['^0.64', '^0.67', '^0.69'] # test key versions (min, partners)
76+
rnwVersion: ['^0.67', '^0.69'] # test key versions (min, partners)
7077
steps:
7178
- uses: actions/checkout@v2
79+
80+
- name: yarn install
81+
run: yarn install
82+
83+
- name: build TS
84+
run: yarn build
85+
86+
- name: yarn link
87+
run: yarn link
88+
working-directory: package
89+
90+
- name: create ${{ matrix.rnwVersion }} app
91+
run: npx react-native init testrnx --template react-native@${{ matrix.rnwVersion }}
92+
93+
- name: add Windows (RNW via ${{ matrix.rnwSource }})
94+
run: npx react-native-windows-init --overwrite ${{ matrix.rnwSource == 'NuGet' && '--experimentalNuGetDependency true' || '' }}
95+
working-directory: testrnx
96+
97+
- name: link react-native-xaml
98+
run: yarn link react-native-xaml
99+
working-directory: testrnx
100+
101+
- name: add react-native-xaml
102+
run: yarn add react-native-xaml
103+
working-directory: testrnx
104+
105+
- name: autolink
106+
run: npx react-native autolink-windows --logging
107+
working-directory: testrnx
108+
109+
- name: update WinUI package version
110+
run: ..\.github\workflows\SetUpAppForNuget.ps1 ${{ matrix.rnwSource == 'NuGet' && '-UseNuGet' || '' }}
111+
working-directory: testrnx
112+
113+
- name: build app
114+
run: npx react-native run-windows --no-launch --no-deploy --no-packager --logging
115+
working-directory: testrnx
116+
117+
testcli:
118+
runs-on: windows-2022
119+
strategy:
120+
fail-fast: false
121+
matrix:
122+
rnwSource: ['Source', 'NuGet'] # test building with both RNW source and RNW NuGet
123+
rnwVersion: ['^0.71'] # test key versions (latest)
124+
steps:
125+
- uses: actions/checkout@v2
126+
72127
- name: yarn install
73128
run: yarn install
74129

@@ -107,7 +162,7 @@ jobs:
107162
working-directory: testrnx
108163

109164
package:
110-
runs-on: windows-2019
165+
runs-on: windows-2022
111166
steps:
112167
- uses: actions/checkout@v2
113168

.github/workflows/publish.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,25 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v2
17+
1718
- uses: nuget/setup-nuget@v1
19+
1820
- name: setup-msbuild
1921
uses: microsoft/setup-msbuild@v1
2022

23+
- name: yarn install
24+
run: yarn install
25+
2126
- name: NuGet restore
2227
run: nuget restore example\windows\example.sln
2328

2429
- name: run CodeGen
25-
run: dotnet run -verbose -winmd ..\..\example\windows\packages\Microsoft.UI.Xaml.2.6.0\lib\uap10.0\Microsoft.UI.Xaml.winmd
30+
run: dotnet run -verbose -winmd $env:USERPROFILE\.nuget\packages\microsoft.ui.xaml\2.7.0\lib\uap10.0\Microsoft.UI.Xaml.winmd
2631
working-directory: package\Codegen
2732

33+
- name: build TS
34+
run: yarn build
35+
2836
- name: verify no changes from CodeGen
2937
shell: powershell
3038
run: |
@@ -37,6 +45,7 @@ jobs:
3745

3846
steps:
3947
- uses: actions/checkout@v2
48+
4049
- name: Use Node.js
4150
uses: actions/setup-node@v1
4251
with:

codegen/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"Codegen": {
44
"commandName": "Project",
5-
"commandLineArgs": "-verbose -winmd ..\\..\\..\\..\\..\\example\\windows\\packages\\Microsoft.UI.Xaml.2.6.0\\lib\\uap10.0\\Microsoft.UI.Xaml.winmd"
5+
"commandLineArgs": "-verbose -winmd %USERPROFILE%\\.nuget\\packages\\microsoft.ui.xaml\\2.7.0\\lib\\uap10.0\\Microsoft.UI.Xaml.winmd"
66
}
77
}
88
}

directory.build.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project>
3+
4+
<PropertyGroup Label="NuGet" Condition="'$(MSBuildProjectExtension)' == '.vcxproj'">
5+
<ResolveNuGetPackages>false</ResolveNuGetPackages>
6+
</PropertyGroup>
7+
8+
</Project>

example/App.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import React from 'react';
10-
import type {Node} from 'react';
10+
import type {PropsWithChildren} from 'react';
1111
import {useState} from 'react';
1212

1313
import {
@@ -61,7 +61,11 @@ import {
6161
Grid,
6262
} from 'react-native-xaml';
6363

64-
const Section = ({children, title}): Node => {
64+
type SectionProps = PropsWithChildren<{
65+
title: string;
66+
}>;
67+
68+
function Section({children, title}: SectionProps): JSX.Element {
6569
const isDarkMode = useColorScheme() === 'dark';
6670
return (
6771
<View style={styles.sectionContainer}>
@@ -85,9 +89,9 @@ const Section = ({children, title}): Node => {
8589
</Text>
8690
</View>
8791
);
88-
};
92+
}
8993

90-
const App: () => Node = () => {
94+
function App(): JSX.Element {
9195
const isDarkMode = useColorScheme() === 'dark';
9296

9397
const backgroundStyle = {
@@ -240,7 +244,7 @@ const App: () => Node = () => {
240244
</ScrollView>
241245
</SafeAreaView>
242246
);
243-
};
247+
}
244248

245249
const styles = StyleSheet.create({
246250
sectionContainer: {

example/metro.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ const fs = require('fs');
88
const path = require('path');
99
const exclusionList = require('metro-config/src/defaults/exclusionList');
1010

11+
const rnwPath = fs.realpathSync(
12+
path.resolve(require.resolve('react-native-windows/package.json'), '..'),
13+
);
14+
1115
module.exports = {
1216
watchFolders: [
1317
// Include hoisted modules
@@ -21,7 +25,9 @@ module.exports = {
2125
new RegExp(
2226
`${path.resolve(__dirname, 'windows').replace(/[/\\]/g, '/')}.*`,
2327
),
24-
// This prevents "react-native run-windows" from hitting: EBUSY: resource busy or locked, open msbuild.ProjectImports.zip
28+
// This prevents "react-native run-windows" from hitting: EBUSY: resource busy or locked, open msbuild.ProjectImports.zip or other files produced by msbuild
29+
new RegExp(`${rnwPath}/build/.*`),
30+
new RegExp(`${rnwPath}/target/.*`),
2531
/.*\.ProjectImports\.zip/,
2632
]),
2733
extraNodeModules: {

example/package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,24 @@
1111
"windows": "react-native run-windows"
1212
},
1313
"dependencies": {
14-
"react": "^17.0.1",
15-
"react-native": "0.65.2",
16-
"react-native-windows": "0.65.7",
14+
"react": "18.2.0",
15+
"react-native": "0.71.0",
16+
"react-native-windows": "0.71.0",
1717
"react-native-xaml": "*"
1818
},
1919
"devDependencies": {
2020
"@babel/core": "^7.12.9",
2121
"@babel/runtime": "^7.12.5",
22-
"@react-native-community/eslint-config": "^2.0.0",
23-
"@types/react": "^17.0.0",
22+
"@react-native-community/eslint-config": "^3.0.0",
23+
"@types/react": "^18.0.24",
2424
"@types/react-native": "^0.63.46",
25-
"babel-jest": "^26.6.3",
26-
"eslint": "7.14.0",
27-
"jest": "^26.6.3",
28-
"metro-react-native-babel-preset": "^0.66.0",
25+
"babel-jest": "^29.2.1",
26+
"eslint": "^8.19.0",
27+
"jest": "^29.2.1",
28+
"metro-react-native-babel-preset": "0.73.5",
2929
"react-native-codegen": "^0.0.7",
30-
"react-test-renderer": "17.0.1"
30+
"@types/react-test-renderer": "^18.0.0",
31+
"metro-config": "^0.72.3"
3132
},
3233
"jest": {
3334
"preset": "react-native"
Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,41 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33

4-
<!-- Flags can be added here to effect the compilation of Microsoft.ReactNative -->
5-
<PropertyGroup Label="Microsoft.ReactNative Build Flags">
6-
<UseWinUI3>false</UseWinUI3>
4+
<!--
5+
This file contains some important settings that will apply globally for
6+
your app and *all* native modules your app consumes. These values were
7+
set when you created the app project, and in some cases cannot be
8+
simply changed here without recreating a new project.
9+
-->
10+
11+
<PropertyGroup Label="Microsoft.ReactNative Experimental Features">
12+
<!--
13+
Enables default usage of Hermes.
14+
15+
See https://microsoft.github.io/react-native-windows/docs/hermes
16+
-->
717
<UseHermes>false</UseHermes>
8-
<WinUI2xVersion>2.6.0</WinUI2xVersion>
18+
19+
<!--
20+
Changes compilation to assume use of WinUI 3 instead of System XAML.
21+
Requires creation of new project.
22+
23+
See https://microsoft.github.io/react-native-windows/docs/winui3
24+
-->
25+
<UseWinUI3>false</UseWinUI3>
26+
<WinUI2xVersion>2.7.0</WinUI2xVersion>
27+
28+
<!--
29+
Changes compilation to assume use of Microsoft.ReactNative NuGet packages
30+
instead of building the framework from source.
31+
Requires creation of new project.
32+
33+
See https://microsoft.github.io/react-native-windows/docs/nuget
34+
-->
35+
<UseExperimentalNuget>false</UseExperimentalNuget>
36+
37+
<ReactExperimentalFeaturesSet>true</ReactExperimentalFeaturesSet>
38+
939
</PropertyGroup>
1040

1141
</Project>

example/windows/NuGet.Config

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<config>
4+
<add key="repositoryPath" value="packages" />
5+
</config>
6+
<packageSources>
7+
<clear />
8+
<add key="Nuget.org" value="https://api.nuget.org/v3/index.json" />
9+
</packageSources>
10+
<disabledPackageSources>
11+
<clear />
12+
</disabledPackageSources>
13+
</configuration>

0 commit comments

Comments
 (0)