Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit be96f07

Browse files
abodalevskyRichard Hua
authored andcommitted
Added React Native Windows dotNet46 support (#684)
Added support react-native-windows dotNet Added example for react-native-windows UWP based Added example for react-native-windows dotNet based Project structure: CodePush.Shared - shared code between UWP and dotNet CodePush - UWP specific code CodePush.Net46 - dotNet specific code For UWP solution it needs to be added the following projects: CodePush.Shared CodePush For dotNet solution it needs to be added the following projects: CodePush.Shared CodePush.Net46 Examples: Examples\CodePushDemoApp\windows\CodePushDemoApp.sln the solution contains both examples (UWP and dotNet). Notes Example for ARM configuration has not been tested. Since there is no changes in UWP part of implementation, there is low risk of failure. In this implementation we tried to reuse UWP library as much as possible. The following issues are relevant for both platforms: ZipFile.ExtractToDirectory is not reliable and throws exception if: folder exists already path is too long (> 250 chars) Un-zipping is quite long operation. Does it make sense for async? await UpdateUtils.UnzipBundleAsync(downloadFile.Path, unzippedFolder.Path);
1 parent fc7c109 commit be96f07

File tree

69 files changed

+2866
-87
lines changed

Some content is hidden

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

69 files changed

+2866
-87
lines changed

.gitignore

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# gitignore contributors: remember to update .npmignore
2+
13
# OSX
24
#
35
.DS_Store
@@ -152,4 +154,38 @@ captures/
152154
code-push-plugin-testing-framework/node_modules
153155

154156
# RN New Version App Generation
155-
Examples/testapp_rn
157+
Examples/testapp_rn
158+
159+
# Windows
160+
windows/.vs/
161+
windows/obj/
162+
163+
#Visual Studio files
164+
*.[Oo]bj
165+
*.user
166+
*.aps
167+
*.pch
168+
*.vspscc
169+
*.vssscc
170+
*_i.c
171+
*_p.c
172+
*.ncb
173+
*.suo
174+
*.tlb
175+
*.tlh
176+
*.bak
177+
*.[Cc]ache
178+
*.ilk
179+
*.log
180+
*.lib
181+
*.sbr
182+
*.sdf
183+
*.opensdf
184+
*.opendb
185+
*.unsuccessfulbuild
186+
ipch/
187+
[Oo]bj/
188+
[Bb]in
189+
[Dd]ebug*/
190+
[Rr]elease*/
191+
Ankh.NoLoad

.npmignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,45 @@ android/local.properties
4343
android/.gradle
4444
android/**/*.iml
4545
android/.idea
46+
47+
48+
# Windows
49+
windows/.vs/
50+
windows/obj/
51+
52+
#Tests
53+
windows/CodePush.Net46.Test
54+
55+
#Visual Studio files
56+
*.[Oo]bj
57+
*.user
58+
*.aps
59+
*.pch
60+
*.vspscc
61+
*.vssscc
62+
*_i.c
63+
*_p.c
64+
*.ncb
65+
*.suo
66+
*.tlb
67+
*.tlh
68+
*.bak
69+
*.[Cc]ache
70+
*.ilk
71+
*.log
72+
*.lib
73+
*.sbr
74+
*.sdf
75+
*.opensdf
76+
*.opendb
77+
*.unsuccessfulbuild
78+
ipch/
79+
[Oo]bj/
80+
[Bb]in
81+
[Dd]ebug*/
82+
[Rr]elease*/
83+
Ankh.NoLoad
84+
85+
#NuGet
86+
packages/
87+
*.nupkg
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
5+
<add key="myget.org" value="https://www.myget.org/F/chakracore-preview/api/v3/index.json" />
6+
</packageSources>
7+
</configuration>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require("./demo");

Examples/CodePushDemoApp/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"babel-preset-react-native-stage-0": "1.0.1",
1010
"react": "15.4.0",
1111
"react-native": "0.40.0",
12-
"react-native-code-push": "file:../../"
12+
"react-native-code-push": "file:../../",
13+
"react-native-windows": "0.40.0-rc.1"
1314
}
1415
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
*AppPackages*
2+
*BundleArtifacts*
3+
*ReactAssets*
4+
5+
#OS junk files
6+
[Tt]humbs.db
7+
*.DS_Store
8+
9+
#Visual Studio files
10+
*.[Oo]bj
11+
*.user
12+
*.aps
13+
*.pch
14+
*.vspscc
15+
*.vssscc
16+
*_i.c
17+
*_p.c
18+
*.ncb
19+
*.suo
20+
*.tlb
21+
*.tlh
22+
*.bak
23+
*.[Cc]ache
24+
*.ilk
25+
*.log
26+
*.lib
27+
*.sbr
28+
*.sdf
29+
*.opensdf
30+
*.opendb
31+
*.unsuccessfulbuild
32+
ipch/
33+
[Oo]bj/
34+
[Bb]in
35+
[Dd]ebug*/
36+
[Rr]elease*/
37+
Ankh.NoLoad
38+
39+
# Visual C++ cache files
40+
ipch/
41+
*.aps
42+
*.ncb
43+
*.opendb
44+
*.opensdf
45+
*.sdf
46+
*.cachefile
47+
*.VC.db
48+
*.VC.VC.opendb
49+
50+
#MonoDevelop
51+
*.pidb
52+
*.userprefs
53+
54+
#Tooling
55+
_ReSharper*/
56+
*.resharper
57+
[Tt]est[Rr]esult*
58+
*.sass-cache
59+
60+
#Project files
61+
[Bb]uild/
62+
63+
#Subversion files
64+
.svn
65+
66+
# Office Temp Files
67+
~$*
68+
69+
# vim Temp Files
70+
*~
71+
72+
#NuGet
73+
packages/
74+
*.nupkg
75+
76+
#ncrunch
77+
*ncrunch*
78+
*crunch*.local.xml
79+
80+
# visual studio database projects
81+
*.dbmdl
82+
83+
#Test files
84+
*.testsettings
85+
86+
#Other files
87+
*.DotSettings
88+
.vs/
89+
*project.lock.json
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
5+
</startup>
6+
</configuration>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Application x:Class="CodePushDemoApp.Wpf.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
4+
5+
</Application>
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Controls;
9+
using System.Windows.Navigation;
10+
11+
namespace CodePushDemoApp.Wpf
12+
{
13+
/// <summary>
14+
/// Interaction logic for App.xaml
15+
/// </summary>
16+
public partial class App : Application
17+
{
18+
private readonly AppReactPage _reactPage = new AppReactPage();
19+
20+
/// <summary>
21+
/// Initializes the singleton application object. This is the first line of authored code
22+
/// executed, and as such is the logical equivalent of main() or WinMain().
23+
/// </summary>
24+
public App()
25+
{
26+
}
27+
28+
/// <summary>
29+
/// Override method fired prior to the Startup event when the Run method of the Application object is called...
30+
/// </summary>
31+
/// <param name="e"></param>
32+
protected override void OnStartup(StartupEventArgs e)
33+
{
34+
base.OnStartup(e);
35+
OnCreate(e.Args);
36+
}
37+
38+
/// <summary>
39+
/// Called whenever the app is opened to initialized...
40+
/// </summary>
41+
/// <param name="arguments"></param>
42+
private void OnCreate(string[] arguments)
43+
{
44+
var shellWindow = Application.Current.MainWindow;
45+
46+
if (shellWindow == null)
47+
{
48+
shellWindow = new Window
49+
{
50+
ShowActivated = true,
51+
ShowInTaskbar = true,
52+
Title = "CodePushDemoApp.WPF",
53+
Height = 768,
54+
Width = 1024,
55+
WindowStartupLocation = WindowStartupLocation.CenterScreen
56+
};
57+
58+
Application.Current.MainWindow = shellWindow;
59+
}
60+
61+
//Show Window if it is not already active...
62+
if (!shellWindow.IsLoaded)
63+
{
64+
shellWindow.Show();
65+
}
66+
67+
var rootFrame = shellWindow.Content as Frame;
68+
69+
// Do not repeat app initialization when the Window already has content,
70+
// just ensure that the window is active
71+
if (rootFrame == null)
72+
{
73+
_reactPage.OnCreate(arguments);
74+
75+
// Create a Frame to act as the navigation context and navigate to the first page
76+
rootFrame = new Frame();
77+
78+
rootFrame.NavigationFailed += OnNavigationFailed;
79+
80+
// Place the frame in the current Window
81+
shellWindow.Content = rootFrame;
82+
}
83+
84+
if (rootFrame.Content == null)
85+
{
86+
// When the navigation stack isn't restored navigate to the first page,
87+
// configuring the new page by passing required information as a navigation
88+
// parameter
89+
rootFrame.Content = _reactPage;
90+
}
91+
92+
// Ensure the current window is active
93+
shellWindow.Activate();
94+
}
95+
96+
/// <summary>
97+
/// Invoked when Navigation to a certain page fails
98+
/// </summary>
99+
/// <param name="sender">The Frame which failed navigation</param>
100+
/// <param name="e">Details about the navigation failure</param>
101+
private void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
102+
{
103+
throw new Exception("Failed to load Page...");
104+
}
105+
}
106+
}
107+
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using CodePush.ReactNative;
2+
using ReactNative;
3+
using ReactNative.Modules.Core;
4+
using ReactNative.Shell;
5+
using System;
6+
using System.Collections.Generic;
7+
8+
namespace CodePushDemoApp.Wpf
9+
{
10+
internal class AppReactPage : ReactPage
11+
{
12+
public override string MainComponentName
13+
{
14+
get
15+
{
16+
return "CodePushDemoApp";
17+
}
18+
}
19+
20+
private CodePushReactPackage codePushReactPackage = null;
21+
public override string JavaScriptBundleFile
22+
{
23+
get
24+
{
25+
codePushReactPackage = new CodePushReactPackage("deployment-key-here", this);
26+
27+
#if BUNDLE
28+
return codePushReactPackage.GetJavaScriptBundleFile();
29+
#else
30+
return null;
31+
#endif
32+
}
33+
}
34+
35+
36+
public override List<IReactPackage> Packages
37+
{
38+
get
39+
{
40+
return new List<IReactPackage>
41+
{
42+
new MainReactPackage(),
43+
codePushReactPackage
44+
};
45+
}
46+
}
47+
48+
public override bool UseDeveloperSupport
49+
{
50+
get
51+
{
52+
#if !BUNDLE || DEBUG
53+
return true;
54+
#else
55+
return false;
56+
#endif
57+
}
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)