From af506d64e40ea458d2293bd21e2e9b1953899b2d Mon Sep 17 00:00:00 2001 From: Howard Kapustein Date: Tue, 17 Aug 2021 13:17:35 -0700 Subject: [PATCH] Commonize Hybrid CRT support (#1026) * Move Hybrid CRT support out of individual project files up to the project level as a whole * Remove unnecesasry Store-app-ness that fails the Hybrid CRT support * Stop enabling DebugLibraries to avoid bringing in debug VC CRT DLL dependencies (violating the Hybrid CRT rules) * Add DesktopCompatible to MrtCoreManagedTest for future reference - it doesn't hurt, but it doesn't help (at least, not this issue). Also added Win32Proj keyword to M.AM.Resources project. We now have 1 root issue * Removed MrtCoreManagedTest from the build due to a fundamental incompatibility (ut's a Universal Windows project referencing Microsoft.ApplicationModel.Resources (the WinRT dll) which isn't, and VS doesn't like crossing streams. Even worse, VS and msbuild produce different results!). * Revert "Removed MrtCoreManagedTest from the build due to a fundamental incompatibility (ut's a Universal Windows project referencing Microsoft.ApplicationModel.Resources (the WinRT dll) which isn't, and VS doesn't like crossing streams. Even worse, VS and msbuild produce different results!)." This reverts commit 6f4b23dd1057ee2d0c2c0684aedcd3797adfbaa3. * Doing things to workaround MrtCoreManagedTest is a Univesal Windows project. Epic Failure. Because it's a Universal Windows project MSTest is creating $(OutDir)AppX subdir and copying files ***it knows about*** to the subdir. This brutal hack fails because File.Exists() for files in the parent directory fails, and that's because the last var pc = ... tries to access the AppX directory's parent ***and fails because Access Denied***. Previously doing the copy in the .csproj fails because the AppX directory doesn't necesarily exist before the test runs, and MD $(OutDir)AppX before copying files is pointless because MSTest is deleting all the files (if any) in the AppX directory when the test starts. So dead end upon dead end. Only way is to find a way to bench the Universal Windows .props logic to understand the files it doesn't want to allow through the ...Transitive... copy rules. Or just rewrite the project as a non-Universal Windows project. Or rewrite the test using TAEF instead of MSTest. Or... drink heavily. Hunting up Scott tomorrow hoping he has an idea * Hah! Thank you ScottJ! ReferenceCopyLocalPaths does the right thing, copying the needed DLLs into $(OutDir) *and* $(OutDir)AppX and the tests now find the dll and pass * Remove debugging hackery --- Directory.Build.props | 3 ++ HybridCRT.props | 38 +++++++++++++++++++ dev/Detours/Detours.vcxproj | 8 ++-- ...amicDependency.DataStore.ProxyStub.vcxproj | 30 --------------- .../DynamicDependency.DataStore.vcxproj | 30 --------------- ...ependencyLifetimeManager.ProxyStub.vcxproj | 30 --------------- .../DynamicDependencyLifetimeManager.vcxproj | 30 --------------- dev/MRTCore/mrt/Core/src/MRM.vcxproj | 20 ---------- .../MrtCoreUnpackagedTests.csproj | 5 ++- ...crosoft.ApplicationModel.Resources.vcxproj | 5 +-- .../unittests/MrtCoreManagedTest.csproj | 21 +++++++++- .../unittests/MrtCoreManagedTests.runsettings | 8 ++++ .../mrm/UnitTests/MrmBaseUnitTests.vcxproj | 18 +-------- .../WindowsAppSDK_BootstrapDLL.vcxproj | 31 --------------- .../WindowsAppSDK_DLL.vcxproj | 28 -------------- 15 files changed, 78 insertions(+), 227 deletions(-) create mode 100644 HybridCRT.props create mode 100644 dev/MRTCore/mrt/Microsoft.ApplicationModel.Resources/unittests/MrtCoreManagedTests.runsettings diff --git a/Directory.Build.props b/Directory.Build.props index 7bd7f75ad..d6f3fdae7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -44,4 +44,7 @@ $(SolutionDir)\build\override;%(AdditionalIncludeDirectories) + + + diff --git a/HybridCRT.props b/HybridCRT.props new file mode 100644 index 000000000..750b7e596 --- /dev/null +++ b/HybridCRT.props @@ -0,0 +1,38 @@ + + + + + + true + + + + + + MultiThreadedDebug + + + + %(IgnoreSpecificDefaultLibraries);libucrtd.lib + %(AdditionalOptions) /defaultlib:ucrtd.lib + + + + + + MultiThreaded + + + + %(IgnoreSpecificDefaultLibraries);libucrt.lib + %(AdditionalOptions) /defaultlib:ucrt.lib + + + + diff --git a/dev/Detours/Detours.vcxproj b/dev/Detours/Detours.vcxproj index 7dfdc9459..b55afc052 100644 --- a/dev/Detours/Detours.vcxproj +++ b/dev/Detours/Detours.vcxproj @@ -45,13 +45,13 @@ StaticLibrary - true + false v142 Unicode StaticLibrary - true + false v142 Unicode @@ -71,13 +71,13 @@ StaticLibrary - true + false v142 Unicode StaticLibrary - true + false v142 Unicode diff --git a/dev/DynamicDependencyDataStore/DynamicDependency.DataStore.ProxyStub/DynamicDependency.DataStore.ProxyStub.vcxproj b/dev/DynamicDependencyDataStore/DynamicDependency.DataStore.ProxyStub/DynamicDependency.DataStore.ProxyStub.vcxproj index a629fb3c2..c71db5a16 100644 --- a/dev/DynamicDependencyDataStore/DynamicDependency.DataStore.ProxyStub/DynamicDependency.DataStore.ProxyStub.vcxproj +++ b/dev/DynamicDependencyDataStore/DynamicDependency.DataStore.ProxyStub/DynamicDependency.DataStore.ProxyStub.vcxproj @@ -161,36 +161,6 @@ false PostBuildEvent - - - - - MultiThreadedDebug - - - - %(IgnoreSpecificDefaultLibraries);libucrtd.lib - %(AdditionalOptions) /defaultlib:ucrtd.lib - - - - - - MultiThreaded - - - - %(IgnoreSpecificDefaultLibraries);libucrt.lib - %(AdditionalOptions) /defaultlib:ucrt.lib - - - Level4 diff --git a/dev/DynamicDependencyDataStore/DynamicDependency.DataStore/DynamicDependency.DataStore.vcxproj b/dev/DynamicDependencyDataStore/DynamicDependency.DataStore/DynamicDependency.DataStore.vcxproj index ffc2bf746..d36a2dfa3 100644 --- a/dev/DynamicDependencyDataStore/DynamicDependency.DataStore/DynamicDependency.DataStore.vcxproj +++ b/dev/DynamicDependencyDataStore/DynamicDependency.DataStore/DynamicDependency.DataStore.vcxproj @@ -145,36 +145,6 @@ false - - - - - MultiThreadedDebug - - - - %(IgnoreSpecificDefaultLibraries);libucrtd.lib - %(AdditionalOptions) /defaultlib:ucrtd.lib - - - - - - MultiThreaded - - - - %(IgnoreSpecificDefaultLibraries);libucrt.lib - %(AdditionalOptions) /defaultlib:ucrt.lib - - - Level4 diff --git a/dev/DynamicDependencyLifetimeManager/DynamicDependencyLifetimeManager.ProxyStub/DynamicDependencyLifetimeManager.ProxyStub.vcxproj b/dev/DynamicDependencyLifetimeManager/DynamicDependencyLifetimeManager.ProxyStub/DynamicDependencyLifetimeManager.ProxyStub.vcxproj index 3b8d4063b..02da4fc64 100644 --- a/dev/DynamicDependencyLifetimeManager/DynamicDependencyLifetimeManager.ProxyStub/DynamicDependencyLifetimeManager.ProxyStub.vcxproj +++ b/dev/DynamicDependencyLifetimeManager/DynamicDependencyLifetimeManager.ProxyStub/DynamicDependencyLifetimeManager.ProxyStub.vcxproj @@ -160,36 +160,6 @@ false PostBuildEvent - - - - - MultiThreadedDebug - - - - %(IgnoreSpecificDefaultLibraries);libucrtd.lib - %(AdditionalOptions) /defaultlib:ucrtd.lib - - - - - - MultiThreaded - - - - %(IgnoreSpecificDefaultLibraries);libucrt.lib - %(AdditionalOptions) /defaultlib:ucrt.lib - - - Level4 diff --git a/dev/DynamicDependencyLifetimeManager/DynamicDependencyLifetimeManager/DynamicDependencyLifetimeManager.vcxproj b/dev/DynamicDependencyLifetimeManager/DynamicDependencyLifetimeManager/DynamicDependencyLifetimeManager.vcxproj index 8c6c1fb03..c8937b327 100644 --- a/dev/DynamicDependencyLifetimeManager/DynamicDependencyLifetimeManager/DynamicDependencyLifetimeManager.vcxproj +++ b/dev/DynamicDependencyLifetimeManager/DynamicDependencyLifetimeManager/DynamicDependencyLifetimeManager.vcxproj @@ -139,36 +139,6 @@ false - - - - - MultiThreadedDebug - - - - %(IgnoreSpecificDefaultLibraries);libucrtd.lib - %(AdditionalOptions) /defaultlib:ucrtd.lib - - - - - - MultiThreaded - - - - %(IgnoreSpecificDefaultLibraries);libucrt.lib - %(AdditionalOptions) /defaultlib:ucrt.lib - - - Level4 diff --git a/dev/MRTCore/mrt/Core/src/MRM.vcxproj b/dev/MRTCore/mrt/Core/src/MRM.vcxproj index b0701c16f..ad01655d2 100644 --- a/dev/MRTCore/mrt/Core/src/MRM.vcxproj +++ b/dev/MRTCore/mrt/Core/src/MRM.vcxproj @@ -103,27 +103,13 @@ - - MultiThreadedDebug _DEBUG;%(PreprocessorDefinitions) Disabled 18 - - - %(IgnoreSpecificDefaultLibraries);libucrtd.lib - %(AdditionalOptions) /defaultlib:ucrtd.lib - - - - - MultiThreaded NDEBUG;%(PreprocessorDefinitions) 18 @@ -135,12 +121,6 @@ true - - %(IgnoreSpecificDefaultLibraries);libucrt.lib - %(AdditionalOptions) /defaultlib:ucrt.lib false true diff --git a/dev/MRTCore/mrt/Microsoft.ApplicationModel.Resources/UnpackagedTests/MrtCoreUnpackagedTests.csproj b/dev/MRTCore/mrt/Microsoft.ApplicationModel.Resources/UnpackagedTests/MrtCoreUnpackagedTests.csproj index 4d6d90822..ea832c14d 100644 --- a/dev/MRTCore/mrt/Microsoft.ApplicationModel.Resources/UnpackagedTests/MrtCoreUnpackagedTests.csproj +++ b/dev/MRTCore/mrt/Microsoft.ApplicationModel.Resources/UnpackagedTests/MrtCoreUnpackagedTests.csproj @@ -84,17 +84,18 @@ copy /Y "$(OutputPath)..\Microsoft.ApplicationModel.Resources\Microsoft.Internal.FrameworkUdk.dll" "$(OutputPath)Microsoft.Internal.FrameworkUdk.dll" + copy /Y "$(OutputPath)..\MRM\MRM.dll" "$(OutputPath)MRM.dll" powershell -command "$file = gi $(OutputPath)MrtCoreUnpackagedTests.runsettings; $x = [xml](gc $file); $x.RunSettings.RunConfiguration.TestAdaptersPaths = '$(OutputPath)'; $x.Save($file.Fullname)" $(OutputPath)MrtCoreUnpackagedTests.runsettings - - \ No newline at end of file + diff --git a/dev/MRTCore/mrt/Microsoft.ApplicationModel.Resources/src/Microsoft.ApplicationModel.Resources.vcxproj b/dev/MRTCore/mrt/Microsoft.ApplicationModel.Resources/src/Microsoft.ApplicationModel.Resources.vcxproj index 6a1116718..6b153996a 100644 --- a/dev/MRTCore/mrt/Microsoft.ApplicationModel.Resources/src/Microsoft.ApplicationModel.Resources.vcxproj +++ b/dev/MRTCore/mrt/Microsoft.ApplicationModel.Resources/src/Microsoft.ApplicationModel.Resources.vcxproj @@ -16,9 +16,8 @@ Microsoft.ApplicationModel.Resources en-US 14.0 - true - Windows Store - 10.0 + Win32Proj + 10.0.18362.0 10.0.17134.0 + + + powershell -command "$file = gi $(OutputPath)MrtCoreManagedTests.runsettings; $x = [xml](gc $file); $x.RunSettings.RunConfiguration.TestAdaptersPaths = '$(OutputPath)'; $x.Save($file.Fullname)" + + + + $(OutputPath)MrtCoreManagedTests.runsettings + + - \ No newline at end of file + diff --git a/dev/MRTCore/mrt/Microsoft.ApplicationModel.Resources/unittests/MrtCoreManagedTests.runsettings b/dev/MRTCore/mrt/Microsoft.ApplicationModel.Resources/unittests/MrtCoreManagedTests.runsettings new file mode 100644 index 000000000..2f391e809 --- /dev/null +++ b/dev/MRTCore/mrt/Microsoft.ApplicationModel.Resources/unittests/MrtCoreManagedTests.runsettings @@ -0,0 +1,8 @@ + + + + + + .\ + + \ No newline at end of file diff --git a/dev/MRTCore/mrt/mrm/UnitTests/MrmBaseUnitTests.vcxproj b/dev/MRTCore/mrt/mrm/UnitTests/MrmBaseUnitTests.vcxproj index 41fd04ec1..49101da49 100644 --- a/dev/MRTCore/mrt/mrm/UnitTests/MrmBaseUnitTests.vcxproj +++ b/dev/MRTCore/mrt/mrm/UnitTests/MrmBaseUnitTests.vcxproj @@ -97,20 +97,12 @@ Level4 Disabled - - MultiThreadedDebug ..\include;..\mrmmin;%(AdditionalIncludeDirectories) 4309;4838;%(DisableSpecificWarnings) stdcpp17 true - - %(IgnoreSpecificDefaultLibraries);libucrtd.lib - %(AdditionalOptions) /defaultlib:ucrtd.lib @@ -119,8 +111,6 @@ MaxSpeed true true - - MultiThreaded ..\include;..\mrmmin;%(AdditionalIncludeDirectories) 4309;4838;%(DisableSpecificWarnings) stdcpp17 @@ -130,12 +120,6 @@ true true true - - %(IgnoreSpecificDefaultLibraries);libucrt.lib - %(AdditionalOptions) /defaultlib:ucrt.lib @@ -276,4 +260,4 @@ - \ No newline at end of file + diff --git a/dev/WindowsAppSDK_BootstrapDLL/WindowsAppSDK_BootstrapDLL.vcxproj b/dev/WindowsAppSDK_BootstrapDLL/WindowsAppSDK_BootstrapDLL.vcxproj index 45ea1fd0e..ee2e390ef 100644 --- a/dev/WindowsAppSDK_BootstrapDLL/WindowsAppSDK_BootstrapDLL.vcxproj +++ b/dev/WindowsAppSDK_BootstrapDLL/WindowsAppSDK_BootstrapDLL.vcxproj @@ -165,37 +165,6 @@ false Microsoft.WindowsAppSDK.Bootstrap - - - - - MultiThreadedDebug - - - - %(IgnoreSpecificDefaultLibraries);libucrtd.lib - %(AdditionalOptions) /defaultlib:ucrtd.lib - - - - - - MultiThreaded - - - - %(IgnoreSpecificDefaultLibraries);libucrt.lib - %(AdditionalOptions) /defaultlib:ucrt.lib - - - - Use diff --git a/dev/WindowsAppSDK_DLL/WindowsAppSDK_DLL.vcxproj b/dev/WindowsAppSDK_DLL/WindowsAppSDK_DLL.vcxproj index 137777935..262f460a2 100644 --- a/dev/WindowsAppSDK_DLL/WindowsAppSDK_DLL.vcxproj +++ b/dev/WindowsAppSDK_DLL/WindowsAppSDK_DLL.vcxproj @@ -171,34 +171,6 @@ false Microsoft.WindowsAppSDK - - - - MultiThreadedDebug - - - - %(IgnoreSpecificDefaultLibraries);libucrtd.lib - %(AdditionalOptions) /defaultlib:ucrtd.lib - - - - - - MultiThreaded - - - - %(IgnoreSpecificDefaultLibraries);libucrt.lib - %(AdditionalOptions) /defaultlib:ucrt.lib - - %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory);$(OutDir)..\DynamicDependency.DataStore.ProxyStub;$(SolutionDir)appmodel\identity;$(SolutionDir)common