@react-native-windows/cli 0.68.1 → 0.68.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -101,8 +101,9 @@ function commandWithProgress(spinner, taskDoingName, command, args, verbose, err
101
101
  }
102
102
  else {
103
103
  spinner.fail();
104
- reject(new telemetry_1.CodedError(errorCategory, `${taskDoingName} - error code ${code}`, {
105
- errorCode: code,
104
+ reject(new telemetry_1.CodedError(errorCategory, `${taskDoingName} - exit error code ${code}`, {
105
+ taskName: taskDoingName,
106
+ taskExitCode: code,
106
107
  }));
107
108
  }
108
109
  });
@@ -1 +1 @@
1
- {"version":3,"file":"commandWithProgress.js","sourceRoot":"","sources":["../../../src/runWindows/utils/commandWithProgress.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,iDAAkD;AAClD,8CAAsB;AACtB,gEAAoC;AACpC,kDAA0B;AAC1B,+DAKyC;AAEzC,SAAS,cAAc,CAAC,OAAgB,EAAE,MAAc,EAAE,IAAY;IACpE,IAAI,GAAG,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACpC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACjB,MAAM,aAAa,GAAG,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5C,IAAI,aAAa,GAAG,CAAC,EAAE;QACrB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;KACpC;IACD,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACjB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAA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AA0B,EAC1B,KAAa;IAEb,IAAI,KAAK,EAAE;QACT,MAAM,SAAS,GACb,KAAK,YAAY,sBAAU,CAAC,CAAC,CAAE,KAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAEvE,OAAO,CAAC,QAAQ,GAAG,uBAAW,CAAC,SAAS,CAAC,CAAC;QAE1C,IAAI,gBAAgB,EAAE;YACpB,OAAO,CAAC,GAAG,CACT,6BAA6B,eAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CACvE,CAAC;YACF,IAAI,qBAAS,CAAC,SAAS,EAAE,EAAE;gBACzB,OAAO,CAAC,GAAG,CACT,gCAAgC,eAAK,CAAC,IAAI,CACxC,qBAAS,CAAC,YAAY,EAAE,CACzB,EAAE,CACJ,CAAC;aACH;SACF;aAAM;YACL,OAAO,CAAC,GAAG,CACT,2CAA2C,eAAK,CAAC,IAAI,CACnD,WAAW,CACZ,wBAAwB,CAC1B,CAAC;SACH;KACF;AACH,CAAC;AA7BD,0DA6BC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {spawn, SpawnOptions} from 'child_process';\nimport ora from 'ora';\nimport spinners from 'cli-spinners';\nimport chalk from 'chalk';\nimport {\n Telemetry,\n CodedError,\n CodedErrors,\n CodedErrorType,\n} from '@react-native-windows/telemetry';\n\nfunction setSpinnerText(spinner: ora.Ora, prefix: string, text: string) {\n text = prefix + spinnerString(text);\n spinner.text = text.length > 45 ? text.slice(0, 110) + '...' : text;\n}\n\nfunction spinnerString(msg: string) {\n msg = msg.trim();\n const lastLineIndex = msg.lastIndexOf('\\n');\n if (lastLineIndex > 0) {\n msg = msg.slice(lastLineIndex + 1);\n }\n msg = msg.trim();\n return msg;\n}\n\nexport function newSpinner(text: string) {\n const options: ora.Options = {\n text: text,\n indent: 1,\n\n // ora turns off emoji rendering by default on windows, since the default terminal\n // doesn't render them. Turn them back on when running in the new windows terminal\n ...(process.env.WT_SESSION && {spinner: spinners.dots}),\n\n // By default, ora process.stderr as the output stream, however,the VS Code debugger\n // Uses stdout to match success patterns\n stream: process.stdout,\n };\n\n return ora(options).start();\n}\n\nexport const powershell = `${process.env.SystemRoot}\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe`;\n\nexport async function runPowerShellScriptFunction(\n taskDescription: string,\n script: string | null,\n funcName: string,\n verbose: boolean,\n errorCategory: CodedErrorType,\n) {\n try {\n const printException = verbose ? '$_;' : '';\n const importScript = script ? `Import-Module \"${script}\"; ` : '';\n await commandWithProgress(\n newSpinner(taskDescription),\n taskDescription,\n powershell,\n [\n '-NoProfile',\n '-ExecutionPolicy',\n 'RemoteSigned',\n `${importScript}try { ${funcName} -ErrorAction Stop; $lec = $LASTEXITCODE; } catch { $lec = 1; ${printException} }; exit $lec`,\n ],\n verbose,\n errorCategory,\n );\n } catch {\n // The error output from the process will be shown if verbose is set.\n // We don't capture the process output if verbose is set, but at least we have the task name in text, so throw that.\n throw new CodedError(errorCategory, taskDescription);\n }\n}\n\nexport function commandWithProgress(\n spinner: ora.Ora,\n taskDoingName: string,\n command: string,\n args: string[],\n verbose: boolean,\n errorCategory: CodedErrorType,\n) {\n return new Promise<void>((resolve, reject) => {\n const spawnOptions: SpawnOptions = verbose ? {stdio: 'inherit'} : {};\n\n if (verbose) {\n spinner.stop();\n }\n\n const cp = spawn(command, args, spawnOptions);\n let firstErrorLine: string | null = null;\n if (!verbose) {\n cp.stdout!.on('data', (chunk) => {\n const text = chunk.toString();\n setSpinnerText(spinner, taskDoingName + ': ', text);\n });\n cp.stderr!.on('data', (chunk) => {\n const text: string = chunk.toString();\n if (!firstErrorLine) {\n firstErrorLine = text;\n }\n if (text) {\n setSpinnerText(spinner, taskDoingName + ': ERROR: ', firstErrorLine);\n }\n reject(\n new CodedError(errorCategory, firstErrorLine, {\n taskName: taskDoingName,\n }),\n );\n });\n }\n cp.on('error', (e) => {\n if (verbose) {\n console.error(chalk.red(e.toString()));\n }\n spinner.fail(e.toString());\n const ce = new CodedError(errorCategory, e.message);\n ce.stack = e.stack;\n reject(ce);\n }).on('close', (code) => {\n if (code === 0) {\n spinner.succeed(taskDoingName);\n resolve();\n } else {\n spinner.fail();\n reject(\n new CodedError(\n errorCategory,\n `${taskDoingName} - error code ${code}`,\n {\n errorCode: code,\n },\n ),\n );\n }\n });\n });\n}\n\nexport function newError(text: string) {\n newSpinner(text).fail(text);\n}\n\nexport function newWarn(text: string) {\n newSpinner(text).warn(text);\n}\n\nexport function newSuccess(text: string) {\n newSpinner(text).succeed(text);\n}\n\nexport function newInfo(text: string) {\n newSpinner(text).info(text);\n}\n\n/**\n * Sets the process exit code and offers some information at the end of a CLI command.\n * @param loggingIsEnabled Is verbose logging enabled.\n * @param error The error caught during the process, if any.\n */\nexport function setExitProcessWithError(\n loggingIsEnabled?: boolean,\n error?: Error,\n): void {\n if (error) {\n const errorType =\n error instanceof CodedError ? (error as CodedError).type : 'Unknown';\n\n process.exitCode = CodedErrors[errorType];\n\n if (loggingIsEnabled) {\n console.log(\n `Command failed with error ${chalk.bold(errorType)}: ${error.message}`,\n );\n if (Telemetry.isEnabled()) {\n console.log(\n `Your telemetry sessionId was ${chalk.bold(\n Telemetry.getSessionId(),\n )}`,\n );\n }\n } else {\n console.log(\n `Command failed. Re-run the command with ${chalk.bold(\n '--logging',\n )} for more information.`,\n );\n }\n }\n}\n"]}
1
+ {"version":3,"file":"commandWithProgress.js","sourceRoot":"","sources":["../../../src/runWindows/utils/commandWithProgress.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,iDAAkD;AAClD,8CAAsB;AACtB,gEAAoC;AACpC,kDAA0B;AAC1B,+DAKyC;AAEzC,SAAS,cAAc,CAAC,OAAgB,EAAE,MAAc,EAAE,IAAY;IACpE,IAAI,GAAG,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACpC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,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n */\n\nimport {spawn, SpawnOptions} from 'child_process';\nimport ora from 'ora';\nimport spinners from 'cli-spinners';\nimport chalk from 'chalk';\nimport {\n Telemetry,\n CodedError,\n CodedErrors,\n CodedErrorType,\n} from '@react-native-windows/telemetry';\n\nfunction setSpinnerText(spinner: ora.Ora, prefix: string, text: string) {\n text = prefix + spinnerString(text);\n spinner.text = text.length > 45 ? text.slice(0, 110) + '...' : text;\n}\n\nfunction spinnerString(msg: string) {\n msg = msg.trim();\n const lastLineIndex = msg.lastIndexOf('\\n');\n if (lastLineIndex > 0) {\n msg = msg.slice(lastLineIndex + 1);\n }\n msg = msg.trim();\n return msg;\n}\n\nexport function newSpinner(text: string) {\n const options: ora.Options = {\n text: text,\n indent: 1,\n\n // ora turns off emoji rendering by default on windows, since the default terminal\n // doesn't render them. Turn them back on when running in the new windows terminal\n ...(process.env.WT_SESSION && {spinner: spinners.dots}),\n\n // By default, ora process.stderr as the output stream, however,the VS Code debugger\n // Uses stdout to match success patterns\n stream: process.stdout,\n };\n\n return ora(options).start();\n}\n\nexport const powershell = `${process.env.SystemRoot}\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe`;\n\nexport async function runPowerShellScriptFunction(\n taskDescription: string,\n script: string | null,\n funcName: string,\n verbose: boolean,\n errorCategory: CodedErrorType,\n) {\n try {\n const printException = verbose ? '$_;' : '';\n const importScript = script ? `Import-Module \"${script}\"; ` : '';\n await commandWithProgress(\n newSpinner(taskDescription),\n taskDescription,\n powershell,\n [\n '-NoProfile',\n '-ExecutionPolicy',\n 'RemoteSigned',\n `${importScript}try { ${funcName} -ErrorAction Stop; $lec = $LASTEXITCODE; } catch { $lec = 1; ${printException} }; exit $lec`,\n ],\n verbose,\n errorCategory,\n );\n } catch {\n // The error output from the process will be shown if verbose is set.\n // We don't capture the process output if verbose is set, but at least we have the task name in text, so throw that.\n throw new CodedError(errorCategory, taskDescription);\n }\n}\n\nexport function commandWithProgress(\n spinner: ora.Ora,\n taskDoingName: string,\n command: string,\n args: string[],\n verbose: boolean,\n errorCategory: CodedErrorType,\n) {\n return new Promise<void>((resolve, reject) => {\n const spawnOptions: SpawnOptions = verbose ? {stdio: 'inherit'} : {};\n\n if (verbose) {\n spinner.stop();\n }\n\n const cp = spawn(command, args, spawnOptions);\n let firstErrorLine: string | null = null;\n if (!verbose) {\n cp.stdout!.on('data', (chunk) => {\n const text = chunk.toString();\n setSpinnerText(spinner, taskDoingName + ': ', text);\n });\n cp.stderr!.on('data', (chunk) => {\n const text: string = chunk.toString();\n if (!firstErrorLine) {\n firstErrorLine = text;\n }\n if (text) {\n setSpinnerText(spinner, taskDoingName + ': ERROR: ', firstErrorLine);\n }\n reject(\n new CodedError(errorCategory, firstErrorLine, {\n taskName: taskDoingName,\n }),\n );\n });\n }\n cp.on('error', (e) => {\n if (verbose) {\n console.error(chalk.red(e.toString()));\n }\n spinner.fail(e.toString());\n const ce = new CodedError(errorCategory, e.message);\n ce.stack = e.stack;\n reject(ce);\n }).on('close', (code) => {\n if (code === 0) {\n spinner.succeed(taskDoingName);\n resolve();\n } else {\n spinner.fail();\n reject(\n new CodedError(\n errorCategory,\n `${taskDoingName} - exit error code ${code}`,\n {\n taskName: taskDoingName,\n taskExitCode: code,\n },\n ),\n );\n }\n });\n });\n}\n\nexport function newError(text: string) {\n newSpinner(text).fail(text);\n}\n\nexport function newWarn(text: string) {\n newSpinner(text).warn(text);\n}\n\nexport function newSuccess(text: string) {\n newSpinner(text).succeed(text);\n}\n\nexport function newInfo(text: string) {\n newSpinner(text).info(text);\n}\n\n/**\n * Sets the process exit code and offers some information at the end of a CLI command.\n * @param loggingIsEnabled Is verbose logging enabled.\n * @param error The error caught during the process, if any.\n */\nexport function setExitProcessWithError(\n loggingIsEnabled?: boolean,\n error?: Error,\n): void {\n if (error) {\n const errorType =\n error instanceof CodedError ? (error as CodedError).type : 'Unknown';\n\n process.exitCode = CodedErrors[errorType];\n\n if (loggingIsEnabled) {\n console.log(\n `Command failed with error ${chalk.bold(errorType)}: ${error.message}`,\n );\n if (Telemetry.isEnabled()) {\n console.log(\n `Your telemetry sessionId was ${chalk.bold(\n Telemetry.getSessionId(),\n )}`,\n );\n }\n } else {\n console.log(\n `Command failed. Re-run the command with ${chalk.bold(\n '--logging',\n )} for more information.`,\n );\n }\n }\n}\n"]}
@@ -128,12 +128,23 @@ class MSBuildTools {
128
128
  }
129
129
  catch (e) {
130
130
  let error = e;
131
- if (!e) {
132
- const firstMessage = (await fs_1.default.readFile(errorLog))
133
- .toString()
134
- .split(os_1.EOL)[0];
135
- error = new telemetry_1.CodedError('MSBuildError', firstMessage);
136
- error.logfile = errorLog;
131
+ if (e instanceof telemetry_1.CodedError) {
132
+ const origCodedError = e;
133
+ if (origCodedError.type === 'MSBuildError') {
134
+ // Try to parse msbuild errors from errorLog
135
+ const errorLogContents = (await fs_1.default.readFile(errorLog))
136
+ .toString()
137
+ .split(os_1.EOL)
138
+ .filter((s) => s)
139
+ .map((s) => s.trim());
140
+ if (errorLogContents.length > 0) {
141
+ const firstMessage = errorLogContents[0];
142
+ error = new telemetry_1.CodedError('MSBuildError', firstMessage, origCodedError.data);
143
+ // Hide error messages in a field that won't automatically get reported
144
+ // with telemetry but is still available to be parsed and sanitized
145
+ error.msBuildErrorMessages = errorLogContents;
146
+ }
147
+ }
137
148
  }
138
149
  throw error;
139
150
  }
@@ -1 +1 @@
1
- {"version":3,"file":"msbuildtools.js","sourceRoot":"","sources":["../../../src/runWindows/utils/msbuildtools.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2BAAiC;AACjC,kEAA0C;AAC1C,gDAAwB;AACxB,kEAA0C;AAC1C,kDAA0B;AAC1B,4CAAoB;AACpB,sDAA4B;AAC5B,wDAAgC;AAChC,uEAAyD;AACzD,+DAO+B;AAC/B,iDAAuC;AAEvC,6CAAiD;AACjD,+DAA2D;AAE3D,MAAqB,YAAY;IAC/B;;;;OAIG;IACH,YACkB,OAAe,EACf,gBA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,IAAI,CAAC,KAAK,CAAC,aAAa,CAA2B,CAAC;YACvE,OAAO,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO,UAAU,CAAC;SACnB;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,IAAI,CACV,6CAA6C,GAAI,CAAW,CAAC,OAAO,CACrE,CAAC;YACF,MAAM,CAAC,CAAC;SACT;IACH,CAAC;CACF;AAtSD,+BAsSC;AAED,SAAS,gBAAgB,CAAC,SAAoB;IAC5C,QAAQ,SAAS,EAAE;QACjB,KAAK,KAAK,CAAC;QACX,KAAK,KAAK;YACR,OAAO,mDAAmD,CAAC;QAC7D,KAAK,OAAO;YACV,OAAO,iDAAiD,CAAC;KAC5D;AACH,CAAC;AAED,SAAS,0BAA0B;IACjC,MAAM,MAAM,GAAG,EAAE,CAAC;IAElB,MAAM,UAAU,GACd,wGAAwG,CAAC;IAC3G,IAAI,MAAM,CAAC;IACX,IAAI;QACF,MAAM,GAAG,IAAA,wBAAQ,EAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;KAC1C;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,MAAM,CAAC;KACf;IAED,MAAM,EAAE,GACN,0EAA0E,CAAC;IAC7E,MAAM,KAAK,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,IAAI,KAAK,EAAE;QACT,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;KACjB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {totalmem, EOL} from 'os';\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport child_process from 'child_process';\nimport chalk from 'chalk';\nimport os from 'os';\nimport shell from 'shelljs';\nimport Version from './version';\nimport * as checkRequirements from './checkRequirements';\nimport {\n commandWithProgress,\n newInfo,\n newSpinner,\n newSuccess,\n newError,\n powershell,\n} from './commandWithProgress';\nimport {execSync} from 'child_process';\nimport {BuildArch, BuildConfig} from '../runWindowsOptions';\nimport {findLatestVsInstall} from './vsInstalls';\nimport {CodedError} from '@react-native-windows/telemetry';\n\nexport default class MSBuildTools {\n /**\n * @param version is something like 16.0 for 2019\n * @param installationPath Path to installation root\n * @param installationVersion is the full version e.g. 16.3.29411.108\n */\n constructor(\n public readonly version: string,\n public readonly installationPath: string,\n public readonly installationVersion: string,\n ) {}\n\n /**\n * @returns directory where x86 msbuild can be found\n */\n msbuildPath() {\n return path.join(this.installationPath, 'MSBuild/Current/Bin');\n }\n\n cleanProject(slnFile: string) {\n const cmd = `\"${path.join(\n this.msbuildPath(),\n 'msbuild.exe',\n )}\" \"${slnFile}\" /t:Clean`;\n const results = child_process.execSync(cmd).toString().split(EOL);\n results.forEach((result) => console.log(chalk.white(result)));\n }\n\n async restorePackageConfigs(\n slnFile: any,\n buildArch: BuildArch,\n buildType: BuildConfig,\n ) {\n const text = 'Restoring NuGet packages ';\n const spinner = newSpinner(text);\n await commandWithProgress(\n spinner,\n text,\n path.join(this.msbuildPath(), 'msbuild.exe'),\n [\n slnFile,\n '/t:Restore',\n '/p:RestoreProjectStyle=PackagesConfig',\n '/p:RestorePackagesConfig=true',\n `/p:Platform=${buildArch}`,\n `/p:Configuration=${buildType}`,\n ],\n true,\n 'MSBuildError',\n );\n }\n\n async buildProject(\n slnFile: string,\n buildType: BuildConfig,\n buildArch: BuildArch,\n msBuildProps: Record<string, string>,\n verbose: boolean,\n target: 'build' | 'deploy',\n buildLogDirectory: string | undefined,\n singleproc?: boolean,\n ) {\n newSuccess(`Found Solution: ${slnFile}`);\n newInfo(`Build configuration: ${buildType}`);\n newInfo(`Build platform: ${buildArch}`);\n\n const verbosityOption = verbose ? 'normal' : 'minimal';\n const logPrefix = path.join(\n buildLogDirectory || os.tmpdir(),\n `msbuild_${process.pid}_${target}`,\n );\n\n const errorLog = logPrefix + '.err';\n const warnLog = logPrefix + '.wrn';\n\n const localBinLog = target === 'build' ? '' : ':deploy.binlog';\n const binlog = buildLogDirectory ? `:${logPrefix}.binlog` : localBinLog;\n\n const args = [\n `/clp:NoSummary;NoItemAndPropertyList;Verbosity=${verbosityOption}`,\n '/nologo',\n `/p:Configuration=${buildType}`,\n `/p:Platform=${buildArch}`,\n '/p:AppxBundle=Never',\n `/bl${binlog}`,\n `/flp1:errorsonly;logfile=${errorLog}`,\n `/flp2:warningsonly;logfile=${warnLog}`,\n ];\n\n // Building projects in parallel increases compiler memory usage and\n // doesn't lead to dramatic performance gains (See #4739). Only enable\n // parallel builds on machines with >16GB of memory to avoid OOM errors\n const highMemory = totalmem() > 16 * 1024 * 1024 * 1024;\n const enableParallelBuilds = singleproc === false || highMemory;\n\n if (enableParallelBuilds) {\n args.push('/maxCpuCount');\n }\n\n if (target === 'build') {\n args.push('/restore', '/p:RestorePackagesConfig=true');\n } else {\n args.push(`/t:Deploy`);\n }\n\n Object.keys(msBuildProps).forEach((key) => {\n args.push(`/p:${key}=${msBuildProps[key]}`);\n });\n\n try {\n checkRequirements.isWinSdkPresent('10.0');\n } catch (e) {\n newError((e as Error).message);\n throw e;\n }\n\n if (verbose) {\n console.log(`Running MSBuild with args ${args.join(' ')}`);\n }\n\n const progressName =\n target === 'deploy' ? 'Deploying Solution' : 'Building Solution';\n const spinner = newSpinner(progressName);\n try {\n await commandWithProgress(\n spinner,\n progressName,\n path.join(this.msbuildPath(), 'msbuild.exe'),\n [slnFile].concat(args),\n verbose,\n 'MSBuildError',\n );\n } catch (e) {\n let error = e;\n if (!e) {\n const firstMessage = (await fs.readFile(errorLog))\n .toString()\n .split(EOL)[0];\n error = new CodedError('MSBuildError', firstMessage);\n (error as any).logfile = errorLog;\n }\n throw error;\n }\n // If we have no errors, delete the error log when we're done\n if ((await fs.stat(errorLog)).size === 0) {\n await fs.unlink(errorLog);\n }\n }\n\n static findAvailableVersion(\n buildArch: BuildArch,\n verbose: boolean,\n prerelease?: boolean,\n ): MSBuildTools {\n // https://aka.ms/vs/workloads\n const requires = [\n 'Microsoft.Component.MSBuild',\n getVCToolsByArch(buildArch),\n ];\n const minVersion = process.env.VisualStudioVersion || '16.7';\n const vsInstallation = findLatestVsInstall({\n requires,\n minVersion,\n verbose,\n prerelease,\n });\n\n if (!vsInstallation) {\n if (process.env.VisualStudioVersion != null) {\n throw new CodedError(\n 'NoMSBuild',\n `MSBuild tools not found for version ${process.env.VisualStudioVersion} (from environment). Make sure all required components have been installed`,\n {VisualStudioVersionFromEnv: process.env.VisualStudioVersion},\n );\n } else {\n throw new CodedError(\n 'NoMSBuild',\n `Could not find MSBuild with VCTools for Visual Studio ${minVersion} or later. Make sure all required components have been installed`,\n {minVersion: minVersion},\n );\n }\n }\n\n const toolsPath = path.join(\n vsInstallation.installationPath,\n 'MSBuild/Current/Bin',\n );\n\n if (fs.existsSync(toolsPath)) {\n if (verbose) {\n newSuccess(\n `Found compatible MSBuild at ${toolsPath} (${vsInstallation.installationVersion})`,\n );\n }\n return new MSBuildTools(\n minVersion,\n vsInstallation.installationPath,\n vsInstallation.installationVersion,\n );\n } else {\n throw new CodedError(\n 'NoMSBuild',\n `MSBuild path '${toolsPath} does not exist'`,\n );\n }\n }\n\n static getAllAvailableUAPVersions(): Version[] {\n const results: Version[] = [];\n\n const programFilesFolder =\n process.env['ProgramFiles(x86)'] || process.env.ProgramFiles;\n // No Program Files folder found, so we won't be able to find UAP SDK\n if (!programFilesFolder) {\n return results;\n }\n\n let uapFolderPath = path.join(\n programFilesFolder,\n 'Windows Kits',\n '10',\n 'Platforms',\n 'UAP',\n );\n\n if (!shell.test('-e', uapFolderPath)) {\n // Check other installation folder from reg\n const sdkFolder = getSDK10InstallationFolder();\n if (sdkFolder) {\n uapFolderPath = path.join(sdkFolder, 'Platforms', 'UAP');\n }\n }\n\n // No UAP SDK exists on this machine\n if (!shell.test('-e', uapFolderPath)) {\n return results;\n }\n\n shell\n .ls(uapFolderPath)\n .filter((uapDir) => shell.test('-d', path.join(uapFolderPath, uapDir)))\n .map(Version.tryParse)\n .forEach((version) => version && results.push(version));\n\n return results;\n }\n\n evaluateMSBuildProperties(\n solutionFile: string,\n projectFile: string,\n propertyNames?: string[],\n extraMsBuildProps?: Record<string, string>,\n ): Record<string, string> {\n const spinner = newSpinner('Running Eval-MsBuildProperties.ps1');\n\n try {\n const msbuildEvalScriptPath = path.resolve(\n __dirname,\n '..',\n '..',\n '..',\n 'powershell',\n 'Eval-MsBuildProperties.ps1',\n );\n\n let command = `${powershell} -ExecutionPolicy Unrestricted -NoProfile \"${msbuildEvalScriptPath}\" -SolutionFile '${solutionFile}' -ProjectFile '${projectFile}' -MSBuildPath '${this.msbuildPath()}'`;\n\n if (propertyNames && propertyNames.length > 0) {\n command += ` -PropertyNames '${propertyNames.join(',')}'`;\n }\n\n if (extraMsBuildProps) {\n command += \" -ExtraMSBuildProps '\";\n for (const extraProp in extraMsBuildProps) {\n if (!(extraProp in Object.prototype)) {\n command += `,${extraProp}=${extraMsBuildProps[extraProp]}`;\n }\n }\n command += \"'\";\n }\n\n const commandOutput = execSync(command).toString();\n spinner.succeed();\n\n const properties = JSON.parse(commandOutput) as Record<string, string>;\n spinner.succeed();\n return properties;\n } catch (e) {\n spinner.fail(\n 'Running Eval-MsBuildProperties.ps1 failed: ' + (e as Error).message,\n );\n throw e;\n }\n }\n}\n\nfunction getVCToolsByArch(buildArch: BuildArch): string {\n switch (buildArch) {\n case 'x86':\n case 'x64':\n return 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64';\n case 'ARM64':\n return 'Microsoft.VisualStudio.Component.VC.Tools.ARM64';\n }\n}\n\nfunction getSDK10InstallationFolder(): string {\n const folder = '';\n\n const execString =\n 'reg query \"HKLM\\\\SOFTWARE\\\\Microsoft\\\\Microsoft SDKs\\\\Windows\\\\v10.0\" /s /v InstallationFolder /reg:32';\n let output;\n try {\n output = execSync(execString).toString();\n } catch (e) {\n return folder;\n }\n\n const re =\n /\\\\Microsoft SDKs\\\\Windows\\\\v10.0\\s*InstallationFolder\\s+REG_SZ\\s+(.*)/gim;\n const match = re.exec(output);\n if (match) {\n return match[1];\n }\n\n return folder;\n}\n"]}
1
+ {"version":3,"file":"msbuildtools.js","sourceRoot":"","sources":["../../../src/runWindows/utils/msbuildtools.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2BAAiC;AACjC,kEAA0C;AAC1C,gDAAwB;AACxB,kEAA0C;AAC1C,kDAA0B;AAC1B,4CAAoB;AACpB,sDAA4B;AAC5B,wDAAgC;AAChC,uEAAyD;AACzD,+DAO+B;AAC/B,iDAAuC;AAEvC,6CAAiD;AACjD,+DAA2D;AAE3D,MAAqB,YAAY;IAC/B;;;;OAIG;IACH,YACkB,OAAe,EACf,gBAAwB,EACxB,mBAA2B;QAF3B,YAAO,GAAP,OAAO,CAAQ;QACf,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,wBAAmB,GAAnB,mBAAmB,CAAQ;IAC1C,CAAC;IAEJ;;OAEG;IACH,WAAW;QACT,OAAO,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;IACjE,CAAC;IAED,YAAY,CAAC,OAAe;QAC1B,MAAM,GAAG,GAAG,IAAI,cAAI,CAAC,IAAI,CACvB,IAAI,CAAC,WAAW,EAAE,EAClB,aAAa,CACd,MAAM,OAAO,YAAY,CAAC;QAC3B,MAAM,OAAO,GAAG,uBAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,QAAG,CAAC,CAAC;QAClE,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,qBAAqB,CACzB,OAAY,EACZ,SAAoB,EACpB,SAAsB;QAEtB,MAAM,IAAI,GAAG,2BAA2B,CAAC;QACzC,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;YACR,OAAO,mDAAmD,CAAC;QAC7D,KAAK,OAAO;YACV,OAAO,iDAAiD,CAAC;KAC5D;AACH,CAAC;AAED,SAAS,0BAA0B;IACjC,MAAM,MAAM,GAAG,EAAE,CAAC;IAElB,MAAM,UAAU,GACd,wGAAwG,CAAC;IAC3G,IAAI,MAAM,CAAC;IACX,IAAI;QACF,MAAM,GAAG,IAAA,wBAAQ,EAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;KAC1C;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,MAAM,CAAC;KACf;IAED,MAAM,EAAE,GACN,0EAA0E,CAAC;IAC7E,MAAM,KAAK,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,IAAI,KAAK,EAAE;QACT,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;KACjB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {totalmem, EOL} from 'os';\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport child_process from 'child_process';\nimport chalk from 'chalk';\nimport os from 'os';\nimport shell from 'shelljs';\nimport Version from './version';\nimport * as checkRequirements from './checkRequirements';\nimport {\n commandWithProgress,\n newInfo,\n newSpinner,\n newSuccess,\n newError,\n powershell,\n} from './commandWithProgress';\nimport {execSync} from 'child_process';\nimport {BuildArch, BuildConfig} from '../runWindowsOptions';\nimport {findLatestVsInstall} from './vsInstalls';\nimport {CodedError} from '@react-native-windows/telemetry';\n\nexport default class MSBuildTools {\n /**\n * @param version is something like 16.0 for 2019\n * @param installationPath Path to installation root\n * @param installationVersion is the full version e.g. 16.3.29411.108\n */\n constructor(\n public readonly version: string,\n public readonly installationPath: string,\n public readonly installationVersion: string,\n ) {}\n\n /**\n * @returns directory where x86 msbuild can be found\n */\n msbuildPath() {\n return path.join(this.installationPath, 'MSBuild/Current/Bin');\n }\n\n cleanProject(slnFile: string) {\n const cmd = `\"${path.join(\n this.msbuildPath(),\n 'msbuild.exe',\n )}\" \"${slnFile}\" /t:Clean`;\n const results = child_process.execSync(cmd).toString().split(EOL);\n results.forEach((result) => console.log(chalk.white(result)));\n }\n\n async restorePackageConfigs(\n slnFile: any,\n buildArch: BuildArch,\n buildType: BuildConfig,\n ) {\n const text = 'Restoring NuGet packages ';\n const spinner = newSpinner(text);\n await commandWithProgress(\n spinner,\n text,\n path.join(this.msbuildPath(), 'msbuild.exe'),\n [\n slnFile,\n '/t:Restore',\n '/p:RestoreProjectStyle=PackagesConfig',\n '/p:RestorePackagesConfig=true',\n `/p:Platform=${buildArch}`,\n `/p:Configuration=${buildType}`,\n ],\n true,\n 'MSBuildError',\n );\n }\n\n async buildProject(\n slnFile: string,\n buildType: BuildConfig,\n buildArch: BuildArch,\n msBuildProps: Record<string, string>,\n verbose: boolean,\n target: 'build' | 'deploy',\n buildLogDirectory: string | undefined,\n singleproc?: boolean,\n ) {\n newSuccess(`Found Solution: ${slnFile}`);\n newInfo(`Build configuration: ${buildType}`);\n newInfo(`Build platform: ${buildArch}`);\n\n const verbosityOption = verbose ? 'normal' : 'minimal';\n const logPrefix = path.join(\n buildLogDirectory || os.tmpdir(),\n `msbuild_${process.pid}_${target}`,\n );\n\n const errorLog = logPrefix + '.err';\n const warnLog = logPrefix + '.wrn';\n\n const localBinLog = target === 'build' ? '' : ':deploy.binlog';\n const binlog = buildLogDirectory ? `:${logPrefix}.binlog` : localBinLog;\n\n const args = [\n `/clp:NoSummary;NoItemAndPropertyList;Verbosity=${verbosityOption}`,\n '/nologo',\n `/p:Configuration=${buildType}`,\n `/p:Platform=${buildArch}`,\n '/p:AppxBundle=Never',\n `/bl${binlog}`,\n `/flp1:errorsonly;logfile=${errorLog}`,\n `/flp2:warningsonly;logfile=${warnLog}`,\n ];\n\n // Building projects in parallel increases compiler memory usage and\n // doesn't lead to dramatic performance gains (See #4739). Only enable\n // parallel builds on machines with >16GB of memory to avoid OOM errors\n const highMemory = totalmem() > 16 * 1024 * 1024 * 1024;\n const enableParallelBuilds = singleproc === false || highMemory;\n\n if (enableParallelBuilds) {\n args.push('/maxCpuCount');\n }\n\n if (target === 'build') {\n args.push('/restore', '/p:RestorePackagesConfig=true');\n } else {\n args.push(`/t:Deploy`);\n }\n\n Object.keys(msBuildProps).forEach((key) => {\n args.push(`/p:${key}=${msBuildProps[key]}`);\n });\n\n try {\n checkRequirements.isWinSdkPresent('10.0');\n } catch (e) {\n newError((e as Error).message);\n throw e;\n }\n\n if (verbose) {\n console.log(`Running MSBuild with args ${args.join(' ')}`);\n }\n\n const progressName =\n target === 'deploy' ? 'Deploying Solution' : 'Building Solution';\n const spinner = newSpinner(progressName);\n try {\n await commandWithProgress(\n spinner,\n progressName,\n path.join(this.msbuildPath(), 'msbuild.exe'),\n [slnFile].concat(args),\n verbose,\n 'MSBuildError',\n );\n } catch (e) {\n let error = e;\n if (e instanceof CodedError) {\n const origCodedError = e as CodedError;\n if (origCodedError.type === 'MSBuildError') {\n // Try to parse msbuild errors from errorLog\n const errorLogContents = (await fs.readFile(errorLog))\n .toString()\n .split(EOL)\n .filter((s) => s)\n .map((s) => s.trim());\n if (errorLogContents.length > 0) {\n const firstMessage = errorLogContents[0];\n error = new CodedError(\n 'MSBuildError',\n firstMessage,\n origCodedError.data,\n );\n // Hide error messages in a field that won't automatically get reported\n // with telemetry but is still available to be parsed and sanitized\n (error as any).msBuildErrorMessages = errorLogContents;\n }\n }\n }\n throw error;\n }\n // If we have no errors, delete the error log when we're done\n if ((await fs.stat(errorLog)).size === 0) {\n await fs.unlink(errorLog);\n }\n }\n\n static findAvailableVersion(\n buildArch: BuildArch,\n verbose: boolean,\n prerelease?: boolean,\n ): MSBuildTools {\n // https://aka.ms/vs/workloads\n const requires = [\n 'Microsoft.Component.MSBuild',\n getVCToolsByArch(buildArch),\n ];\n const minVersion = process.env.VisualStudioVersion || '16.7';\n const vsInstallation = findLatestVsInstall({\n requires,\n minVersion,\n verbose,\n prerelease,\n });\n\n if (!vsInstallation) {\n if (process.env.VisualStudioVersion != null) {\n throw new CodedError(\n 'NoMSBuild',\n `MSBuild tools not found for version ${process.env.VisualStudioVersion} (from environment). Make sure all required components have been installed`,\n {VisualStudioVersionFromEnv: process.env.VisualStudioVersion},\n );\n } else {\n throw new CodedError(\n 'NoMSBuild',\n `Could not find MSBuild with VCTools for Visual Studio ${minVersion} or later. Make sure all required components have been installed`,\n {minVersion: minVersion},\n );\n }\n }\n\n const toolsPath = path.join(\n vsInstallation.installationPath,\n 'MSBuild/Current/Bin',\n );\n\n if (fs.existsSync(toolsPath)) {\n if (verbose) {\n newSuccess(\n `Found compatible MSBuild at ${toolsPath} (${vsInstallation.installationVersion})`,\n );\n }\n return new MSBuildTools(\n minVersion,\n vsInstallation.installationPath,\n vsInstallation.installationVersion,\n );\n } else {\n throw new CodedError(\n 'NoMSBuild',\n `MSBuild path '${toolsPath} does not exist'`,\n );\n }\n }\n\n static getAllAvailableUAPVersions(): Version[] {\n const results: Version[] = [];\n\n const programFilesFolder =\n process.env['ProgramFiles(x86)'] || process.env.ProgramFiles;\n // No Program Files folder found, so we won't be able to find UAP SDK\n if (!programFilesFolder) {\n return results;\n }\n\n let uapFolderPath = path.join(\n programFilesFolder,\n 'Windows Kits',\n '10',\n 'Platforms',\n 'UAP',\n );\n\n if (!shell.test('-e', uapFolderPath)) {\n // Check other installation folder from reg\n const sdkFolder = getSDK10InstallationFolder();\n if (sdkFolder) {\n uapFolderPath = path.join(sdkFolder, 'Platforms', 'UAP');\n }\n }\n\n // No UAP SDK exists on this machine\n if (!shell.test('-e', uapFolderPath)) {\n return results;\n }\n\n shell\n .ls(uapFolderPath)\n .filter((uapDir) => shell.test('-d', path.join(uapFolderPath, uapDir)))\n .map(Version.tryParse)\n .forEach((version) => version && results.push(version));\n\n return results;\n }\n\n evaluateMSBuildProperties(\n solutionFile: string,\n projectFile: string,\n propertyNames?: string[],\n extraMsBuildProps?: Record<string, string>,\n ): Record<string, string> {\n const spinner = newSpinner('Running Eval-MsBuildProperties.ps1');\n\n try {\n const msbuildEvalScriptPath = path.resolve(\n __dirname,\n '..',\n '..',\n '..',\n 'powershell',\n 'Eval-MsBuildProperties.ps1',\n );\n\n let command = `${powershell} -ExecutionPolicy Unrestricted -NoProfile \"${msbuildEvalScriptPath}\" -SolutionFile '${solutionFile}' -ProjectFile '${projectFile}' -MSBuildPath '${this.msbuildPath()}'`;\n\n if (propertyNames && propertyNames.length > 0) {\n command += ` -PropertyNames '${propertyNames.join(',')}'`;\n }\n\n if (extraMsBuildProps) {\n command += \" -ExtraMSBuildProps '\";\n for (const extraProp in extraMsBuildProps) {\n if (!(extraProp in Object.prototype)) {\n command += `,${extraProp}=${extraMsBuildProps[extraProp]}`;\n }\n }\n command += \"'\";\n }\n\n const commandOutput = execSync(command).toString();\n spinner.succeed();\n\n const properties = JSON.parse(commandOutput) as Record<string, string>;\n spinner.succeed();\n return properties;\n } catch (e) {\n spinner.fail(\n 'Running Eval-MsBuildProperties.ps1 failed: ' + (e as Error).message,\n );\n throw e;\n }\n }\n}\n\nfunction getVCToolsByArch(buildArch: BuildArch): string {\n switch (buildArch) {\n case 'x86':\n case 'x64':\n return 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64';\n case 'ARM64':\n return 'Microsoft.VisualStudio.Component.VC.Tools.ARM64';\n }\n}\n\nfunction getSDK10InstallationFolder(): string {\n const folder = '';\n\n const execString =\n 'reg query \"HKLM\\\\SOFTWARE\\\\Microsoft\\\\Microsoft SDKs\\\\Windows\\\\v10.0\" /s /v InstallationFolder /reg:32';\n let output;\n try {\n output = execSync(execString).toString();\n } catch (e) {\n return folder;\n }\n\n const re =\n /\\\\Microsoft SDKs\\\\Windows\\\\v10.0\\s*InstallationFolder\\s+REG_SZ\\s+(.*)/gim;\n const match = re.exec(output);\n if (match) {\n return match[1];\n }\n\n return folder;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-windows/cli",
3
- "version": "0.68.1",
3
+ "version": "0.68.2",
4
4
  "license": "MIT",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "repository": {
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "@react-native-windows/fs": "0.68.0",
21
21
  "@react-native-windows/package-utils": "0.68.0",
22
- "@react-native-windows/telemetry": "0.68.1",
22
+ "@react-native-windows/telemetry": "0.68.2",
23
23
  "@xmldom/xmldom": "^0.7.5",
24
24
  "chalk": "^4.1.0",
25
25
  "cli-spinners": "^2.2.0",