Skip to content
Open
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
2 changes: 1 addition & 1 deletion .ado/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function ensureNuGet(toolsPath) {
ensureDir(toolsPath);
console.log(`Downloading nuget.exe to: ${localNuGet}`);
execSync(
`powershell.exe -NoLogo -NoProfile -Command ` +
`pwsh.exe -NoLogo -NoProfile -Command ` +
`"[Net.ServicePointManager]::SecurityProtocol = ` +
`[Net.SecurityProtocolType]::Tls12; ` +
`Invoke-WebRequest -Uri 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe' ` +
Expand Down
4 changes: 4 additions & 0 deletions .ado/templates/yarn-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ parameters:
default: .

steps:
- task: NuGetToolInstaller@1
inputs:
versionSpec: ">=5.8.0"

- script: yarn --cwd ${{ parameters.workingDirectory }} install --immutable
displayName: yarn install (immutable)
retryCountOnTaskFailure: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Upgrade to PowerShell 7",
"packageName": "@react-native-windows/cli",
"email": "julio.rocha@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Upgrade to PowerShell 7",
"packageName": "react-native-windows",
"email": "julio.rocha@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
* @format
*/

import {spawn, SpawnOptions} from 'child_process';
import {execSync, spawn, SpawnOptions} from 'child_process';
import fs from 'fs';
import os from 'os';
import path from 'path';
import ora from 'ora';
import spinners from 'cli-spinners';
import chalk from 'chalk';
Expand Down Expand Up @@ -47,7 +50,47 @@ export function newSpinner(text: string) {
return ora(options).start();
}

export const powershell = `${process.env.SystemRoot}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
function getGlobalNuGetPackagesFolder(): string {
if (process.env.NUGET_PACKAGES) {
return process.env.NUGET_PACKAGES;
}
try {
const output = execSync('nuget locals global-packages -list', {
encoding: 'utf8',
}).trim();
const match = output.match(/global-packages:\s*(.+)/i);
if (match) {
return match[1].trim();
}
} catch {}
return path.join(os.homedir(), '.nuget', 'packages');
}

function findPwsh(): string {
const nugetPackages = getGlobalNuGetPackagesFolder();
const nugetPwsh = path.join(
nugetPackages,
'PowerShell.7.6.1',
'tools',
'net8.0',
'any',
'pwsh.exe',
);
if (fs.existsSync(nugetPwsh)) {
return nugetPwsh;
}

try {
const found = execSync('where pwsh.exe', {encoding: 'utf8'}).trim();
if (found) {
return found.split(/\r?\n/)[0];
}
} catch {}

return `${process.env.SystemRoot}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
}

export const powershell = findPwsh();

export async function runPowerShellScriptFunction(
taskDescription: string,
Expand Down

This file was deleted.

Loading
Loading