From c99230901849c71ea24dad7020e829c982741854 Mon Sep 17 00:00:00 2001 From: David Serafimov <12337821+nasadigital@users.noreply.github.com> Date: Wed, 8 Apr 2020 09:02:31 -0700 Subject: [PATCH 1/7] Allow enabling of direct debugging through the CLI. --- ...-windows-2020-04-08-09-04-34-direct_debugging_cli.json | 8 ++++++++ .../windows/SampleAppCPP/App.cpp | 7 +++++++ .../windows/SampleAppCPP/PropertySheet.props | 6 +++++- .../windows/SampleAppCS/App.xaml.cs | 7 +++++++ .../windows/SampleAppCS/SampleAppCS.csproj | 3 +++ .../local-cli/generator-windows/templates/cpp/src/App.cpp | 7 +++++++ .../templates/cpp/src/PropertySheet.props | 6 +++++- .../generator-windows/templates/cs/proj/MyApp.csproj | 3 +++ .../generator-windows/templates/cs/src/App.xaml.cs | 7 +++++++ vnext/local-cli/runWindows/runWindows.js | 6 ++++++ vnext/local-cli/runWindows/utils/build.js | 8 +++++--- 11 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 change/react-native-windows-2020-04-08-09-04-34-direct_debugging_cli.json diff --git a/change/react-native-windows-2020-04-08-09-04-34-direct_debugging_cli.json b/change/react-native-windows-2020-04-08-09-04-34-direct_debugging_cli.json new file mode 100644 index 00000000000..6e190fdc286 --- /dev/null +++ b/change/react-native-windows-2020-04-08-09-04-34-direct_debugging_cli.json @@ -0,0 +1,8 @@ +{ + "type": "prerelease", + "comment": "Allow enabling of direct debugging through the CLI.", + "packageName": "react-native-windows", + "email": "12337821+nasadigital@users.noreply.github.com", + "dependentChangeType": "patch", + "date": "2020-04-08T16:04:34.634Z" +} \ No newline at end of file diff --git a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/App.cpp b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/App.cpp index d5c23ef61ce..957baf90553 100644 --- a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/App.cpp +++ b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/App.cpp @@ -34,6 +34,13 @@ App::App() noexcept { InstanceSettings().EnableDeveloperMenu(false); #endif +#if USE_DIRECT_DEBUGGING + InstanceSettings().UseWebDebugger(false); + InstanceSettings().UseDirectDebugger(true); + InstanceSettings().DebuggerBreakOnNextLine(true); + InstanceSettings().DebuggerPort(9229); +#endif + PackageProviders().Append(make()); // Includes all modules in this project PackageProviders().Append(winrt::SampleLibraryCpp::ReactPackageProvider()); PackageProviders().Append(winrt::SampleLibraryCS::ReactPackageProvider()); diff --git a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/PropertySheet.props b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/PropertySheet.props index 064dec08100..fc603f6ab25 100644 --- a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/PropertySheet.props +++ b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/PropertySheet.props @@ -8,7 +8,11 @@ normal - + + + USE_DIRECT_DEBUGGING;%(PreprocessorDefinitions) + + $(CppWinRTVerbosity) diff --git a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/App.xaml.cs b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/App.xaml.cs index a2552c4c772..7e972f434c6 100644 --- a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/App.xaml.cs +++ b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/App.xaml.cs @@ -36,6 +36,13 @@ public App() InstanceSettings.EnableDeveloperMenu = false; #endif +#if USE_DIRECT_DEBUGGING + InstanceSettings.UseWebDebugger = false; + InstanceSettings.UseDirectDebugger = true; + InstanceSettings.DebuggerBreakOnNextLine = true; + InstanceSettings.DebuggerPort = 9229; +#endif + PackageProviders.Add(new Microsoft.ReactNative.Managed.ReactPackageProvider()); // Includes any modules in this project PackageProviders.Add(new SampleLibraryCS.ReactPackageProvider()); PackageProviders.Add(new SampleLibraryCpp.ReactPackageProvider()); diff --git a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/SampleAppCS.csproj b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/SampleAppCS.csproj index 2e97b136b5b..c30ccf33393 100644 --- a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/SampleAppCS.csproj +++ b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/SampleAppCS.csproj @@ -120,6 +120,9 @@ PackageReference + + $(DefineConstants);USE_DIRECT_DEBUGGING + App.xaml diff --git a/vnext/local-cli/generator-windows/templates/cpp/src/App.cpp b/vnext/local-cli/generator-windows/templates/cpp/src/App.cpp index e79bb0b7dd8..1bc85388977 100644 --- a/vnext/local-cli/generator-windows/templates/cpp/src/App.cpp +++ b/vnext/local-cli/generator-windows/templates/cpp/src/App.cpp @@ -31,6 +31,13 @@ App::App() noexcept InstanceSettings().EnableDeveloperMenu(false); #endif +#if USE_DIRECT_DEBUGGING + InstanceSettings().UseWebDebugger(false); + InstanceSettings().UseDirectDebugger(true); + InstanceSettings().DebuggerBreakOnNextLine(true); + InstanceSettings().DebuggerPort(9229); +#endif + PackageProviders().Append(make()); // Includes all modules in this project REACT_REGISTER_NATIVE_MODULE_PACKAGES(); //code-gen macro from autolink diff --git a/vnext/local-cli/generator-windows/templates/cpp/src/PropertySheet.props b/vnext/local-cli/generator-windows/templates/cpp/src/PropertySheet.props index 5942ba395bb..aab8f9c7cd9 100644 --- a/vnext/local-cli/generator-windows/templates/cpp/src/PropertySheet.props +++ b/vnext/local-cli/generator-windows/templates/cpp/src/PropertySheet.props @@ -12,5 +12,9 @@ https://github.com/Microsoft/xlang/tree/master/src/package/cppwinrt/nuget --> - + + + USE_DIRECT_DEBUGGING;%(PreprocessorDefinitions) + + \ No newline at end of file diff --git a/vnext/local-cli/generator-windows/templates/cs/proj/MyApp.csproj b/vnext/local-cli/generator-windows/templates/cs/proj/MyApp.csproj index 2b598cbc339..78348b1782d 100644 --- a/vnext/local-cli/generator-windows/templates/cs/proj/MyApp.csproj +++ b/vnext/local-cli/generator-windows/templates/cs/proj/MyApp.csproj @@ -117,6 +117,9 @@ PackageReference + + $(DefineConstants);USE_DIRECT_DEBUGGING + App.xaml diff --git a/vnext/local-cli/generator-windows/templates/cs/src/App.xaml.cs b/vnext/local-cli/generator-windows/templates/cs/src/App.xaml.cs index 77b1a40b190..10b728393b4 100644 --- a/vnext/local-cli/generator-windows/templates/cs/src/App.xaml.cs +++ b/vnext/local-cli/generator-windows/templates/cs/src/App.xaml.cs @@ -24,6 +24,13 @@ public App() InstanceSettings.EnableDeveloperMenu = false; #endif +#if USE_DIRECT_DEBUGGING + InstanceSettings.UseWebDebugger = false; + InstanceSettings.UseDirectDebugger = true; + InstanceSettings.DebuggerBreakOnNextLine = true; + InstanceSettings.DebuggerPort = 9229; +#endif + PackageProviders.Add(new Microsoft.ReactNative.Managed.ReactPackageProvider()); // Includes any modules in this project InitializeComponent(); diff --git a/vnext/local-cli/runWindows/runWindows.js b/vnext/local-cli/runWindows/runWindows.js index 3a4c9e40bea..1f1de0d01fa 100644 --- a/vnext/local-cli/runWindows/runWindows.js +++ b/vnext/local-cli/runWindows/runWindows.js @@ -124,6 +124,7 @@ runWindows({ * no-build: Boolean - Do not build the solution * no-deploy: Boolean - Do not deploy the app * msBuildProps: String - Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2 + * direct-debugging: Boolean - Enables direct debugging by default */ module.exports = { name: 'run-windows', @@ -206,5 +207,10 @@ module.exports = { description: 'Auto link native modules', default: false, }, + { + command: '--direct-debugging', + description: 'Turn on direct debugging by default', + default: false, + }, ], }; diff --git a/vnext/local-cli/runWindows/utils/build.js b/vnext/local-cli/runWindows/utils/build.js index 4d4ad38e431..dcd915a1b3a 100644 --- a/vnext/local-cli/runWindows/utils/build.js +++ b/vnext/local-cli/runWindows/utils/build.js @@ -96,16 +96,18 @@ function getSolutionFile(options) { } function parseMsBuildProps(options) { + var result = {}; if (options.msbuildprops) { - var result = {}; var props = options.msbuildprops.split(','); for (var i = 0; i < props.length; i++) { var prop = props[i].split('='); result[prop[0]] = prop[1]; } - return result; } - return null; + if (options.directDebugging) { + result.UseDirectDebugging = 'true'; + } + return result; } module.exports = { From f20fb3f4aad231b435cfa5af05f1a7f82773d9b6 Mon Sep 17 00:00:00 2001 From: David Serafimov <12337821+nasadigital@users.noreply.github.com> Date: Thu, 9 Apr 2020 13:09:55 -0700 Subject: [PATCH 2/7] Use more accurate declartions. --- vnext/local-cli/runWindows/utils/build.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vnext/local-cli/runWindows/utils/build.js b/vnext/local-cli/runWindows/utils/build.js index dcd915a1b3a..2f5b183ba19 100644 --- a/vnext/local-cli/runWindows/utils/build.js +++ b/vnext/local-cli/runWindows/utils/build.js @@ -96,11 +96,11 @@ function getSolutionFile(options) { } function parseMsBuildProps(options) { - var result = {}; + let result = {}; if (options.msbuildprops) { - var props = options.msbuildprops.split(','); - for (var i = 0; i < props.length; i++) { - var prop = props[i].split('='); + const props = options.msbuildprops.split(','); + for (let i = 0; i < props.length; i++) { + const prop = props[i].split('='); result[prop[0]] = prop[1]; } } From 557f5dd06da04aa9ea1a0e6c35a2a09aaf93f3e0 Mon Sep 17 00:00:00 2001 From: David Serafimov <12337821+nasadigital@users.noreply.github.com> Date: Tue, 14 Apr 2020 19:20:20 -0700 Subject: [PATCH 3/7] Enable direct debugging through command line arguments instead of defines. --- .../windows/SampleAppCPP/App.cpp | 7 ------- .../windows/SampleAppCPP/PropertySheet.props | 6 +----- .../windows/SampleAppCS/App.xaml.cs | 7 ------- .../windows/SampleAppCS/SampleAppCS.csproj | 3 --- .../ReactApplicationDelegate.cpp | 20 ++++++++++++++++--- .../templates/cpp/src/App.cpp | 7 ------- .../templates/cpp/src/PropertySheet.props | 6 +----- .../templates/cs/proj/MyApp.csproj | 3 --- .../templates/cs/src/App.xaml.cs | 7 ------- vnext/local-cli/runWindows/runWindows.js | 7 +++---- vnext/local-cli/runWindows/utils/build.js | 3 --- vnext/local-cli/runWindows/utils/deploy.js | 6 +++++- 12 files changed, 27 insertions(+), 55 deletions(-) diff --git a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/App.cpp b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/App.cpp index 957baf90553..d5c23ef61ce 100644 --- a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/App.cpp +++ b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/App.cpp @@ -34,13 +34,6 @@ App::App() noexcept { InstanceSettings().EnableDeveloperMenu(false); #endif -#if USE_DIRECT_DEBUGGING - InstanceSettings().UseWebDebugger(false); - InstanceSettings().UseDirectDebugger(true); - InstanceSettings().DebuggerBreakOnNextLine(true); - InstanceSettings().DebuggerPort(9229); -#endif - PackageProviders().Append(make()); // Includes all modules in this project PackageProviders().Append(winrt::SampleLibraryCpp::ReactPackageProvider()); PackageProviders().Append(winrt::SampleLibraryCS::ReactPackageProvider()); diff --git a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/PropertySheet.props b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/PropertySheet.props index fc603f6ab25..064dec08100 100644 --- a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/PropertySheet.props +++ b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCPP/PropertySheet.props @@ -8,11 +8,7 @@ normal - - - USE_DIRECT_DEBUGGING;%(PreprocessorDefinitions) - - + $(CppWinRTVerbosity) diff --git a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/App.xaml.cs b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/App.xaml.cs index 7e972f434c6..a2552c4c772 100644 --- a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/App.xaml.cs +++ b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/App.xaml.cs @@ -36,13 +36,6 @@ public App() InstanceSettings.EnableDeveloperMenu = false; #endif -#if USE_DIRECT_DEBUGGING - InstanceSettings.UseWebDebugger = false; - InstanceSettings.UseDirectDebugger = true; - InstanceSettings.DebuggerBreakOnNextLine = true; - InstanceSettings.DebuggerPort = 9229; -#endif - PackageProviders.Add(new Microsoft.ReactNative.Managed.ReactPackageProvider()); // Includes any modules in this project PackageProviders.Add(new SampleLibraryCS.ReactPackageProvider()); PackageProviders.Add(new SampleLibraryCpp.ReactPackageProvider()); diff --git a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/SampleAppCS.csproj b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/SampleAppCS.csproj index c30ccf33393..2e97b136b5b 100644 --- a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/SampleAppCS.csproj +++ b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/SampleAppCS.csproj @@ -120,9 +120,6 @@ PackageReference - - $(DefineConstants);USE_DIRECT_DEBUGGING - App.xaml diff --git a/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp b/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp index 0dd35ba0e96..e55ea857bc3 100644 --- a/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp +++ b/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp @@ -20,10 +20,24 @@ using namespace Windows::ApplicationModel::Activation; namespace winrt::Microsoft::ReactNative::implementation { -static void ApplyArguments(ReactNative::ReactNativeHost const & /*host*/, std::wstring const &arguments) noexcept { - // Microsoft::ReactNative::implementation::ReactNativeHost* hostImpl { - // get_self(host)}; +static void ApplyArguments(ReactNative::ReactNativeHost const &host, std::wstring const &arguments) noexcept { + Microsoft::ReactNative::implementation::ReactNativeHost *hostImpl{ + get_self(host)}; if (!arguments.empty() /*&& host.HasInstance()*/) { + std::wistringstream argumentStream(arguments); + std::wstring token; + while (std::getline(argumentStream, token, L' ')) { + if (token == L"directDebugging" && std::getline(argumentStream, token, L' ')) { + wchar_t *nextPosition = nullptr; + const uint16_t port = static_cast(std::wcstol(token.c_str(), &nextPosition, 10)); + if (nextPosition == nullptr) { + hostImpl->InstanceSettings().UseWebDebugger(false); + hostImpl->InstanceSettings().UseDirectDebugger(true); + hostImpl->InstanceSettings().DebuggerBreakOnNextLine(true); + hostImpl->InstanceSettings().DebuggerPort(port); + } + } + } // TODO: check for 'remoteDebugging'. Return if not found. Otherwise, // validate a value is provided and then parse it to set the // ReactInstanceManager.DevSupportManager.IsRemoteDebuggingEnabled flag diff --git a/vnext/local-cli/generator-windows/templates/cpp/src/App.cpp b/vnext/local-cli/generator-windows/templates/cpp/src/App.cpp index 1bc85388977..e79bb0b7dd8 100644 --- a/vnext/local-cli/generator-windows/templates/cpp/src/App.cpp +++ b/vnext/local-cli/generator-windows/templates/cpp/src/App.cpp @@ -31,13 +31,6 @@ App::App() noexcept InstanceSettings().EnableDeveloperMenu(false); #endif -#if USE_DIRECT_DEBUGGING - InstanceSettings().UseWebDebugger(false); - InstanceSettings().UseDirectDebugger(true); - InstanceSettings().DebuggerBreakOnNextLine(true); - InstanceSettings().DebuggerPort(9229); -#endif - PackageProviders().Append(make()); // Includes all modules in this project REACT_REGISTER_NATIVE_MODULE_PACKAGES(); //code-gen macro from autolink diff --git a/vnext/local-cli/generator-windows/templates/cpp/src/PropertySheet.props b/vnext/local-cli/generator-windows/templates/cpp/src/PropertySheet.props index aab8f9c7cd9..5942ba395bb 100644 --- a/vnext/local-cli/generator-windows/templates/cpp/src/PropertySheet.props +++ b/vnext/local-cli/generator-windows/templates/cpp/src/PropertySheet.props @@ -12,9 +12,5 @@ https://github.com/Microsoft/xlang/tree/master/src/package/cppwinrt/nuget --> - - - USE_DIRECT_DEBUGGING;%(PreprocessorDefinitions) - - + \ No newline at end of file diff --git a/vnext/local-cli/generator-windows/templates/cs/proj/MyApp.csproj b/vnext/local-cli/generator-windows/templates/cs/proj/MyApp.csproj index 78348b1782d..2b598cbc339 100644 --- a/vnext/local-cli/generator-windows/templates/cs/proj/MyApp.csproj +++ b/vnext/local-cli/generator-windows/templates/cs/proj/MyApp.csproj @@ -117,9 +117,6 @@ PackageReference - - $(DefineConstants);USE_DIRECT_DEBUGGING - App.xaml diff --git a/vnext/local-cli/generator-windows/templates/cs/src/App.xaml.cs b/vnext/local-cli/generator-windows/templates/cs/src/App.xaml.cs index 10b728393b4..77b1a40b190 100644 --- a/vnext/local-cli/generator-windows/templates/cs/src/App.xaml.cs +++ b/vnext/local-cli/generator-windows/templates/cs/src/App.xaml.cs @@ -24,13 +24,6 @@ public App() InstanceSettings.EnableDeveloperMenu = false; #endif -#if USE_DIRECT_DEBUGGING - InstanceSettings.UseWebDebugger = false; - InstanceSettings.UseDirectDebugger = true; - InstanceSettings.DebuggerBreakOnNextLine = true; - InstanceSettings.DebuggerPort = 9229; -#endif - PackageProviders.Add(new Microsoft.ReactNative.Managed.ReactPackageProvider()); // Includes any modules in this project InitializeComponent(); diff --git a/vnext/local-cli/runWindows/runWindows.js b/vnext/local-cli/runWindows/runWindows.js index 1f1de0d01fa..c299acabc5c 100644 --- a/vnext/local-cli/runWindows/runWindows.js +++ b/vnext/local-cli/runWindows/runWindows.js @@ -124,7 +124,7 @@ runWindows({ * no-build: Boolean - Do not build the solution * no-deploy: Boolean - Do not deploy the app * msBuildProps: String - Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2 - * direct-debugging: Boolean - Enables direct debugging by default + * direct-debugging: Number - Enable direct debugging on specified port */ module.exports = { name: 'run-windows', @@ -208,9 +208,8 @@ module.exports = { default: false, }, { - command: '--direct-debugging', - description: 'Turn on direct debugging by default', - default: false, + command: '--direct-debugging [number]', + description: 'Enable direct debugging on specified port', }, ], }; diff --git a/vnext/local-cli/runWindows/utils/build.js b/vnext/local-cli/runWindows/utils/build.js index 2f5b183ba19..e8d68401929 100644 --- a/vnext/local-cli/runWindows/utils/build.js +++ b/vnext/local-cli/runWindows/utils/build.js @@ -104,9 +104,6 @@ function parseMsBuildProps(options) { result[prop[0]] = prop[1]; } } - if (options.directDebugging) { - result.UseDirectDebugging = 'true'; - } return result; } diff --git a/vnext/local-cli/runWindows/utils/deploy.js b/vnext/local-cli/runWindows/utils/deploy.js index 5bddc239f59..98cc8907e99 100644 --- a/vnext/local-cli/runWindows/utils/deploy.js +++ b/vnext/local-cli/runWindows/utils/deploy.js @@ -162,7 +162,11 @@ async function deployToDesktop(options, verbose) { path.join(appPackageFolder, 'Add-AppDevPackage.ps1'), )[0]; - const args = ['remoteDebugging', options.proxy ? 'true' : 'false']; + let args = ['remoteDebugging', options.proxy ? 'true' : 'false']; + + if (options.directDebugging) { + args.push('directDebugging', options.directDebugging); + } const popd = pushd(options.root); From 7f5dec3468a05b7723da795cb06afdedc1e0488a Mon Sep 17 00:00:00 2001 From: David Serafimov <12337821+nasadigital@users.noreply.github.com> Date: Wed, 15 Apr 2020 19:25:52 -0700 Subject: [PATCH 4/7] Addres PR feedback. --- .../ReactApplicationDelegate.cpp | 11 +++++++---- vnext/local-cli/runWindows/utils/deploy.js | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp b/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp index e55ea857bc3..5f0133be5ee 100644 --- a/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp +++ b/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp @@ -27,10 +27,13 @@ static void ApplyArguments(ReactNative::ReactNativeHost const &host, std::wstrin std::wistringstream argumentStream(arguments); std::wstring token; while (std::getline(argumentStream, token, L' ')) { - if (token == L"directDebugging" && std::getline(argumentStream, token, L' ')) { - wchar_t *nextPosition = nullptr; - const uint16_t port = static_cast(std::wcstol(token.c_str(), &nextPosition, 10)); - if (nextPosition == nullptr) { + if (token == L"-?") { + std::cout << "Options:\n" + " directDebugging Enable direct debugging on specified port.\n"; + std::cout.flush(); + } else if (token == L"directDebugging") { + if (std::getline(argumentStream, token, L' ')) { + const uint16_t port = static_cast(std::wcstoul(token.c_str(), nullptr, 10)); hostImpl->InstanceSettings().UseWebDebugger(false); hostImpl->InstanceSettings().UseDirectDebugger(true); hostImpl->InstanceSettings().DebuggerBreakOnNextLine(true); diff --git a/vnext/local-cli/runWindows/utils/deploy.js b/vnext/local-cli/runWindows/utils/deploy.js index 98cc8907e99..2d08e97a7d6 100644 --- a/vnext/local-cli/runWindows/utils/deploy.js +++ b/vnext/local-cli/runWindows/utils/deploy.js @@ -164,8 +164,9 @@ async function deployToDesktop(options, verbose) { let args = ['remoteDebugging', options.proxy ? 'true' : 'false']; - if (options.directDebugging) { - args.push('directDebugging', options.directDebugging); + const port = parseInt(options.directDebugging, 10); + if (!isNaN(port)) { + args.push('directDebugging', port.toString()); } const popd = pushd(options.root); From 9da0d64e89fff748f9d169e3376d6c96b8bbcbe6 Mon Sep 17 00:00:00 2001 From: David Serafimov <12337821+nasadigital@users.noreply.github.com> Date: Wed, 15 Apr 2020 19:33:02 -0700 Subject: [PATCH 5/7] Use same delimiter as when running through the react native CLI. --- vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp b/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp index 5f0133be5ee..f6c099f6b4a 100644 --- a/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp +++ b/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp @@ -24,15 +24,16 @@ static void ApplyArguments(ReactNative::ReactNativeHost const &host, std::wstrin Microsoft::ReactNative::implementation::ReactNativeHost *hostImpl{ get_self(host)}; if (!arguments.empty() /*&& host.HasInstance()*/) { + constexpr wchar_t delimiter = L','; std::wistringstream argumentStream(arguments); std::wstring token; - while (std::getline(argumentStream, token, L' ')) { + while (std::getline(argumentStream, token, delimiter)) { if (token == L"-?") { std::cout << "Options:\n" - " directDebugging Enable direct debugging on specified port.\n"; + " directDebugging, Enable direct debugging on specified port.\n"; std::cout.flush(); } else if (token == L"directDebugging") { - if (std::getline(argumentStream, token, L' ')) { + if (std::getline(argumentStream, token, delimiter)) { const uint16_t port = static_cast(std::wcstoul(token.c_str(), nullptr, 10)); hostImpl->InstanceSettings().UseWebDebugger(false); hostImpl->InstanceSettings().UseDirectDebugger(true); From f48cb5baa53a18115c4f776a5651f2950b540353 Mon Sep 17 00:00:00 2001 From: David Serafimov <12337821+nasadigital@users.noreply.github.com> Date: Thu, 16 Apr 2020 12:32:30 -0700 Subject: [PATCH 6/7] Change delimiter back to whitespace. --- vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp | 7 +++---- vnext/local-cli/runWindows/utils/WindowsStoreAppUtils.ps1 | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp b/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp index f6c099f6b4a..f26b392dd20 100644 --- a/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp +++ b/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp @@ -24,14 +24,13 @@ static void ApplyArguments(ReactNative::ReactNativeHost const &host, std::wstrin Microsoft::ReactNative::implementation::ReactNativeHost *hostImpl{ get_self(host)}; if (!arguments.empty() /*&& host.HasInstance()*/) { - constexpr wchar_t delimiter = L','; + constexpr wchar_t delimiter = L' '; std::wistringstream argumentStream(arguments); std::wstring token; while (std::getline(argumentStream, token, delimiter)) { if (token == L"-?") { - std::cout << "Options:\n" - " directDebugging, Enable direct debugging on specified port.\n"; - std::cout.flush(); + std::cout << "Options:" << std::endl + << " directDebugging Enable direct debugging on specified port." << std::endl; } else if (token == L"directDebugging") { if (std::getline(argumentStream, token, delimiter)) { const uint16_t port = static_cast(std::wcstoul(token.c_str(), nullptr, 10)); diff --git a/vnext/local-cli/runWindows/utils/WindowsStoreAppUtils.ps1 b/vnext/local-cli/runWindows/utils/WindowsStoreAppUtils.ps1 index 68a76ce1874..ef23893d174 100644 --- a/vnext/local-cli/runWindows/utils/WindowsStoreAppUtils.ps1 +++ b/vnext/local-cli/runWindows/utils/WindowsStoreAppUtils.ps1 @@ -175,6 +175,6 @@ function Start-Locally { add-type -TypeDefinition $code $appActivator = new-object StoreAppRunner.ApplicationActivationManager - $args = [system.String]::Join(",", $argv) + $args = [system.String]::Join(" ", $argv) $appActivator.ActivateApplication($applicationUserModelId,$args,[StoreAppRunner.ActivateOptions]::None,[ref]0) | Out-Null } From cb8b7c77a25b99dc6ea22ec5b371194f30e9054e Mon Sep 17 00:00:00 2001 From: David Serafimov <12337821+nasadigital@users.noreply.github.com> Date: Fri, 17 Apr 2020 10:20:05 -0700 Subject: [PATCH 7/7] Address PR feedback. --- .../ReactApplicationDelegate.cpp | 4 ++-- vnext/local-cli/runWindows/runWindows.js | 2 +- vnext/local-cli/runWindows/utils/deploy.js | 15 +++++++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp b/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp index f26b392dd20..d4619d9d879 100644 --- a/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp +++ b/vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp @@ -30,8 +30,8 @@ static void ApplyArguments(ReactNative::ReactNativeHost const &host, std::wstrin while (std::getline(argumentStream, token, delimiter)) { if (token == L"-?") { std::cout << "Options:" << std::endl - << " directDebugging Enable direct debugging on specified port." << std::endl; - } else if (token == L"directDebugging") { + << " --direct-debugging Enable direct debugging on specified port." << std::endl; + } else if (token == L"--direct-debugging") { if (std::getline(argumentStream, token, delimiter)) { const uint16_t port = static_cast(std::wcstoul(token.c_str(), nullptr, 10)); hostImpl->InstanceSettings().UseWebDebugger(false); diff --git a/vnext/local-cli/runWindows/runWindows.js b/vnext/local-cli/runWindows/runWindows.js index c299acabc5c..a056a7f8636 100644 --- a/vnext/local-cli/runWindows/runWindows.js +++ b/vnext/local-cli/runWindows/runWindows.js @@ -143,7 +143,7 @@ module.exports = { }, { command: '--arch [string]', - description: 'The build architecture (ARM, x86, x64)', + description: 'The build architecture (ARM, ARM64, x86, x64)', default: 'x86', }, { diff --git a/vnext/local-cli/runWindows/utils/deploy.js b/vnext/local-cli/runWindows/utils/deploy.js index 2d08e97a7d6..1225885f681 100644 --- a/vnext/local-cli/runWindows/utils/deploy.js +++ b/vnext/local-cli/runWindows/utils/deploy.js @@ -162,11 +162,18 @@ async function deployToDesktop(options, verbose) { path.join(appPackageFolder, 'Add-AppDevPackage.ps1'), )[0]; - let args = ['remoteDebugging', options.proxy ? 'true' : 'false']; + let args = ['--remote-debugging', options.proxy ? 'true' : 'false']; - const port = parseInt(options.directDebugging, 10); - if (!isNaN(port)) { - args.push('directDebugging', port.toString()); + if (options.directDebugging) { + const port = parseInt(options.directDebugging, 10); + if (!isNaN(port) && port > 1024 && port < 65535) { + args.push('--direct-debugging', port.toString()); + } else { + newError( + 'Direct debugging port not specified, invalid or out of bounds.', + ); + process.exit(1); + } } const popd = pushd(options.root);