From b4399705f001ff82dc05de741afb52ad12eeca1e Mon Sep 17 00:00:00 2001 From: Johan Laanstra Date: Mon, 16 Nov 2020 11:20:13 -0800 Subject: [PATCH 1/4] Revert "Nuget 2.0.200609.3 (#793)" This reverts commit cfda4361db9c0426cf9b5f3f8cccee0f6325fd6c. --- nuget/CppWinrtRules.Project.xml | 5 + nuget/Microsoft.Windows.CppWinRT.props | 13 + nuget/Microsoft.Windows.CppWinRT.targets | 371 +++++++++++++++++++---- nuget/readme.md | 14 +- 4 files changed, 349 insertions(+), 54 deletions(-) diff --git a/nuget/CppWinrtRules.Project.xml b/nuget/CppWinrtRules.Project.xml index 572efc31d..6be51f2f0 100644 --- a/nuget/CppWinrtRules.Project.xml +++ b/nuget/CppWinrtRules.Project.xml @@ -76,4 +76,9 @@ Description="Enables or disables the generation of Windows Metadata" Category="General" /> + + diff --git a/nuget/Microsoft.Windows.CppWinRT.props b/nuget/Microsoft.Windows.CppWinRT.props index 6e1344f40..83a737e74 100644 --- a/nuget/Microsoft.Windows.CppWinRT.props +++ b/nuget/Microsoft.Windows.CppWinRT.props @@ -23,6 +23,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. true PreventSdkUapPropsAssignment + @@ -43,6 +44,18 @@ Copyright (C) Microsoft Corporation. All rights reserved. nul + + + false + + + + false + diff --git a/nuget/Microsoft.Windows.CppWinRT.targets b/nuget/Microsoft.Windows.CppWinRT.targets index a9fe6a3e2..7eb5bd565 100644 --- a/nuget/Microsoft.Windows.CppWinRT.targets +++ b/nuget/Microsoft.Windows.CppWinRT.targets @@ -21,16 +21,26 @@ Copyright (C) Microsoft Corporation. All rights reserved. false true false + true + false $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)))..\..\ $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory))) $(CppWinRTParameters) -fastabi "$(CppWinRTPackageDir)bin\" "$(CppWinRTPackageDir)" + + true C++ Windows.UI.Xaml $(GeneratedFilesDir)XamlMetaDataProvider.idl $(GeneratedFilesDir)XamlMetaDataProvider.cpp + $(IntDir)$(MSBuildProjectFile).mdmerge.rsp + $(IntDir)$(MSBuildProjectFile).midlrt.rsp + $(IntDir)$(MSBuildProjectFile).cppwinrt_plat.rsp + $(IntDir)$(MSBuildProjectFile).cppwinrt_ref.rsp + $(IntDir)$(MSBuildProjectFile).cppwinrt_comp.rsp + @@ -67,6 +77,10 @@ Copyright (C) Microsoft Corporation. All rights reserved. GetResolvedWinMD; CppWinRTCopyWinMDToOutputDirectory; + + $(ResolveReferencesDependsOn); + CppWinRTImplicitlyExpandTargetPlatform + $(ResolveAssemblyReferencesDependsOn);GetCppWinRTProjectWinMDReferences;CppWinRTMarkStaticLibrariesPrivate; @@ -74,9 +88,12 @@ Copyright (C) Microsoft Corporation. All rights reserved. $(BeforeClCompileTargets);CppWinRTAddXamlMetaDataProviderCpp;CppWinRTMakeProjections; + + - $(ComputeCompileInputsTargets);CppWinRTComputeXamlGeneratedCompileInputs;CppWinRTHeapEnforcementOptOut; + CppWinRTComputeXamlGeneratedCompileInputs;$(ComputeCompileInputsTargets);CppWinRTHeapEnforcementOptOut; + $(MarkupCompilePass1DependsOn);CppWinRTAddXamlReferences @@ -124,6 +141,59 @@ Copyright (C) Microsoft Corporation. All rights reserved. + + + + + <_TargetPlatformWinMDs Condition="'$(TargetPlatformWinMDLocation)' != ''" Include="$(TargetPlatformWinMDLocation)\**\*.winmd"> + true + false + $(TargetPlatformMoniker) + $(TargetPlatformDisplayName) + CppWinRTImplicitlyExpandTargetPlatform + True + + <_TargetPlatformWinMDs Condition="'$(TargetPlatformSdkRootOverride)' != '' AND '$(TargetPlatformWinMDLocation)' == ''" Include="$(TargetPlatformSdkRootOverride)\References\$(XeWin10TargetVersion)\**\*.winmd"> + true + false + $(TargetPlatformMoniker) + $(TargetPlatformDisplayName) + CppWinRTImplicitlyExpandTargetPlatform + True + + <_TargetPlatformWinMDs Condition="'$(TargetPlatformSdkRootOverride)' == '' AND '$(TargetPlatformWinMDLocation)' == ''" Include="$(WindowsSDK_MetadataPathVersioned)\**\*.winmd"> + true + false + $(TargetPlatformMoniker) + $(TargetPlatformDisplayName) + CppWinRTImplicitlyExpandTargetPlatform + True + + + + + + + + + + <_ResolveAssemblyReferenceResolvedFiles Include="@(_TargetPlatformWinMDs)" /> + + + <_TargetPlatformWinMDs Remove="@(_TargetPlatformWinMDs)" /> + + + @@ -215,11 +285,11 @@ Copyright (C) Microsoft Corporation. All rights reserved. <_CppWinRTPlatformWinMDInputs Remove="@(_CppWinRTPlatformWinMDInputs)" /> - <_CppWinRTPlatformWinMDInputs Include="$(WindowsSDK_MetadataPathVersioned)\**\*.winmd" /> + <_CppWinRTPlatformWinMDInputs Include="@(CppWinRTPlatformWinMDReferences)" /> %(FullPath) @@ -234,9 +304,10 @@ Copyright (C) Microsoft Corporation. All rights reserved. <_CppWinRTPlatformWinMDReferences Remove="@(_CppWinRTPlatformWinMDReferences)" /> <_CppWinRTPlatformWinMDReferences Include="@(ReferencePath)" Condition="'%(ReferencePath.IsSystemReference)' == 'true' and '%(ReferencePath.WinMDFile)' == 'true' and '%(ReferencePath.ReferenceSourceTarget)' == 'ResolveAssemblyReference'" /> - <_CppWinRTPlatformWinMDReferences Condition="'$(CppWinRTOverrideSDKReferences)' != 'true'" Include="$(WindowsSDK_MetadataPathVersioned)\**\Windows.Foundation.FoundationContract.winmd" /> - <_CppWinRTPlatformWinMDReferences Condition="'$(CppWinRTOverrideSDKReferences)' != 'true'" Include="$(WindowsSDK_MetadataPathVersioned)\**\Windows.Foundation.UniversalApiContract.winmd" /> - <_CppWinRTPlatformWinMDReferences Condition="'$(CppWinRTOverrideSDKReferences)' != 'true'" Include="$(WindowsSDK_MetadataPathVersioned)\**\Windows.Networking.Connectivity.WwanContract.winmd" /> + + <_CppWinRTPlatformWinMDReferences Include="@(ReferencePath)" Condition="'%(ReferencePath.IsSystemReference)' == 'true' and '%(ReferencePath.WinMDFile)' == 'true' and '%(ReferencePath.ResolvedFrom)' == 'ImplicitlyExpandTargetPlatform'" /> + + <_CppWinRTPlatformWinMDReferences Include="@(ReferencePath)" Condition="'%(ReferencePath.IsSystemReference)' == 'true' and '%(ReferencePath.WinMDFile)' == 'true' and '%(ReferencePath.ResolvedFrom)' == 'CppWinRTImplicitlyExpandTargetPlatform'" /> <_CppWinRTPlatformWinMDReferences Include="$(CppWinRTSDKReferences)" /> @@ -248,11 +319,12 @@ Copyright (C) Microsoft Corporation. All rights reserved. <_CppWinRTDirectWinMDReferences Remove="@(_CppWinRTDirectWinMDReferences)" /> <_CppWinRTDirectWinMDReferences Include="@(ReferencePath)" Condition="'%(ReferencePath.IsSystemReference)' != 'true' and '%(ReferencePath.WinMDFile)' == 'true' and '%(ReferencePath.ReferenceSourceTarget)' == 'ResolveAssemblyReference'" /> + <_CppWinRTDirectWinMDReferences Include="@(ReferencePath)" Condition="'%(ReferencePath.WinMDFile)' == 'true' and '%(ReferencePath.ReferenceSourceTarget)' == 'ExpandSDKReference'" /> %(FullPath) @@ -378,10 +450,10 @@ namespace $(RootNamespace) + Overwrite="true" /> @@ -400,10 +472,10 @@ $(XamlMetaDataProviderPch) + Overwrite="true" /> @@ -412,7 +484,7 @@ $(XamlMetaDataProviderPch) Condition="'$(CppWinRTModernIDL)' != 'false'" DependsOnTargets="GetCppWinRTPlatformWinMDReferences;GetCppWinRTDirectWinMDReferences;GetCppWinRTProjectWinMDReferences;$(CppWinRTSetMidlReferencesDependsOn)" Inputs="$(MSBuildAllProjects);@(CppWinRTDirectWinMDReferences);@(CppWinRTStaticProjectWinMDReferences);@(CppWinRTDynamicProjectWinMDReferences);@(CppWinRTPlatformWinMDReferences)" - Outputs="$(IntDir)midlrt.rsp"> + Outputs="$(CppWinRTMidlResponseFile)"> <_MidlReferences Remove="@(_MidlReferences)"/> <_MidlReferences Include="@(CppWinRTDirectWinMDReferences)"/> @@ -422,7 +494,7 @@ $(XamlMetaDataProviderPch) <_MidlReferencesDistinct Remove="@(_MidlReferencesDistinct)" /> <_MidlReferencesDistinct Include="@(_MidlReferences->'%(WinMDPath)'->Distinct())" /> - %(Midl.AdditionalOptions) %40"$(IntDir)midlrt.rsp" + %(Midl.AdditionalOptions) %40"$(CppWinRTMidlResponseFile)" @@ -430,26 +502,67 @@ $(XamlMetaDataProviderPch) + File="$(CppWinRTMidlResponseFile)" Lines="$(_MidlrtParameters)" + Overwrite="true" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + DependsOnTargets="Midl;GetCppWinRTMdMergeInputs;_CppWinRTGenerateMergeProjectWinMDDependencyCache;$(CppWinRTMergeProjectWinMDInputsDependsOn)" + Inputs="$(MSBuildAllProjects);@(CppWinRTMdMergeInputs);@(CustomAdditionalMdMergeInputs)" + Outputs="@(_MdMergedOutput);$(CppWinRTMdMergeResponseFile)"> <_MdMergeDepth Condition="'$(CppWinRTNamespaceMergeDepth)' != ''">-n:$(CppWinRTNamespaceMergeDepth) <_MdMergeDepth Condition="'$(_MdMergeDepth)' == ''">$(CppWinRTMergeDepth) <_MdMergeDepth Condition="'$(_MdMergeDepth)' == '' And '$(CppWinRTRootNamespaceAutoMerge)' == 'true'">-n:$(RootNamespace.Split('.').length) <_MdMergeDepth Condition="'$(_MdMergeDepth)' == '' And ('@(Page)' != '' Or '@(ApplicationDefinition)' != '')">-n:1 - <_MdMergeCommand>$(MdMergePath)mdmerge %40"$(IntDir)mdmerge.rsp" + <_MdMergeCommand>$(MdMergePath)mdmerge %40"$(CppWinRTMdMergeResponseFile)" @@ -457,10 +570,12 @@ $(XamlMetaDataProviderPch) <_MdMergeParameters>$(_MdMergeParameters) @(CppWinRTMdMergeInputs->'-i "%(Identity)"', ' ') <_MdMergeParameters>$(_MdMergeParameters) -o "$(CppWinRTMergedDir.TrimEnd('\'))" -partial $(_MdMergeDepth) + + File="$(CppWinRTMdMergeResponseFile)" Lines="$(_MdMergeParameters)" + Overwrite="true" /> + @@ -470,6 +585,10 @@ $(XamlMetaDataProviderPch) <_MdMergedOutput Include="$(CppWinRTMergedDir)*.winmd"/> + + + + @@ -485,15 +604,56 @@ $(XamlMetaDataProviderPch) DestinationFiles="@(_MdMergedOutput->'$(OutDir)%(Filename)%(Extension)')" /> - + + + + + + + + + + + + + + + + + + + + + + + + + + DependsOnTargets="CppWinRTResolveReferences;GetCppWinRTPlatformWinMDInputs;_CppWinRTMakePlatformProjectionDependencyCache;$(CppWinRTMakePlatformProjectionDependsOn)" + Inputs="$(MSBuildAllProjects);@(CppWinRTPlatformWinMDInputs);@(CustomAdditionalPlatformWinMDInputs)" + Outputs="$(CppWinRTPlatformProjectionResponseFile)"> - $(CppWinRTPath)cppwinrt %40"$(IntDir)cppwinrt_plat.rsp" + $(CppWinRTPath)cppwinrt %40"$(CppWinRTPlatformProjectionResponseFile)" <_CppwinrtInputs Remove="@(_CppwinrtInputs)"/> @@ -504,23 +664,72 @@ $(XamlMetaDataProviderPch) <_CppwinrtParameters>$(_CppwinrtParameters) @(_CppwinrtInputs->'-in "%(WinMDPath)"', ' ') <_CppwinrtParameters>$(_CppwinrtParameters) -out "$(GeneratedFilesDir)." + + File="$(CppWinRTPlatformProjectionResponseFile)" Lines="$(_CppwinrtParameters)" + Overwrite="true" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DependsOnTargets="CppWinRTResolveReferences;_CppWinRTMakeReferenceProjectionDependencyCache;$(CppWinRTMakeReferenceProjectionDependsOn)" + Inputs="$(MSBuildAllProjects);@(CppWinRTDirectWinMDReferences);@(CppWinRTDynamicProjectWinMDReferences);@(CppWinRTPlatformWinMDReferences);@(CustomAdditionalReferenceWinMDInputs)" + Outputs="$(CppWinRTReferenceProjectionResponseFile)"> - $(CppWinRTPath)cppwinrt %40"$(IntDir)cppwinrt_ref.rsp" + $(CppWinRTPath)cppwinrt %40"$(CppWinRTReferenceProjectionResponseFile)" <_CppwinrtRefInputs Remove="@(_CppwinrtRefInputs)"/> @@ -535,21 +744,72 @@ $(XamlMetaDataProviderPch) <_CppwinrtParameters>$(_CppwinrtParameters) @(_CppwinrtRefRefs->'-ref "%(WinMDPath)"', ' ') <_CppwinrtParameters>$(_CppwinrtParameters) -out "$(GeneratedFilesDir)." + + File="$(CppWinRTReferenceProjectionResponseFile)" Lines="$(_CppwinrtParameters)" + Overwrite="true" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DependsOnTargets="CppWinRTResolveReferences;GetCppWinRTMdMergeInputs;_CppWinRTMakeComponentProjectionDependencyCache;$(CppWinRTMakeComponentProjectionDependsOn)" + Inputs="$(MSBuildAllProjects);@(CppWinRTMdMergeInputs);@(CppWinRTStaticProjectWinMDReferences);@(CustomAdditionalComponentWinMDInputs)" + Outputs="$(CppWinRTComponentProjectionResponseFile)"> <_PCH>@(ClCompile->Metadata('PrecompiledHeaderFile')->Distinct()) @@ -562,7 +822,7 @@ $(XamlMetaDataProviderPch) -prefix -pch $(CppWinRTPrecompiledHeader) - $(CppWinRTPath)cppwinrt %40"$(IntDir)cppwinrt_comp.rsp" + $(CppWinRTPath)cppwinrt %40"$(CppWinRTComponentProjectionResponseFile)" @@ -590,12 +850,17 @@ $(XamlMetaDataProviderPch) <_CppwinrtParameters>$(_CppwinrtParameters) @(_CppwinrtCompRefs->'-ref "%(WinMDPath)"', ' ') <_CppwinrtParameters>$(_CppwinrtParameters) -out "$(GeneratedFilesDir)." + + File="$(CppWinRTComponentProjectionResponseFile)" Lines="$(_CppwinrtParameters)" + Overwrite="true" /> + + + + @@ -622,20 +887,20 @@ $(XamlMetaDataProviderPch) - + %(AdditionalOptions) /bigobj %(AdditionalOptions) /await - %(AdditionalIncludeDirectories);$(GeneratedFilesDir) - - - $(WindowsSDK_MetadataFoundationPath);%(AdditionalMetadataDirectories) - $(WindowsSDK_MetadataPath);%(AdditionalMetadataDirectories) - %(AdditionalOptions) /nomidl - - - %(AdditionalDependencies);WindowsApp.lib - %(AdditionalDependencies);$(CppWinRTPackageDir)build\native\lib\$(Platform)\cppwinrt_fast_forwarder.lib - + %(AdditionalIncludeDirectories);$(GeneratedFilesDir) + + + $(WindowsSDK_MetadataFoundationPath);%(AdditionalMetadataDirectories) + $(WindowsSDK_MetadataPath);%(AdditionalMetadataDirectories) + %(AdditionalOptions) /nomidl + + + %(AdditionalDependencies);WindowsApp.lib + %(AdditionalDependencies);$(CppWinRTPackageDir)build\native\lib\$(Platform)\cppwinrt_fast_forwarder.lib + - + diff --git a/nuget/readme.md b/nuget/readme.md index 696bf1b76..4a33b8eb6 100644 --- a/nuget/readme.md +++ b/nuget/readme.md @@ -36,7 +36,7 @@ It sets the following project properties and item metadata: | XamlLanguage | CppWinRT | Directs the Xaml compiler to generate C++/WinRT code | | ClCompile.CompileAsWinRT | *false | Enables ISO C++ compilation (disables C++/CX) | | ClCompile.LanguageStandard | *stdcpp17 | Enables C++17 language features | -| ClCompile.AdditionalOptions | /bigobj /await | Enables support for large object files and coroutines | +| ClCompile.AdditionalOptions | /bigobj | Enables support for large object files | | ClCompile.AdditionalIncludeDirectories | GeneratedFilesDir | Adds $(GeneratedFilesDir) to the C++ include dirs | | Link.AdditionalDependencies | WindowsApp.lib | Umbrella library for Windows Runtime imports | | Midl.AdditionalOptions | /reference ... | Enables faster compilation with winmd references (versus idl imports) | @@ -68,6 +68,7 @@ C++/WinRT behavior can be customized with these project properties: | CppWinRTProjectLanguage | C++/CX \| *C++/WinRT | Selects the C++ dialect for the project. C++/WinRT provides full projection support, C++/CX permits consuming projection headers. | | CppWinRTOptimized | true \| *false | Enables component projection [optimization features](https://kennykerr.ca/2019/06/07/cppwinrt-optimizing-components/) | | CppWinRTGenerateWindowsMetadata | true \| *false | Indicates whether this project produces Windows Metadata | +| CppWinRTEnableDefaultPrivateFalse | true \| *false | Indicates whether this project uses C++/WinRT optimized default for copying binaries to the output directory | \*Default value To customize common C++/WinRT project properties: @@ -94,3 +95,14 @@ Example: For more complex analysis of build errors, the [MSBuild Binary and Structured Log Viewer](http://msbuildlog.com/) is highly recommended. +## Building, Testing + +Be sure to get the latest nuget.exe from [nuget.org](https://www.nuget.org/downloads) and place it in your path. + +Build the package by running [build_nuget.cmd](../build_nuget.cmd) from a developer environment command line. For testing pass a version number that is much higher than your currently installed, like: + +``` +c:\repos\cppwinrt> .\build_nuget.cmd 5.0.0.0 +``` + +Add the cppwinrt repo directory as a nuget source location and update your projects' references to point at it, update project references, then rebuild a test/sample project. From bafa470b8bae46f24b3b86dc491e9642470f2fe4 Mon Sep 17 00:00:00 2001 From: Johan Laanstra Date: Fri, 13 Nov 2020 15:08:00 -0800 Subject: [PATCH 2/4] Remove the use of TargetPlatformWinMDLocation as the C++ build targets put a problematic path in it. --- nuget/Microsoft.Windows.CppWinRT.targets | 12 +- .../ConsoleApplication1.vcxproj | 136 ++++++++++++++++++ .../ConsoleApplication1.vcxproj.filters | 46 ++++++ .../ConsoleApplication1Class.cpp | 10 ++ .../ConsoleApplication1Class.h | 18 +++ .../ConsoleApplication1Class.idl | 9 ++ .../ConsoleApplication1_TemporaryKey.pfx | Bin 0 -> 2520 bytes .../ConsoleApplication1/PropertySheet.props | 16 +++ test/nuget/ConsoleApplication1/main.cpp | 11 ++ .../nuget/ConsoleApplication1/packages.config | 4 + test/nuget/ConsoleApplication1/pch.cpp | 1 + test/nuget/ConsoleApplication1/pch.h | 3 + test/nuget/ConsoleApplication1/readme.txt | 30 ++++ test/nuget/NuGetTest.sln | 14 ++ 14 files changed, 300 insertions(+), 10 deletions(-) create mode 100644 test/nuget/ConsoleApplication1/ConsoleApplication1.vcxproj create mode 100644 test/nuget/ConsoleApplication1/ConsoleApplication1.vcxproj.filters create mode 100644 test/nuget/ConsoleApplication1/ConsoleApplication1Class.cpp create mode 100644 test/nuget/ConsoleApplication1/ConsoleApplication1Class.h create mode 100644 test/nuget/ConsoleApplication1/ConsoleApplication1Class.idl create mode 100644 test/nuget/ConsoleApplication1/ConsoleApplication1_TemporaryKey.pfx create mode 100644 test/nuget/ConsoleApplication1/PropertySheet.props create mode 100644 test/nuget/ConsoleApplication1/main.cpp create mode 100644 test/nuget/ConsoleApplication1/packages.config create mode 100644 test/nuget/ConsoleApplication1/pch.cpp create mode 100644 test/nuget/ConsoleApplication1/pch.h create mode 100644 test/nuget/ConsoleApplication1/readme.txt diff --git a/nuget/Microsoft.Windows.CppWinRT.targets b/nuget/Microsoft.Windows.CppWinRT.targets index 7eb5bd565..a25b1e8f5 100644 --- a/nuget/Microsoft.Windows.CppWinRT.targets +++ b/nuget/Microsoft.Windows.CppWinRT.targets @@ -154,7 +154,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. Condition="'$(CppWinRTImplicitlyExpandTargetPlatform)' == 'true'"> - <_TargetPlatformWinMDs Condition="'$(TargetPlatformWinMDLocation)' != ''" Include="$(TargetPlatformWinMDLocation)\**\*.winmd"> + <_TargetPlatformWinMDs Condition="'$(TargetPlatformSdkRootOverride)' != ''" Include="$(TargetPlatformSdkRootOverride)\References\$(XeWin10TargetVersion)\**\*.winmd"> true false $(TargetPlatformMoniker) @@ -162,15 +162,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. CppWinRTImplicitlyExpandTargetPlatform True - <_TargetPlatformWinMDs Condition="'$(TargetPlatformSdkRootOverride)' != '' AND '$(TargetPlatformWinMDLocation)' == ''" Include="$(TargetPlatformSdkRootOverride)\References\$(XeWin10TargetVersion)\**\*.winmd"> - true - false - $(TargetPlatformMoniker) - $(TargetPlatformDisplayName) - CppWinRTImplicitlyExpandTargetPlatform - True - - <_TargetPlatformWinMDs Condition="'$(TargetPlatformSdkRootOverride)' == '' AND '$(TargetPlatformWinMDLocation)' == ''" Include="$(WindowsSDK_MetadataPathVersioned)\**\*.winmd"> + <_TargetPlatformWinMDs Condition="'$(TargetPlatformSdkRootOverride)' == ''" Include="$(WindowsSDK_MetadataPathVersioned)\**\*.winmd"> true false $(TargetPlatformMoniker) diff --git a/test/nuget/ConsoleApplication1/ConsoleApplication1.vcxproj b/test/nuget/ConsoleApplication1/ConsoleApplication1.vcxproj new file mode 100644 index 000000000..86453e25f --- /dev/null +++ b/test/nuget/ConsoleApplication1/ConsoleApplication1.vcxproj @@ -0,0 +1,136 @@ + + + + + + true + true + true + true + 15.0 + {4dd64eae-4b27-415a-863e-55cb8d5863dd} + Win32Proj + ConsoleApplication1 + 10.0.19041.0 + 10.0.17134.0 + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + Application + v140 + v141 + v142 + Unicode + + + true + true + + + false + true + false + + + + + + + + + + + + + + + + + Use + pch.h + $(IntDir)pch.pch + _CONSOLE;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions) + Level4 + %(AdditionalOptions) /permissive- /bigobj + + + + + Disabled + _DEBUG;%(PreprocessorDefinitions) + + + Console + false + + + + + WIN32;%(PreprocessorDefinitions) + + + + + MaxSpeed + true + true + NDEBUG;%(PreprocessorDefinitions) + + + Console + true + true + false + + + + + + + + + + + Create + + + + + + + false + + + + + Designer + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/test/nuget/ConsoleApplication1/ConsoleApplication1.vcxproj.filters b/test/nuget/ConsoleApplication1/ConsoleApplication1.vcxproj.filters new file mode 100644 index 000000000..8b6a45974 --- /dev/null +++ b/test/nuget/ConsoleApplication1/ConsoleApplication1.vcxproj.filters @@ -0,0 +1,46 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/nuget/ConsoleApplication1/ConsoleApplication1Class.cpp b/test/nuget/ConsoleApplication1/ConsoleApplication1Class.cpp new file mode 100644 index 000000000..59b01f8cf --- /dev/null +++ b/test/nuget/ConsoleApplication1/ConsoleApplication1Class.cpp @@ -0,0 +1,10 @@ +#include "pch.h" +#include "ConsoleApplication1Class.h" +#include "ConsoleApplication1Class.g.cpp" + +namespace winrt::ConsoleApplication1::implementation +{ + void ConsoleApplication1Class::Test() + { + } +} diff --git a/test/nuget/ConsoleApplication1/ConsoleApplication1Class.h b/test/nuget/ConsoleApplication1/ConsoleApplication1Class.h new file mode 100644 index 000000000..70a3cf506 --- /dev/null +++ b/test/nuget/ConsoleApplication1/ConsoleApplication1Class.h @@ -0,0 +1,18 @@ +#pragma once +#include "ConsoleApplication1Class.g.h" + +namespace winrt::ConsoleApplication1::implementation +{ + struct ConsoleApplication1Class : ConsoleApplication1ClassT + { + ConsoleApplication1Class() = default; + + void Test(); + }; +} +namespace winrt::ConsoleApplication1::factory_implementation +{ + struct ConsoleApplication1Class : ConsoleApplication1ClassT + { + }; +} diff --git a/test/nuget/ConsoleApplication1/ConsoleApplication1Class.idl b/test/nuget/ConsoleApplication1/ConsoleApplication1Class.idl new file mode 100644 index 000000000..dd086b0bb --- /dev/null +++ b/test/nuget/ConsoleApplication1/ConsoleApplication1Class.idl @@ -0,0 +1,9 @@ +namespace ConsoleApplication1 +{ + [default_interface] + runtimeclass ConsoleApplication1Class + { + ConsoleApplication1Class(); + void Test(); + } +} diff --git a/test/nuget/ConsoleApplication1/ConsoleApplication1_TemporaryKey.pfx b/test/nuget/ConsoleApplication1/ConsoleApplication1_TemporaryKey.pfx new file mode 100644 index 0000000000000000000000000000000000000000..b1f67069d42d1e64062ed5913a05bcad7d1339f1 GIT binary patch literal 2520 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 literal 0 HcmV?d00001 diff --git a/test/nuget/ConsoleApplication1/PropertySheet.props b/test/nuget/ConsoleApplication1/PropertySheet.props new file mode 100644 index 000000000..b0c622690 --- /dev/null +++ b/test/nuget/ConsoleApplication1/PropertySheet.props @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/test/nuget/ConsoleApplication1/main.cpp b/test/nuget/ConsoleApplication1/main.cpp new file mode 100644 index 000000000..d5b806548 --- /dev/null +++ b/test/nuget/ConsoleApplication1/main.cpp @@ -0,0 +1,11 @@ +#include "pch.h" + +using namespace winrt; +using namespace Windows::Foundation; + +int main() +{ + init_apartment(); + Uri uri(L"http://aka.ms/cppwinrt"); + printf("Hello, %ls!\n", uri.AbsoluteUri().c_str()); +} diff --git a/test/nuget/ConsoleApplication1/packages.config b/test/nuget/ConsoleApplication1/packages.config new file mode 100644 index 000000000..be196b1fc --- /dev/null +++ b/test/nuget/ConsoleApplication1/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/test/nuget/ConsoleApplication1/pch.cpp b/test/nuget/ConsoleApplication1/pch.cpp new file mode 100644 index 000000000..bcb5590be --- /dev/null +++ b/test/nuget/ConsoleApplication1/pch.cpp @@ -0,0 +1 @@ +#include "pch.h" diff --git a/test/nuget/ConsoleApplication1/pch.h b/test/nuget/ConsoleApplication1/pch.h new file mode 100644 index 000000000..2eec5b922 --- /dev/null +++ b/test/nuget/ConsoleApplication1/pch.h @@ -0,0 +1,3 @@ +#pragma once +#include +#include diff --git a/test/nuget/ConsoleApplication1/readme.txt b/test/nuget/ConsoleApplication1/readme.txt new file mode 100644 index 000000000..706ccef4d --- /dev/null +++ b/test/nuget/ConsoleApplication1/readme.txt @@ -0,0 +1,30 @@ +======================================================================== + C++/WinRT ConsoleApplication1 Project Overview +======================================================================== + +This project demonstrates how to get started consuming Windows Runtime +classes directly from standard C++, using platform projection headers +generated from Windows SDK metadata files. + +Steps to generate and consume SDK platform projection: +1. Build project initally to generate platform projection headers into + your Generated Files folder. +2. Include a projection namespace header in your pch.h, such as + . +3. Consume winrt namespace and any Windows Runtime namespaces, such as + winrt::Windows::Foundation, from source code. +4. Initialize apartment via init_apartment() and consume winrt classes. + +Steps to generate and consume a projection from third party metadata: +1. Add a WinMD reference by right-clicking the References project node + and selecting "Add Reference...". In the Add References dialog, + browse to the component WinMD you want to consume and add it. +2. Build the project once to generate projection headers for the + referenced WinMD file under the "Generated Files" subfolder. +3. As above, include projection headers in pch or source code + to consume projected Windows Runtime classes. + +======================================================================== +Learn more about C++/WinRT here: +http://aka.ms/cppwinrt/ +======================================================================== diff --git a/test/nuget/NuGetTest.sln b/test/nuget/NuGetTest.sln index 11490b8c0..24b81d177 100644 --- a/test/nuget/NuGetTest.sln +++ b/test/nuget/NuGetTest.sln @@ -43,6 +43,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestRuntimeComponentCXRefer EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestStaticLibrary7", "TestStaticLibrary7\TestStaticLibrary7.vcxproj", "{F89C2185-7834-443D-A449-53BD52FFEA3B}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConsoleApplication1", "ConsoleApplication1\ConsoleApplication1.vcxproj", "{4DD64EAE-4B27-415A-863E-55CB8D5863DD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -287,6 +289,18 @@ Global {F89C2185-7834-443D-A449-53BD52FFEA3B}.Release|x64.Build.0 = Release|x64 {F89C2185-7834-443D-A449-53BD52FFEA3B}.Release|x86.ActiveCfg = Release|Win32 {F89C2185-7834-443D-A449-53BD52FFEA3B}.Release|x86.Build.0 = Release|Win32 + {4DD64EAE-4B27-415A-863E-55CB8D5863DD}.Debug|ARM.ActiveCfg = Debug|Win32 + {4DD64EAE-4B27-415A-863E-55CB8D5863DD}.Debug|ARM64.ActiveCfg = Debug|Win32 + {4DD64EAE-4B27-415A-863E-55CB8D5863DD}.Debug|x64.ActiveCfg = Debug|x64 + {4DD64EAE-4B27-415A-863E-55CB8D5863DD}.Debug|x64.Build.0 = Debug|x64 + {4DD64EAE-4B27-415A-863E-55CB8D5863DD}.Debug|x86.ActiveCfg = Debug|Win32 + {4DD64EAE-4B27-415A-863E-55CB8D5863DD}.Debug|x86.Build.0 = Debug|Win32 + {4DD64EAE-4B27-415A-863E-55CB8D5863DD}.Release|ARM.ActiveCfg = Release|Win32 + {4DD64EAE-4B27-415A-863E-55CB8D5863DD}.Release|ARM64.ActiveCfg = Release|Win32 + {4DD64EAE-4B27-415A-863E-55CB8D5863DD}.Release|x64.ActiveCfg = Release|x64 + {4DD64EAE-4B27-415A-863E-55CB8D5863DD}.Release|x64.Build.0 = Release|x64 + {4DD64EAE-4B27-415A-863E-55CB8D5863DD}.Release|x86.ActiveCfg = Release|Win32 + {4DD64EAE-4B27-415A-863E-55CB8D5863DD}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 1d4bd753e13ecf553b1f14b08fc95dc86089aeba Mon Sep 17 00:00:00 2001 From: Johan Laanstra Date: Mon, 7 Dec 2020 11:26:53 -0800 Subject: [PATCH 3/4] MSBuild only resolves refs for TargetPlatformIdentifier=UAP. C++/WinRT does it for non-UAP projects. --- nuget/Microsoft.Windows.CppWinRT.targets | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nuget/Microsoft.Windows.CppWinRT.targets b/nuget/Microsoft.Windows.CppWinRT.targets index a25b1e8f5..253560b05 100644 --- a/nuget/Microsoft.Windows.CppWinRT.targets +++ b/nuget/Microsoft.Windows.CppWinRT.targets @@ -28,8 +28,9 @@ Copyright (C) Microsoft Corporation. All rights reserved. $(CppWinRTParameters) -fastabi "$(CppWinRTPackageDir)bin\" "$(CppWinRTPackageDir)" - - true + + + true C++ Windows.UI.Xaml $(GeneratedFilesDir)XamlMetaDataProvider.idl From e83377aa7bb3d54b0c91e8e8a2a7f71ca8c1848e Mon Sep 17 00:00:00 2001 From: Johan Laanstra Date: Thu, 10 Dec 2020 17:30:33 -0800 Subject: [PATCH 4/4] Use Copy Local in the property name instead of Private. --- nuget/CppWinrtRules.Project.xml | 6 +++--- nuget/Microsoft.Windows.CppWinRT.props | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nuget/CppWinrtRules.Project.xml b/nuget/CppWinrtRules.Project.xml index 6be51f2f0..bd0efd57a 100644 --- a/nuget/CppWinrtRules.Project.xml +++ b/nuget/CppWinrtRules.Project.xml @@ -76,9 +76,9 @@ Description="Enables or disables the generation of Windows Metadata" Category="General" /> - diff --git a/nuget/Microsoft.Windows.CppWinRT.props b/nuget/Microsoft.Windows.CppWinRT.props index 83a737e74..ff894eb00 100644 --- a/nuget/Microsoft.Windows.CppWinRT.props +++ b/nuget/Microsoft.Windows.CppWinRT.props @@ -23,7 +23,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. true PreventSdkUapPropsAssignment - + @@ -44,13 +44,13 @@ Copyright (C) Microsoft Corporation. All rights reserved. nul - + false - +