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
2 changes: 1 addition & 1 deletion dev/Package/M.W.A.Package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace winrt::Microsoft::Windows::ApplicationModel::implementation

bool Package::IsFeatureSupported(winrt::Microsoft::Windows::ApplicationModel::PackageFeature const& feature)
{
return ::IsPackageFeatureSupported(static_cast<::PackageFeature>(feature));
return ::WindowsAppRuntime_IsPackageFeatureSupported(static_cast<::PackageFeature>(feature));
}
hstring Package::GetFilePath(hstring const& filename)
{
Expand Down
6 changes: 3 additions & 3 deletions dev/Package/package_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ namespace appmodel
static bool IsPathSupported_Mutable()
{
// Cache the answer on first query
static bool s_isSupported{ !!::IsPackageFeatureSupported(PackageFeature_PackagePath_Mutable) };
static bool s_isSupported{ !!::WindowsAppRuntime_IsPackageFeatureSupported(PackageFeature_PackagePath_Mutable) };
return s_isSupported;
}

static bool IsPathSupported_ExternalLocation()
{
// Cache the answer on first query
static bool s_isSupported{ !!::IsPackageFeatureSupported(PackageFeature_PackagePath_ExternalLocation) };
static bool s_isSupported{ !!::WindowsAppRuntime_IsPackageFeatureSupported(PackageFeature_PackagePath_ExternalLocation) };
return s_isSupported;
}

Expand Down Expand Up @@ -322,7 +322,7 @@ inline GetPackageFilePathOptions ToEffectiveOptions(
}
}

STDAPI_(BOOL) IsPackageFeatureSupported(
STDAPI_(BOOL) WindowsAppRuntime_IsPackageFeatureSupported(
PackageFeature feature) noexcept
{
switch (feature)
Expand Down
4 changes: 2 additions & 2 deletions dev/Package/package_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define PACKAGE_RUNTIME_H

/// Features can be queried if currently available/enabled.
/// @see IsPackageFeatureSupported()
/// @see WindowsAppRuntime_IsPackageFeatureSupported()
typedef enum PackageFeature
{
/// Package Mutable path.
Expand All @@ -19,7 +19,7 @@ typedef enum PackageFeature
} PackageFeature;

/// Return TRUE if feature is supported on the current system.
STDAPI_(BOOL) IsPackageFeatureSupported(
STDAPI_(BOOL) WindowsAppRuntime_IsPackageFeatureSupported(
PackageFeature feature) noexcept;

/// Options for GetPackageFilePath*() functions
Expand Down
4 changes: 3 additions & 1 deletion dev/WindowsAppRuntime_DLL/WindowsAppRuntime.def
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ EXPORTS

GetPackageFilePath
GetPackageFilePathInPackageGraph
IsPackageFeatureSupported
; Preserve existing binary imports without exposing the Windows SDK name in the import library.
IsPackageFeatureSupported = WindowsAppRuntime_IsPackageFeatureSupported PRIVATE
WindowsAppRuntime_IsPackageFeatureSupported
8 changes: 6 additions & 2 deletions docs/Coding-Guidelines/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Development requires the following installation:

1. Install Visual Studio 2022
1. Install Visual Studio 2022 or 2026

Select the following workloads:
* .NET desktop development
Expand All @@ -13,11 +13,15 @@ Development requires the following installation:

Additional components are quired. To add them via the Visual Studio Installer...
* select `More` / `Import configuration`
* select the file `docs\Coding-Guidelines\VisualStudio2022.vsconfig` in the repository
* select the matching file `docs\Coding-Guidelines\VisualStudio2022.vsconfig` or `VisualStudio2026.vsconfig` in the repository
* select `Review details`
* select `Modify`
and wait for the install to complete.

Visual Studio 2026 also needs the v143 (VS 2022 17.14) C++ toolset and Spectre-mitigated
libraries included in its configuration file; the SDK projects still target v143.
DevCheck validates components in the newest supported installation with C++ build tools.

2. Run `DevCheck -CheckAll -FixAll` from an admin prompt to verify your configuration and perform
additional installation and configuration updates (if necessary). See `One-Time Setup` for more details.

Expand Down
5 changes: 0 additions & 5 deletions docs/Coding-Guidelines/VisualStudio2022.vsconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"Microsoft.VisualStudio.Component.NuGet",
"Microsoft.VisualStudio.Component.Roslyn.Compiler",
"Microsoft.Component.MSBuild",
"Microsoft.NetCore.Component.Runtime.6.0",
"Microsoft.NetCore.Component.Runtime.7.0",
"Microsoft.NetCore.Component.SDK",
"Microsoft.Net.Component.4.7.2.TargetingPack",
"Microsoft.VisualStudio.Component.Roslyn.LanguageServices",
Expand All @@ -30,10 +28,7 @@
"Microsoft.VisualStudio.Component.IntelliTrace.FrontEnd",
"Microsoft.VisualStudio.Component.DiagnosticTools",
"Microsoft.VisualStudio.Component.EntityFramework",
"Microsoft.VisualStudio.Component.LiveUnitTesting",
"Microsoft.VisualStudio.Component.Debugger.JustInTime",
"Component.Microsoft.VisualStudio.LiveShare.2022",
"Microsoft.VisualStudio.Component.IntelliCode",
"Microsoft.VisualStudio.Component.ClassDesigner",
"Microsoft.VisualStudio.Component.GraphDocument",
"Microsoft.VisualStudio.Component.CodeMap",
Expand Down
16 changes: 16 additions & 0 deletions docs/Coding-Guidelines/VisualStudio2026.vsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Component.NuGet",
"Microsoft.VisualStudio.Component.Roslyn.Compiler",
"Microsoft.Component.MSBuild",
"Microsoft.Net.Component.4.8.SDK",
"Microsoft.Net.Component.4.8.TargetingPack",
"Microsoft.VisualStudio.ComponentGroup.MSIX.Packaging",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.44.17.14.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.44.17.14.ARM64",
"Microsoft.VisualStudio.Component.VC.14.44.17.14.x86.x64.Spectre",
"Microsoft.VisualStudio.Component.VC.14.44.17.14.ARM64.Spectre"
]
}
4 changes: 2 additions & 2 deletions test/Package/API/PackageTests.Packages.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ namespace Test::Package::Tests

inline bool IsMutableLocationSupported()
{
return !!::IsPackageFeatureSupported(PackageFeature_PackagePath_Mutable);
return !!::WindowsAppRuntime_IsPackageFeatureSupported(PackageFeature_PackagePath_Mutable);
}

inline bool IsExternalLocationSupported()
{
return !!::IsPackageFeatureSupported(PackageFeature_PackagePath_ExternalLocation);
return !!::WindowsAppRuntime_IsPackageFeatureSupported(PackageFeature_PackagePath_ExternalLocation);
}


Expand Down
11 changes: 11 additions & 0 deletions test/Package/API/PackageTests_Package_CPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ namespace Test::Package::Tests
return true;
}

TEST_METHOD(IsPackageFeatureSupported_ExportAlias)
{
const auto module{ ::GetModuleHandleW(L"Microsoft.WindowsAppRuntime.dll") };
VERIFY_IS_NOT_NULL(module);
const auto legacyExport{ ::GetProcAddress(module, "IsPackageFeatureSupported") };
const auto renamedExport{ ::GetProcAddress(module, "WindowsAppRuntime_IsPackageFeatureSupported") };
VERIFY_IS_NOT_NULL(legacyExport);
VERIFY_IS_NOT_NULL(renamedExport);
VERIFY_IS_TRUE(legacyExport == renamedExport);
}

TEST_METHOD(GetPackageFilePath_InvalidParameter)
{
PCWSTR packageFullName{ Framework_PackageFullName };
Expand Down
56 changes: 32 additions & 24 deletions tools/DevCheck/DevCheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Review the current environment and fix or warn if anything is amiss. This includes...
* Developer mode is enabled
* LongPath support is enabled
* Visual Studio 2022 is installed and properly configured
* Visual Studio 2022 or 2026 is installed and properly configured
* Windows SDK(s) are installed
* Nuget.exe is installed
* Test certificate to sign test MSIX packages is installed
Expand Down Expand Up @@ -638,41 +638,48 @@ function Run-Process([string]$exe, [string]$arguments, [Ref][string]$stderr, [in
}

$global:vspath = ''
function Get-VisualStudio2022InstallPath
$global:vsversion = $null
function Get-VisualStudioInstallPath
{
Write-Verbose "Detecting VisualStudio 2022..."
Write-Verbose "Detecting Visual Studio 2022 or 2026..."
$global:vspath = ''
$global:vsversion = $null
$vswhere_exe = Get-VSWhere
if ([string]::IsNullOrEmpty($vswhere_exe))
{
return $null
}
$args = " -latest -products * -version [17.0,18.0) -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath"
$args = " -latest -products * -version [17.0,19.0) -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -format json"
Write-Verbose "Executing $vswhere_exe $args"
$path = Run-Process $vswhere_exe $args
$path = $path -replace [environment]::NewLine, ''
Write-Verbose "Visual Studio 2022 detected at $path"
$global:vspath = $path
return $path
$instances = Run-Process $vswhere_exe $args | ConvertFrom-Json
if (-not $instances)
{
return $null
}
$global:vspath = $instances[0].installationPath
$global:vsversion = [version]$instances[0].installationVersion
Write-Verbose "Visual Studio $global:vsversion detected at $global:vspath"
return $global:vspath
}

function Test-VisualStudioComponent
{
param(
[String]$component,
[String]$versionRange
[String]$component
)

$vswhere_exe = Get-VSWhere
if ([string]::IsNullOrEmpty($global:vswhere))
if ([string]::IsNullOrEmpty($vswhere_exe))
{
return 0
return 1
}
$args = " -latest -products * -version $versionRange -requires $component -property productDisplayVersion"
$versionRange = "[$global:vsversion,$global:vsversion]"
$args = " -products * -version $versionRange -requires $component -property installationPath"
Write-Verbose "Executing $vswhere_exe $args"
try
{
$value = Run-Process $vswhere_exe $args -throwIfExitCodeIsFailure $true
if ([string]::IsNullOrEmpty($value))
if (($value -split '\r?\n') -notcontains $global:vspath)
{
throw "Component"
}
Expand All @@ -682,7 +689,7 @@ function Test-VisualStudioComponent
catch
{
$e = $_
Write-Host "...ERROR $($e): $($component) not found or valid" -ForegroundColor Red -BackgroundColor Black
Write-Host "...ERROR $($e): $($component) not found or valid in $global:vspath" -ForegroundColor Red -BackgroundColor Black
return 1
}
}
Expand All @@ -692,9 +699,8 @@ function Test-VisualStudioComponents
Write-Verbose "Detecting VisualStudio components..."
$root = Get-ProjectRoot
$path = Join-Path $root 'docs\Coding-Guidelines'
$filename = Join-Path $path 'VisualStudio2022.vsconfig'

$versionRange = "[17.0,18.0)"
$config = if ($global:vsversion.Major -eq 18) { 'VisualStudio2026.vsconfig' } else { 'VisualStudio2022.vsconfig' }
$filename = Join-Path $path $config

$json = Get-Content $filename -EA:Stop -Raw | ConvertFrom-Json
Write-Host "...Scanning $($json.components.Length) components in $($filename)" -NoNewline
Expand All @@ -703,27 +709,29 @@ function Test-VisualStudioComponents
ForEach ($component in $components)
{
Write-Host "." -NoNewline
$errors += (Test-VisualStudioComponent $component $versionRange)
$errors += (Test-VisualStudioComponent $component)
}
if ($errors -gt 0)
{
$global:issues += $errors
Write-Host ""
return $false
}
Write-Host "OK"
return $true
}

function Test-VisualStudio2022Install
function Test-VisualStudioInstall
{
$ok = $true
$path = Get-VisualStudio2022InstallPath
$path = Get-VisualStudioInstallPath
if ([string]::IsNullOrEmpty($path))
{
$global:issues++
$ok = $false
Write-Host "ERROR: Visual Studio 2022 or 2026 with C++ build tools not found" -ForegroundColor Red -BackgroundColor Black
}
Write-Host "VisualStudio 2022...$path"
Write-Host "Visual Studio...$path"
return $ok
}

Expand Down Expand Up @@ -1761,7 +1769,7 @@ if (($CheckAll -ne $false) -Or ($CheckVCLibs -ne $false))

if (($CheckAll -ne $false) -Or ($CheckVisualStudio -ne $false))
{
$ok = Test-VisualStudio2022Install
$ok = Test-VisualStudioInstall
if ($ok -eq $true)
{
$null = Test-VisualStudioComponents
Expand Down
88 changes: 88 additions & 0 deletions tools/DevCheck/Test-VisualStudio.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Set-StrictMode -Version 2.0
$ErrorActionPreference = 'Stop'

$root = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
$ast = [System.Management.Automation.Language.Parser]::ParseFile(
"$root\tools\DevCheck\DevCheck.ps1", [ref]$null, [ref]$null)
$names = @('Get-VisualStudioInstallPath', 'Test-VisualStudioInstall',
'Test-VisualStudioComponent', 'Test-VisualStudioComponents')
foreach ($node in $ast.FindAll({
param($node)
$node -is [System.Management.Automation.Language.FunctionDefinitionAst]
}, $true)) {
if ($node.Name -in $names) {
. ([scriptblock]::Create($node.Extent.Text))
}
}

function Get-ProjectRoot { return $root }
function Get-VSWhere { return 'vswhere.exe' }
function Run-Process {
param([string]$exe, [string]$arguments, [int]$throwIfExitCodeIsFailure = 0)
if ($arguments -match '-format json') { return $script:instanceJson }
if ($arguments -notmatch [regex]::Escape("[$global:vsversion,$global:vsversion]")) {
throw 'Component query was not scoped to the selected version'
}
$component = [regex]::Match($arguments, '-requires (\S+)').Groups[1].Value
if ($script:overrides.ContainsKey($component)) { return $script:overrides[$component] }
return "$global:vspath`r`n"
}
function Assert([bool]$condition, [string]$message) {
if (-not $condition) { throw $message }
}
function Set-Instance([int]$major) {
$script:instanceJson = ConvertTo-Json -InputObject @(@{
installationPath = "C:\VS$major"
installationVersion = "$major.14.123.4"
})
$script:overrides = @{}
$global:issues = 0
$global:vspath = ''
$global:vsversion = $null
}

foreach ($major in @(17, 18)) {
Set-Instance $major
Assert (Test-VisualStudioInstall) "VS $major discovery failed"
Assert (Test-VisualStudioComponents) "VS $major component check failed"
Assert ($global:issues -eq 0) "VS $major incorrectly reported issues"

Set-Instance $major
$null = Test-VisualStudioInstall
$script:overrides['Microsoft.Component.MSBuild'] = ''
Assert (-not (Test-VisualStudioComponents)) "VS $major missing component was accepted"
Assert ($global:issues -eq 1) "VS $major missing component was not counted for exit status"

Set-Instance $major
$null = Test-VisualStudioInstall
$script:overrides['Microsoft.VisualStudio.Component.NuGet'] = "C:\AnotherVS`r`n"
Assert (-not (Test-VisualStudioComponents)) "VS $major accepted a component from a different installation"
Assert ($global:issues -eq 1) "VS $major split-install failure was not counted"

Set-Instance $major
$null = Test-VisualStudioInstall
$script:instanceJson = '[]'
Assert (-not (Test-VisualStudioInstall)) "VS $major no-installation case was accepted"
Assert ($global:issues -eq 1) "VS $major no-installation failure was not counted"
Assert ([string]::IsNullOrEmpty($global:vspath)) "VS $major stale installation path survived"
Assert ($null -eq $global:vsversion) "VS $major stale installation version survived"
}

Set-Instance 17
Comment thread
Scottj1s marked this conversation as resolved.
Resolved
$null = Test-VisualStudioInstall
foreach ($component in @(
'Microsoft.NetCore.Component.Runtime.6.0',
'Microsoft.NetCore.Component.Runtime.7.0',
'Microsoft.VisualStudio.Component.LiveUnitTesting',
'Component.Microsoft.VisualStudio.LiveShare.2022',
'Microsoft.VisualStudio.Component.IntelliCode'
)) {
$script:overrides[$component] = ''
}
Assert (Test-VisualStudioComponents) 'Build-ready VS2022 was rejected without obsolete runtimes or optional IDE features'
Assert ($global:issues -eq 0) 'Optional VS2022 components incorrectly reported issues'

Write-Output 'PASS: VS2022, VS2026, VS2022 pipeline image, missing component, split installations, and no installation'
exit 0