Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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"
}
23 changes: 20 additions & 3 deletions vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,27 @@ 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<Microsoft::ReactNative::implementation::ReactNativeHost>(host)};
static void ApplyArguments(ReactNative::ReactNativeHost const &host, std::wstring const &arguments) noexcept {
Microsoft::ReactNative::implementation::ReactNativeHost *hostImpl{
get_self<Microsoft::ReactNative::implementation::ReactNativeHost>(host)};
if (!arguments.empty() /*&& host.HasInstance()*/) {
constexpr wchar_t delimiter = L' ';
std::wistringstream argumentStream(arguments);
std::wstring token;
while (std::getline(argumentStream, token, delimiter)) {
if (token == L"-?") {
std::cout << "Options:" << std::endl
<< " --direct-debugging <port> 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<uint16_t>(std::wcstoul(token.c_str(), nullptr, 10));
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
Expand Down
7 changes: 6 additions & 1 deletion vnext/local-cli/runWindows/runWindows.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: Number - Enable direct debugging on specified port
*/
module.exports = {
name: 'run-windows',
Expand All @@ -142,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',
},
{
Expand Down Expand Up @@ -206,5 +207,9 @@ module.exports = {
description: 'Auto link native modules',
default: false,
},
{
command: '--direct-debugging [number]',
description: 'Enable direct debugging on specified port',
},
],
};
2 changes: 1 addition & 1 deletion vnext/local-cli/runWindows/utils/WindowsStoreAppUtils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
11 changes: 5 additions & 6 deletions vnext/local-cli/runWindows/utils/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,15 @@ function getSolutionFile(options) {
}

function parseMsBuildProps(options) {
let result = {};
if (options.msbuildprops) {
var result = {};
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];
}
return result;
}
return null;
return result;
}

module.exports = {
Expand Down
14 changes: 13 additions & 1 deletion vnext/local-cli/runWindows/utils/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,19 @@ async function deployToDesktop(options, verbose) {
path.join(appPackageFolder, 'Add-AppDevPackage.ps1'),
)[0];

const args = ['remoteDebugging', options.proxy ? 'true' : 'false'];
let args = ['--remote-debugging', options.proxy ? 'true' : 'false'];

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);

Expand Down