mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-08-29 01:59:34 +02:00
## Summary of the Pull Request Fixes two local C++ build reliability problems: - Compiles all PowerToys C++ projects as UTF-8 through `Cpp.Build.props`, so builds do not depend on the active Windows code page. On code page 936, UTF-8 punctuation in BOM-less source files otherwise triggers C4819 and fails the build because warnings are treated as errors. - Uses `$(RepoRoot)` for Keyboard Manager repository paths and standardizes native/test output directories. This makes direct project builds find the resource conversion script and headers, places the Editor wrapper beside the WinUI app, and keeps the Engine test DLL under the repository test output directory. No runtime logic, end-user strings, dependencies, or binaries are added. ## PR Checklist - [x] Closes: #49573 - [x] Closes: #49574 - [x] **Communication:** Discussed the shared UTF-8 policy with a PowerToys collaborator in this PR - [x] **Tests:** Existing Keyboard Manager Engine tests pass; no new tests are needed for project-only changes - [x] **Localization:** No end-user-facing strings are changed - [x] **Dev docs:** No documentation changes are required for project configuration fixes - [x] **New binaries:** No new binaries are added - [x] **Documentation updated:** No user documentation changes are required ## Detailed Description of the Pull Request / Additional comments `Directory.Build.props` imports `Cpp.Build.props` for C++ projects. Defining `/utf-8 %(AdditionalOptions)` in its shared `ClCompile` settings makes source decoding deterministic across the native codebase and prevents future BOM-less UTF-8 source files from reintroducing the same locale-dependent failure. `/utf-8` explicitly sets both the source and execution character sets instead of suppressing C4819 or replacing valid Unicode text. `$(SolutionDir)` is only reliable when MSBuild is invoked through a solution. The repository's local build script builds `.vcxproj` files directly from their project directories, where `$(RepoRoot)` is the stable repository root property. The wrapper output now follows the existing `$(RepoRoot)$(Platform)\$(Configuration)\WinUI3Apps\` pattern used by other native WinUI dependencies. ## Validation Steps Performed All successful builds used the repository build scripts with `-Platform x64 -Configuration Debug`. - Ran `tools/build/build-essentials.cmd`: solution restore, Runner, and Settings all succeeded with empty errors logs. - Built `FancyZonesLib` successfully after it had failed with a resource-related CL exit during a full parallel build. - Built `WorkspacesModuleInterface` successfully, validating that existing UTF-16 BOM headers remain compatible with the shared option. - Built `ZoomItBreak` and `ZoomIt` successfully. - Built `KeyboardManagerEngineTest` successfully. - Built `KeyboardManagerEditor` and `KeyboardManagerEditorUI` successfully after the documented essentials prerequisite. - Confirmed the successful native build logs contain `/utf-8` compiler invocations and all corresponding `build.debug.x64.errors.log` files are empty. - Ran `vstest.console.exe` against the Keyboard Manager Engine test assembly: 103/103 passed. - Confirmed `PowerToys.KeyboardManagerEditorLibraryWrapper.dll` is emitted to `x64/Debug/WinUI3Apps`. - Confirmed `KeyboardManager.Engine.UnitTests.dll` is emitted to `x64/Debug/tests/KeyboardManagerEngine`. - Previously manually verified the x64 Debug PowerToys build can open Keyboard Manager Editor without 0x8007007E. A full `PowerToys.slnx` x64 Debug build was attempted twice. The first attempt exhausted the remaining 62 MB of disk space. After clearing 52.46 GB of ignored build outputs, the second attempt still exceeded the machine's temporary disk/commit limits (`CL.exe` exit `0xC000012D` and an out-of-space cppwinrt write). Before that resource failure, the log contained 4,642 `/utf-8` command entries and no character-set diagnostics. The full configuration matrix is left to PR CI rather than bypassing normal build settings locally. --------- Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com>
183 lines
10 KiB
XML
183 lines
10 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<Project ToolsVersion="4.0"
|
|
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
|
|
<!-- Skip building C++ test projects when BuildTests=false -->
|
|
<PropertyGroup Condition="'$(_IsSkippedTestProject)' == 'true'">
|
|
<UsePrecompiledHeaders>false</UsePrecompiledHeaders>
|
|
<RunCodeAnalysis>false</RunCodeAnalysis>
|
|
</PropertyGroup>
|
|
|
|
<!-- Project configurations -->
|
|
<ItemGroup Label="ProjectConfigurations">
|
|
<ProjectConfiguration Include="Debug|x64">
|
|
<Configuration>Debug</Configuration>
|
|
<Platform>x64</Platform>
|
|
</ProjectConfiguration>
|
|
<ProjectConfiguration Include="Release|x64">
|
|
<Configuration>Release</Configuration>
|
|
<Platform>x64</Platform>
|
|
</ProjectConfiguration>
|
|
<ProjectConfiguration Include="Debug|ARM64">
|
|
<Configuration>Debug</Configuration>
|
|
<Platform>ARM64</Platform>
|
|
</ProjectConfiguration>
|
|
<ProjectConfiguration Include="Release|ARM64">
|
|
<Configuration>Release</Configuration>
|
|
<Platform>ARM64</Platform>
|
|
</ProjectConfiguration>
|
|
</ItemGroup>
|
|
|
|
<!-- Run code analysis locally and in PR CI, but not on release CI -->
|
|
<PropertyGroup Condition="'$(SkipCppCodeAnalysis)' == ''">
|
|
<RunCodeAnalysis>true</RunCodeAnalysis>
|
|
<CodeAnalysisRuleSet>$(MsbuildThisFileDirectory)\CppRuleSet.ruleset</CodeAnalysisRuleSet>
|
|
<CAExcludePath>$(MSBuildThisFileDirectory)deps;$(MSBuildThisFileDirectory)packages;$(CAExcludePath)</CAExcludePath>
|
|
</PropertyGroup>
|
|
|
|
<!-- C++ source compile-specific things for all configurations -->
|
|
<PropertyGroup>
|
|
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
|
|
<PreferredToolArchitecture Condition="'$(PROCESSOR_ARCHITECTURE)' == 'ARM64' or '$(PROCESSOR_ARCHITEW6432)' == 'ARM64'">arm64</PreferredToolArchitecture>
|
|
<!-- vcpkg.targets is imported via Cpp.Build.targets after Microsoft.Cpp.targets. -->
|
|
<ForceImportAfterCppTargets>$(MSBuildThisFileDirectory)Cpp.Build.targets</ForceImportAfterCppTargets>
|
|
<ReplaceWildcardsInProjectItems>true</ReplaceWildcardsInProjectItems>
|
|
<ExternalIncludePath>$(MSBuildThisFileDirectory)deps;$(MSBuildThisFileDirectory)packages;$(ExternalIncludePath)</ExternalIncludePath>
|
|
<!-- Enable control flow guard for C++ projects that don't consume any C++ files -->
|
|
<!-- This covers the case where a .dll exports a .lib, but doesn't have any ClCompile entries. -->
|
|
<LinkControlFlowGuard>Guard</LinkControlFlowGuard>
|
|
</PropertyGroup>
|
|
<ItemDefinitionGroup>
|
|
<ClCompile>
|
|
<!-- Make angle-bracket includes external and turn off code analysis for them -->
|
|
<TreatAngleIncludeAsExternal>true</TreatAngleIncludeAsExternal>
|
|
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
|
|
<DisableAnalyzeExternal>true</DisableAnalyzeExternal>
|
|
|
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
<PrecompiledHeader Condition="'$(UsePrecompiledHeaders)' != 'false'">Use</PrecompiledHeader>
|
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
|
<WarningLevel>Level4</WarningLevel>
|
|
<DisableSpecificWarnings>4679;4706;4874;5271;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
<DisableAnalyzeExternal >true</DisableAnalyzeExternal>
|
|
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
|
|
<ConformanceMode>false</ConformanceMode>
|
|
<TreatWarningAsError>true</TreatWarningAsError>
|
|
<LanguageStandard>stdcpplatest</LanguageStandard>
|
|
<BuildStlModules>false</BuildStlModules>
|
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
|
<!-- TODO: _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING for compatibility with VS 17.8. Check if we can remove. -->
|
|
<!-- TODO: _SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS for VS 2026 (MSVC 14.51+). The STL turned
|
|
<experimental/coroutine> into a hard error (STL1011), and C++/WinRT's base.h still falls back to it when
|
|
__cpp_lib_coroutine isn't defined at include time. Remove once C++/WinRT no longer references the experimental header. -->
|
|
<PreprocessorDefinitions>_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING;_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
<!-- CLR + CFG are not compatible >:{ -->
|
|
<ControlFlowGuard Condition="'$(CLRSupport)' == ''">Guard</ControlFlowGuard>
|
|
<DebugInformationFormat Condition="'%(ControlFlowGuard)' == 'Guard'">ProgramDatabase</DebugInformationFormat>
|
|
<SDLCheck>true</SDLCheck>
|
|
</ClCompile>
|
|
<Link>
|
|
<SubSystem>Windows</SubSystem>
|
|
</Link>
|
|
<Lib>
|
|
<TreatLibWarningAsErrors>true</TreatLibWarningAsErrors>
|
|
</Lib>
|
|
</ItemDefinitionGroup>
|
|
|
|
<!-- C++ source compile-specific things for Debug/Release configurations -->
|
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
|
<ClCompile>
|
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
<Optimization>Disabled</Optimization>
|
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
</ClCompile>
|
|
<Link>
|
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
</Link>
|
|
</ItemDefinitionGroup>
|
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
|
<ClCompile>
|
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
<Optimization>MaxSpeed</Optimization>
|
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
</ClCompile>
|
|
<Link>
|
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
<OptimizeReferences>true</OptimizeReferences>
|
|
</Link>
|
|
</ItemDefinitionGroup>
|
|
|
|
<!-- Global props OverrideWindowsTargetPlatformVersion-->
|
|
<PropertyGroup Label="Globals">
|
|
<WindowsTargetPlatformVersion>10.0.26100.0</WindowsTargetPlatformVersion>
|
|
<TargetPlatformVersion>10.0.26100.0</TargetPlatformVersion>
|
|
<WindowsTargetPlatformMinVersion>10.0.19041.0</WindowsTargetPlatformMinVersion>
|
|
</PropertyGroup>
|
|
|
|
<!-- Props that are constant for both Debug and Release configurations -->
|
|
<PropertyGroup Label="Configuration">
|
|
<PlatformToolset>v143</PlatformToolset>
|
|
<PlatformToolset Condition="'$(VisualStudioVersion)' == '18.0'">v145</PlatformToolset>
|
|
<CharacterSet>Unicode</CharacterSet>
|
|
<DesktopCompatible>true</DesktopCompatible>
|
|
<SpectreMitigation>Spectre</SpectreMitigation>
|
|
</PropertyGroup>
|
|
|
|
<!--
|
|
vcpkg integration. Set globally and loaded before Microsoft.Cpp.props (via
|
|
ForceImportBeforeCppProps) so that vcpkg.props' ClCompile hook is in place
|
|
before the C++ targets run. VcpkgRoot is resolved via the same three-tier
|
|
fallback used by microsoft/terminal (env var → VS-shipped → deps/vcpkg).
|
|
-->
|
|
<PropertyGroup Label="vcpkg">
|
|
<VcpkgEnabled>true</VcpkgEnabled>
|
|
<VcpkgEnableManifest>true</VcpkgEnableManifest>
|
|
<VcpkgManifestEnabled>true</VcpkgManifestEnabled>
|
|
<VcpkgManifestRoot>$(MSBuildThisFileDirectory)</VcpkgManifestRoot>
|
|
<VcpkgOSTarget>windows</VcpkgOSTarget>
|
|
<VcpkgUseStatic>true</VcpkgUseStatic>
|
|
<!--
|
|
Force VcpkgConfiguration to follow $(Configuration). Without this,
|
|
vcpkg.props infers VcpkgConfiguration from $(UseDebugLibraries), which
|
|
Microsoft.Cpp.Default.props has already defaulted to 'false' by the
|
|
time vcpkg.props is imported here (the PowerToys-wide Debug override
|
|
below runs LATER). That would silently link the Release-built spdlog
|
|
into Debug consumers and trigger LNK2038 (MT/MTd, _ITERATOR_DEBUG_LEVEL).
|
|
-->
|
|
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
|
|
<!-- vcpkg validates triplets case-sensitively; PowerToys uses ARM64 capital-case. -->
|
|
<VcpkgPlatformTarget Condition="'$(Platform)' == 'ARM64'">arm64</VcpkgPlatformTarget>
|
|
<VcpkgApplocalDeps>false</VcpkgApplocalDeps>
|
|
<VcpkgInstalledDir>$(MSBuildThisFileDirectory)vcpkg_installed\$(Platform)\</VcpkgInstalledDir>
|
|
<VcpkgRoot Condition="'$(VcpkgRoot)' == ''">$(VCPKG_ROOT)</VcpkgRoot>
|
|
<VcpkgRoot Condition="'$(VcpkgRoot)' == '' and '$(VsInstallRoot)' != ''">$(VsInstallRoot)\VC\vcpkg</VcpkgRoot>
|
|
<VcpkgRoot Condition="'$(VcpkgRoot)' == '' or !Exists('$(VcpkgRoot)\vcpkg.exe')">$(MSBuildThisFileDirectory)deps\vcpkg</VcpkgRoot>
|
|
<CAExcludePath>$(CAExcludePath);$(VcpkgInstalledDir)</CAExcludePath>
|
|
<VCPkgLocalAppDataDisabled>true</VCPkgLocalAppDataDisabled>
|
|
</PropertyGroup>
|
|
<!-- Fail fast with an actionable message instead of opaque C1083 spdlog/spdlog.h errors. -->
|
|
<Target Name="PowerToysEnsureVcpkgAvailable"
|
|
BeforeTargets="PrepareForBuild"
|
|
Condition="'$(MSBuildProjectExtension)' == '.vcxproj' and '$(VcpkgEnabled)' == 'true' and !Exists('$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg.props')">
|
|
<Error Text="PowerToys requires the 'vcpkg' Visual Studio component, but it was not found.%0A%0AOpen the Visual Studio Installer, click Modify on your VS install, search for 'vcpkg', enable 'C++ vcpkg package manager', and click Modify. (Visual Studio will also prompt you to install missing .vsconfig components when you open PowerToys.slnx.)%0A%0AIf you have vcpkg installed elsewhere, set the VCPKG_ROOT environment variable to its root before building.%0A%0ASearched: '$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg.props'" />
|
|
</Target>
|
|
<Import Project="$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg.props"
|
|
Condition="'$(MSBuildProjectExtension)' == '.vcxproj' and Exists('$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg.props')" />
|
|
|
|
|
|
<!-- Debug/Release props -->
|
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
|
|
<UseDebugLibraries>true</UseDebugLibraries>
|
|
<LinkIncremental>true</LinkIncremental>
|
|
</PropertyGroup>
|
|
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
|
|
<UseDebugLibraries>false</UseDebugLibraries>
|
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
<LinkIncremental>false</LinkIncremental>
|
|
</PropertyGroup>
|
|
|
|
</Project>
|