Skip to content

Commit 7445e1d

Browse files
authored
Shared build props (#5749)
## Change Due to an issue with the internal build, it was realized that we could be violating ODR due to a mismatch on the build configurations. This change moves to using the MSBuild `Directory.Build.props` file to have all projects use the same settings. It also adds a header using `#pragma detect_mismatch` to attempt to detect the issue at compilation. This header is then included by the errors header, which is used by at least one TU in every project, if not all of them.
1 parent ab887ef commit 7445e1d

File tree

19 files changed

+96
-112
lines changed

19 files changed

+96
-112
lines changed

src/AppInstallerCLI.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Project", "Project", "{8D53
3737
..\azure-pipelines.nuget.yml = ..\azure-pipelines.nuget.yml
3838
..\azure-pipelines.yml = ..\azure-pipelines.yml
3939
..\cgmanifest.json = ..\cgmanifest.json
40+
Directory.Build.props = Directory.Build.props
4041
..\README.md = ..\README.md
4142
..\doc\ReleaseNotes.md = ..\doc\ReleaseNotes.md
4243
..\doc\Settings.md = ..\doc\Settings.md

src/AppInstallerCLICore/AppInstallerCLICore.vcxproj

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -279,21 +279,6 @@
279279
<SubSystem Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|x64'">Windows</SubSystem>
280280
</Link>
281281
</ItemDefinitionGroup>
282-
<ItemDefinitionGroup Condition="'$(UseProdCLSIDs)' == 'true'">
283-
<ClCompile>
284-
<PreprocessorDefinitions>USE_PROD_CLSIDS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
285-
</ClCompile>
286-
</ItemDefinitionGroup>
287-
<ItemDefinitionGroup Condition="'$(WingetDisableTestHooks)'=='true'">
288-
<ClCompile>
289-
<PreprocessorDefinitions>AICLI_DISABLE_TEST_HOOKS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
290-
</ClCompile>
291-
</ItemDefinitionGroup>
292-
<ItemDefinitionGroup Condition="'$(WingetDisableExperimentalFeatures)'=='true'">
293-
<ClCompile>
294-
<PreprocessorDefinitions>WINGET_DISABLE_EXPERIMENTAL_FEATURES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
295-
</ClCompile>
296-
</ItemDefinitionGroup>
297282
<ItemGroup>
298283
<ClInclude Include="Argument.h" />
299284
<ClInclude Include="ChannelStreams.h" />

src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,6 @@
204204
<AdditionalOptions>%(AdditionalOptions) /permissive- /D _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING</AdditionalOptions>
205205
</ClCompile>
206206
</ItemDefinitionGroup>
207-
<ItemDefinitionGroup Condition="'$(UseProdCLSIDs)'=='true'">
208-
<ClCompile>
209-
<PreprocessorDefinitions>USE_PROD_CLSIDS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
210-
</ClCompile>
211-
</ItemDefinitionGroup>
212207
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
213208
<ClCompile>
214209
<Optimization>Disabled</Optimization>
@@ -328,21 +323,6 @@
328323
<SubSystem>Windows</SubSystem>
329324
</Link>
330325
</ItemDefinitionGroup>
331-
<ItemDefinitionGroup Condition="'$(WingetDisableTestHooks)'=='true'">
332-
<ClCompile>
333-
<PreprocessorDefinitions>AICLI_DISABLE_TEST_HOOKS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
334-
</ClCompile>
335-
</ItemDefinitionGroup>
336-
<ItemDefinitionGroup Condition="'$(WingetDisableExperimentalFeatures)'=='true'">
337-
<ClCompile>
338-
<PreprocessorDefinitions>WINGET_DISABLE_EXPERIMENTAL_FEATURES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
339-
</ClCompile>
340-
</ItemDefinitionGroup>
341-
<ItemDefinitionGroup Condition="'$(WingetEnableReleaseBuild)'=='true'">
342-
<ClCompile>
343-
<PreprocessorDefinitions>WINGET_ENABLE_RELEASE_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
344-
</ClCompile>
345-
</ItemDefinitionGroup>
346326
<ItemGroup>
347327
<ClInclude Include="Authentication\WebAccountManagerAuthenticator.h" />
348328
<ClInclude Include="DODownloader.h" />

src/AppInstallerRepositoryCore/AppInstallerRepositoryCore.vcxproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,6 @@
278278
<SubSystem Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|x64'">Windows</SubSystem>
279279
</Link>
280280
</ItemDefinitionGroup>
281-
<ItemDefinitionGroup Condition="'$(WingetDisableTestHooks)'=='true'">
282-
<ClCompile>
283-
<PreprocessorDefinitions>AICLI_DISABLE_TEST_HOOKS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
284-
</ClCompile>
285-
</ItemDefinitionGroup>
286281
<ItemGroup>
287282
<ClInclude Include="ArpVersionValidation.h" />
288283
<ClInclude Include="CompositeSource.h" />

src/AppInstallerSharedLib/AppInstallerSharedLib.vcxproj

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -319,21 +319,6 @@
319319
<SubSystem>Windows</SubSystem>
320320
</Link>
321321
</ItemDefinitionGroup>
322-
<ItemDefinitionGroup Condition="'$(WingetDisableTestHooks)'=='true'">
323-
<ClCompile>
324-
<PreprocessorDefinitions>AICLI_DISABLE_TEST_HOOKS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
325-
</ClCompile>
326-
</ItemDefinitionGroup>
327-
<ItemDefinitionGroup Condition="'$(WingetDisableExperimentalFeatures)'=='true'">
328-
<ClCompile>
329-
<PreprocessorDefinitions>WINGET_DISABLE_EXPERIMENTAL_FEATURES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
330-
</ClCompile>
331-
</ItemDefinitionGroup>
332-
<ItemDefinitionGroup Condition="'$(WingetEnableReleaseBuild)'=='true'">
333-
<ClCompile>
334-
<PreprocessorDefinitions>WINGET_ENABLE_RELEASE_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
335-
</ClCompile>
336-
</ItemDefinitionGroup>
337322
<ItemGroup>
338323
<ClInclude Include="ICU\SQLiteICU.h" />
339324
<ClInclude Include="pch.h" />
@@ -351,6 +336,7 @@
351336
<ClInclude Include="Public\winget\Compression.h" />
352337
<ClInclude Include="Public\winget\COMStaticStorage.h" />
353338
<ClInclude Include="Public\winget\ConfigurationSetProcessorHandlers.h" />
339+
<ClInclude Include="Public\winget\DetectMismatch.h" />
354340
<ClInclude Include="Public\winget\Filesystem.h" />
355341
<ClInclude Include="Public\winget\GroupPolicy.h" />
356342
<ClInclude Include="Public\winget\IConfigurationStaticsInternals.h" />

src/AppInstallerSharedLib/AppInstallerSharedLib.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@
143143
<ClInclude Include="Public\winget\COMStaticStorage.h">
144144
<Filter>Public\winget</Filter>
145145
</ClInclude>
146+
<ClInclude Include="Public\winget\DetectMismatch.h">
147+
<Filter>Public\winget</Filter>
148+
</ClInclude>
146149
</ItemGroup>
147150
<ItemGroup>
148151
<ClCompile Include="pch.cpp">

src/AppInstallerSharedLib/Public/AppInstallerErrors.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#include <winget/LocIndependent.h>
55
#include <wil/result_macros.h>
66

7+
// Errors is the most ubiquitous header; including the mismatch detection in it should reach everywhere.
8+
#include <winget/DetectMismatch.h>
9+
710
#ifndef WINGET_DISABLE_FOR_FUZZING
811
#include <winrt/base.h>
912
#endif
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
#pragma once
4+
5+
#ifndef USE_PROD_CLSIDS
6+
#pragma detect_mismatch("USE_PROD_CLSIDS", "Not Defined")
7+
#else
8+
#pragma detect_mismatch("USE_PROD_CLSIDS", "Defined")
9+
#endif
10+
11+
#ifndef AICLI_DISABLE_TEST_HOOKS
12+
#pragma detect_mismatch("AICLI_DISABLE_TEST_HOOKS", "Not Defined")
13+
#else
14+
#pragma detect_mismatch("AICLI_DISABLE_TEST_HOOKS", "Defined")
15+
#endif
16+
17+
#ifndef WINGET_DISABLE_EXPERIMENTAL_FEATURES
18+
#pragma detect_mismatch("WINGET_DISABLE_EXPERIMENTAL_FEATURES", "Not Defined")
19+
#else
20+
#pragma detect_mismatch("WINGET_DISABLE_EXPERIMENTAL_FEATURES", "Defined")
21+
#endif
22+
23+
#ifndef USE_PROD_WINGET_SERVER
24+
#pragma detect_mismatch("USE_PROD_WINGET_SERVER", "Not Defined")
25+
#else
26+
#pragma detect_mismatch("USE_PROD_WINGET_SERVER", "Defined")
27+
#endif
28+
29+
#ifndef WINGET_ENABLE_RELEASE_BUILD
30+
#pragma detect_mismatch("WINGET_ENABLE_RELEASE_BUILD", "Not Defined")
31+
#else
32+
#pragma detect_mismatch("WINGET_ENABLE_RELEASE_BUILD", "Defined")
33+
#endif

src/Directory.Build.props

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<!-- Consume containing solution build props if present. -->
4+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" Condition="'' != $([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
5+
6+
<ItemDefinitionGroup Condition="'$(UseProdCLSIDs)'=='true'">
7+
<ClCompile>
8+
<PreprocessorDefinitions>USE_PROD_CLSIDS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9+
</ClCompile>
10+
</ItemDefinitionGroup>
11+
12+
<PropertyGroup Condition="'$(UseProdCLSIDs)'=='true'">
13+
<DefineConstants>$(DefineConstants);USE_PROD_CLSIDS</DefineConstants>
14+
</PropertyGroup>
15+
16+
<ItemDefinitionGroup Condition="'$(WingetDisableTestHooks)'=='true'">
17+
<ClCompile>
18+
<PreprocessorDefinitions>AICLI_DISABLE_TEST_HOOKS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
19+
</ClCompile>
20+
</ItemDefinitionGroup>
21+
22+
<PropertyGroup Condition="'$(WingetDisableTestHooks)'=='true'">
23+
<DefineConstants>$(DefineConstants);AICLI_DISABLE_TEST_HOOKS</DefineConstants>
24+
</PropertyGroup>
25+
26+
<ItemDefinitionGroup Condition="'$(WingetDisableExperimentalFeatures)'=='true'">
27+
<ClCompile>
28+
<PreprocessorDefinitions>WINGET_DISABLE_EXPERIMENTAL_FEATURES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
29+
</ClCompile>
30+
</ItemDefinitionGroup>
31+
32+
<PropertyGroup Condition="'$(WingetDisableExperimentalFeatures)'=='true'">
33+
<DefineConstants>$(DefineConstants);WINGET_DISABLE_EXPERIMENTAL_FEATURES</DefineConstants>
34+
</PropertyGroup>
35+
36+
<ItemDefinitionGroup Condition="'$(UseProdWingetServer)'=='true'">
37+
<ClCompile>
38+
<PreprocessorDefinitions>USE_PROD_WINGET_SERVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
39+
</ClCompile>
40+
</ItemDefinitionGroup>
41+
42+
<PropertyGroup Condition="'$(UseProdWingetServer)'=='true'">
43+
<DefineConstants>$(DefineConstants);USE_PROD_WINGET_SERVER</DefineConstants>
44+
</PropertyGroup>
45+
46+
<ItemDefinitionGroup Condition="'$(WingetEnableReleaseBuild)'=='true'">
47+
<ClCompile>
48+
<PreprocessorDefinitions>WINGET_ENABLE_RELEASE_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
49+
</ClCompile>
50+
</ItemDefinitionGroup>
51+
52+
<PropertyGroup Condition="'$(WingetEnableReleaseBuild)'=='true'">
53+
<DefineConstants>$(DefineConstants);WINGET_ENABLE_RELEASE_BUILD</DefineConstants>
54+
</PropertyGroup>
55+
</Project>

src/Microsoft.Management.Configuration.OutOfProc/Microsoft.Management.Configuration.OutOfProc.vcxproj

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,6 @@
179179
<AdditionalOptions>%(AdditionalOptions) /permissive- /bigobj /D _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING</AdditionalOptions>
180180
</ClCompile>
181181
</ItemDefinitionGroup>
182-
<ItemDefinitionGroup Condition="'$(UseProdCLSIDs)'=='true'">
183-
<ClCompile>
184-
<PreprocessorDefinitions>USE_PROD_CLSIDS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
185-
</ClCompile>
186-
</ItemDefinitionGroup>
187-
<ItemDefinitionGroup Condition="'$(UseProdWingetServer)'=='true'">
188-
<ClCompile>
189-
<PreprocessorDefinitions>USE_PROD_WINGET_SERVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
190-
</ClCompile>
191-
</ItemDefinitionGroup>
192182
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
193183
<ClCompile>
194184
<Optimization>Disabled</Optimization>

0 commit comments

Comments
 (0)