Skip to content

Commit

Permalink
Upgrade to VS 2022 (#9916)
Browse files Browse the repository at this point in the history
*Description*

This PR updates RNW to build with (and require) Visual Studio 2022. This includes upgrading the `Microsoft.ReactNative.Managed.CodeGen` project to .NET 6.0

This PR does not change the minimum / target Windows SDK versions for RNW or RNW apps.

This PR does not change the language versions of C++ (17) and C# (8.0) used.

*Type of Change*
- Breaking change (fix or feature that would cause existing functionality to not work as expected)
- This change requires a documentation update

*Why*
Visual Studio 2022 is the currently supported version of Visual Studio and what is available to download without an MSDN subscription to access older versions. As Visual Studio 2019 support is reduced/deprecated, we need to migrate. 

Closes #8750
Closes #9499 
Closes #10130

*What*

What's changed:

* All VS project files have been updated to require a minimum of VS 2022 (aka version 17.0).
    * NuGet-based dependencies that are tied to VS version have been upgraded.
* The `Microsoft.ReactNative.Managed.CodeGen` project has been updated to .NET 6.0
    * The snapshots for the codegen tests have been updated to pass
* The E2E Test app has been updated to the latest version of `react-native-xaml` (needed to fix build issues)
    * Snapshots for E2E tests have been updated to pass

*Testing*

Builds and tests All tests
  • Loading branch information
jonthysell authored Oct 31, 2022
1 parent 10e9788 commit 5885ee4
Show file tree
Hide file tree
Showing 152 changed files with 967 additions and 832 deletions.
4 changes: 2 additions & 2 deletions .ado/compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ parameters:
default:
Medium:
name: rnw-pool-4-microsoft
demands: ImageOverride -equals rnw-img-node16
demands: ImageOverride -equals rnw-img-vs2022
Large:
name: rnw-pool-8-microsoft
demands: ImageOverride -equals rnw-img-node16
demands: ImageOverride -equals rnw-img-vs2022
- name: forceCodeQL
displayName: Force CodeQL to rebuild databases
type: boolean
Expand Down
6 changes: 3 additions & 3 deletions .ado/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ parameters:
default:
Small:
name: rnw-pool-2
demands: ImageOverride -equals rnw-img-node16
demands: ImageOverride -equals rnw-img-vs2022
Medium:
name: rnw-pool-4
demands: ImageOverride -equals rnw-img-node16
demands: ImageOverride -equals rnw-img-vs2022
Large:
name: rnw-pool-8
demands: ImageOverride -equals rnw-img-node16
demands: ImageOverride -equals rnw-img-vs2022

stages:
- template: stages.yml
Expand Down
62 changes: 46 additions & 16 deletions .ado/image/rnw-pool.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,71 @@
{
"imageType": "Managed",
"baseImage": "/MicrosoftWindowsServer/WindowsServer/2019-Datacenter/latest",
"baseImage": "/MicrosoftWindowsServer/WindowsServer/2022-Datacenter/latest",
"artifacts": [
{
"Name": "windows-EnableDeveloperMode"
"name": "windows-EnableDeveloperMode"
},
{
"Name": "windows-enable-long-paths"
"name": "windows-enable-long-paths"
},
{
"Name": "windows-gitinstall"
"name": "windows-gitinstall"
},
{
"Name": "windows-AzPipeline-ImageHelpers"
"name": "windows-AzPipeline-ImageHelpers"
},
{
"Name": "windows-AzPipeline-InitializeVM"
"name": "windows-AzPipeline-InitializeVM"
},
{
"Name": "windows-AzPipeline-Install-VS",
"Parameters": {
"ToolSetFileName": "2019-default.json"
"name": "windows-AzPipeline-powershellCore"
},
{
"name": "windows-AzPipeline-7zip"
},
{
"name": "windows-visualstudio-bootstrapper",
"parameters": {
"Workloads": "--add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Workload.Universal --add Microsoft.Component.MSBuild --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.ComponentGroup.UWP.Support --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core --add Microsoft.VisualStudio.Component.Windows10SDK.19041 --add Microsoft.VisualStudio.ComponentGroup.UWP.VC --includeRecommended --includeOptional",
"SKU": "Enterprise",
"VSBootstrapperURL": "https://aka.ms/vs/17/release/vs_Enterprise.exe"
}
},
{
"name": "Windows-NodeJS",
"parameters": {
"Version": "16.13.0"
}
},
{
"Name": "windows-AzPipeline-NodeLts"
"name": "windows-npm-global",
"parameters": {
"packages": "[email protected], [email protected], [email protected]",
"addToPath": true
}
},
{
"name": "windows-chrome"
},
{
"Name": "windows-chrome"
"name": "windows-AzPipeline-WinAppDriver"
},
{
"Name": "windows-AzPipeline-WinAppDriver"
"name": "windows-dotnetcore-sdk",
"parameters": {
"DotNetCoreVersion": "2.1.818"
}
},
{
"name": "windows-dotnetcore-sdk",
"parameters": {
"DotNetCoreVersion": "3.1.412"
}
},
{
"Name": "windows-dotnetcore-sdk",
"Parameters": {
"DotNetCoreVersion": "3.1.401"
"name": "windows-dotnetcore-sdk",
"parameters": {
"DotNetCoreVersion": "6.0.401"
}
}
],
Expand All @@ -47,4 +77,4 @@
}
]
}
}
}
2 changes: 1 addition & 1 deletion .ado/integrate-rn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ variables:
- group: RNW Secrets

pool:
vmImage: windows-2019
vmImage: windows-2022

jobs:
- job: IntegrateRN
Expand Down
4 changes: 2 additions & 2 deletions .ado/jobs/desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ jobs:
value: false

#5059 - Disable failing or intermittent tests (IntegrationTestHarness,AsyncStorage,WebSocket,Logging).
#5265 - WebSocketModuleIntegrationTest::WebSocketModule_Ping fails for Release
#10732 - WebSocketIntegrationTest::SendReceiveSsl fails on Windows Server 2022.
- name: Desktop.IntegrationTests.Filter
value: >
(FullyQualifiedName!=RNTesterIntegrationTests::AsyncStorage)&
(FullyQualifiedName!=RNTesterIntegrationTests::Blob)&
(FullyQualifiedName!=RNTesterIntegrationTests::IntegrationTestHarness)&
(FullyQualifiedName!=WebSocketResourcePerformanceTest::ProcessThreadsPerResource)&
(FullyQualifiedName!=WebSocketIntegrationTest::SendReceiveSsl)&
(FullyQualifiedName!=Microsoft::React::Test::HttpOriginPolicyIntegrationTest)
#6799 -
# HostFunctionTest - Crashes under JSI/V8
# HostObjectProtoTest - Crashes under JSI/V8
Expand Down
4 changes: 2 additions & 2 deletions .ado/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ parameters:
default:
Medium:
name: rnw-pool-4-microsoft
demands: ImageOverride -equals rnw-img-node16
demands: ImageOverride -equals rnw-img-vs2022
Large:
name: rnw-pool-8-microsoft
demands: ImageOverride -equals rnw-img-node16
demands: ImageOverride -equals rnw-img-vs2022

variables:
- template: variables/windows.yml
Expand Down
2 changes: 1 addition & 1 deletion .ado/templates/discover-google-test-adapter.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
steps:

- powershell: |
$vsExtensionPath="${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\";
$vsExtensionPath="${env:ProgramFiles}\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\";
$GoogleTestAdapterPath=(Get-ChildItem $vsExtensionPath -Directory | Where-Object -FilterScript {Test-Path (Join-Path -Path $_.FullName -ChildPath "GoogleTestAdapter.Core.dll")}).FullName
# Test the path to the google test adapter
Expand Down
4 changes: 2 additions & 2 deletions .ado/templates/msbuild-sln.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ parameters:
# NuGet & MSBuild
solutionDir:
solutionName:
msbuildVersion: 16.0
msbuildVersion: 17.0
msBuildArchitecture: x64
preferredToolArchitecture: x64
platformToolset: v142
platformToolset: v143
buildPlatform: x64
buildConfiguration: Debug
msbuildArguments: ''
Expand Down
6 changes: 3 additions & 3 deletions .ado/windows-vs-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ parameters:
default:
Small:
name: rnw-pool-2
demands: ImageOverride -equals rnw-img-node16
demands: ImageOverride -equals rnw-img-vs2022
Medium:
name: rnw-pool-4
demands: ImageOverride -equals rnw-img-node16
demands: ImageOverride -equals rnw-img-vs2022
Large:
name: rnw-pool-8
demands: ImageOverride -equals rnw-img-node16
demands: ImageOverride -equals rnw-img-vs2022

stages:
- template: stages.yml
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Upgrade to VS 2022",
"packageName": "@react-native-windows/automation-channel",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Upgrade to VS 2022",
"packageName": "@react-native-windows/automation",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Upgrade to VS 2022",
"packageName": "@react-native-windows/cli",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Upgrade to VS 2022",
"packageName": "@react-native-windows/telemetry",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Upgrade to VS 2022",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
2 changes: 1 addition & 1 deletion docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ When contributing to this project, unit and integration tests should be run to h

## Windows Desktop
Tests should be run with a VSTest-compatible client
(i.e. [VSTest.Console.exe](https://docs.microsoft.com/en-us/visualstudio/test/vstest-console-options?view=vs-2019),
(i.e. [VSTest.Console.exe](https://docs.microsoft.com/en-us/visualstudio/test/vstest-console-options?view=vs-2022),
[Visual Studio Test task](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/vstest?view=azure-devops)).
This project includes convenience scripts to set up and run the test artifacts.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29215.179
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AutomationChannel", "AutomationChannel\AutomationChannel.vcxproj", "{C0A69310-6119-46DC-A6D6-0BAB7826DC92}"
ProjectSection(ProjectDependencies) = postProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ProjectName>AutomationChannel</ProjectName>
<RootNamespace>AutomationChannel</RootNamespace>
<DefaultLanguage>en-US</DefaultLanguage>
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
<MinimumVisualStudioVersion>17.0</MinimumVisualStudioVersion>
<AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
Expand Down Expand Up @@ -139,7 +139,7 @@
<None Include="PropertySheet.props" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CppWinRT" Version="$(CppWinRTVersion)" />
<PackageReference Include="Microsoft.Windows.CppWinRT" Version="$(CppWinRTVersion)" PrivateAssets="all" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ReactNativeWindowsTargets">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,23 @@ export const app = {
/**
* Find an element by Automation ID
*
* https://docs.microsoft.com/en-us/dotnet/api/system.windows.automation.automationelement.automationelementinformation.automationid?view=net-5.0
* https://docs.microsoft.com/en-us/dotnet/api/system.windows.automation.automationelement.automationelementinformation.automationid?view=net-6.0
*/
findElementByAutomationID: (id: string): Promise<AutomationElement> =>
$(`~${id}`),

/**
* Finds an element by the name of its class name (e.g. ListViewItem)
*
* https://docs.microsoft.com/en-us/dotnet/api/system.windows.automation.automationelement.automationelementinformation.classname?view=net-5.0
* https://docs.microsoft.com/en-us/dotnet/api/system.windows.automation.automationelement.automationelementinformation.classname?view=net-6.0
*/
findElementByClassName: (className: string): Promise<AutomationElement> =>
$(className),

/**
* Find element by ControlType (e.g. Button, CheckBox)
*
* https://docs.microsoft.com/en-us/dotnet/api/system.windows.automation.controltype?view=net-5.0
* https://docs.microsoft.com/en-us/dotnet/api/system.windows.automation.controltype?view=net-6.0
*/
findElementByControlType: (controlType: string): Promise<AutomationElement> =>
$(`<${controlType} />`),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const bundleDir = 'Bundle';
interface NugetPackage {
id: string;
version: string;
privateAssets: boolean;
}

function pascalCase(str: string) {
Expand Down Expand Up @@ -175,6 +176,7 @@ export async function copyProjectTemplateAndReplace(
{
id: 'Microsoft.Windows.CppWinRT',
version: '2.0.211028.7',
privateAssets: true,
},
];

Expand Down Expand Up @@ -463,6 +465,7 @@ function getUwpCsPackages(): NugetPackage[] {
{
id: 'Microsoft.NETCore.UniversalWindowsPlatform',
version: '6.2.9',
privateAssets: false,
},
];
}
Expand Down Expand Up @@ -541,11 +544,13 @@ function getWinAppSDKPackages(nugetVersion: string): NugetPackage[] {
winAppSDKPackages.push({
id: 'Microsoft.ReactNative.WindowsAppSDK',
version: nugetVersion,
privateAssets: false,
});

winAppSDKPackages.push({
id: 'Microsoft.WindowsAppSDK',
version: '1.1.4',
version: '1.1.5',
privateAssets: false,
});

return winAppSDKPackages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import {CodedError} from '@react-native-windows/telemetry';

export default class MSBuildTools {
/**
* @param version is something like 16.0 for 2019
* @param version is something like 17.0 for 2022
* @param installationPath Path to installation root
* @param installationVersion is the full version e.g. 16.3.29411.108
* @param installationVersion is the full version e.g. 17.3.32929.385
*/
constructor(
public readonly version: string,
Expand Down Expand Up @@ -200,7 +200,7 @@ export default class MSBuildTools {
'Microsoft.Component.MSBuild',
getVCToolsByArch(buildArch),
];
const minVersion = process.env.VisualStudioVersion || '16.7';
const minVersion = process.env.VisualStudioVersion || '17.0';
const vsInstallation = findLatestVsInstall({
requires,
minVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
<MinimumVisualStudioVersion>17.0</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
Expand Down Expand Up @@ -136,8 +136,8 @@
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '16.0' ">
<VisualStudioVersion>16.0</VisualStudioVersion>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '17.0' ">
<VisualStudioVersion>17.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<ImportGroup Label="ReactNativeWindowsPropertySheets">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ProjectName>UsesPackagesConfig</ProjectName>
<RootNamespace>UsesPackagesConfig</RootNamespace>
<DefaultLanguage>en-US</DefaultLanguage>
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
<MinimumVisualStudioVersion>17.0</MinimumVisualStudioVersion>
<AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
Expand Down
Loading

0 comments on commit 5885ee4

Please sign in to comment.