diff --git a/nuget/CppWinrtRules.Project.xml b/nuget/CppWinrtRules.Project.xml index 572efc31d..bd0efd57a 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..ff894eb00 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..253560b05 100644 --- a/nuget/Microsoft.Windows.CppWinRT.targets +++ b/nuget/Microsoft.Windows.CppWinRT.targets @@ -21,16 +21,27 @@ 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 +78,10 @@ Copyright (C) Microsoft Corporation. All rights reserved. GetResolvedWinMD; CppWinRTCopyWinMDToOutputDirectory; + + $(ResolveReferencesDependsOn); + CppWinRTImplicitlyExpandTargetPlatform + $(ResolveAssemblyReferencesDependsOn);GetCppWinRTProjectWinMDReferences;CppWinRTMarkStaticLibrariesPrivate; @@ -74,9 +89,12 @@ Copyright (C) Microsoft Corporation. All rights reserved. $(BeforeClCompileTargets);CppWinRTAddXamlMetaDataProviderCpp;CppWinRTMakeProjections; + + - $(ComputeCompileInputsTargets);CppWinRTComputeXamlGeneratedCompileInputs;CppWinRTHeapEnforcementOptOut; + CppWinRTComputeXamlGeneratedCompileInputs;$(ComputeCompileInputsTargets);CppWinRTHeapEnforcementOptOut; + $(MarkupCompilePass1DependsOn);CppWinRTAddXamlReferences @@ -124,6 +142,51 @@ Copyright (C) Microsoft Corporation. All rights reserved. + + + + + <_TargetPlatformWinMDs Condition="'$(TargetPlatformSdkRootOverride)' != ''" Include="$(TargetPlatformSdkRootOverride)\References\$(XeWin10TargetVersion)\**\*.winmd"> + true + false + $(TargetPlatformMoniker) + $(TargetPlatformDisplayName) + CppWinRTImplicitlyExpandTargetPlatform + True + + <_TargetPlatformWinMDs Condition="'$(TargetPlatformSdkRootOverride)' == ''" Include="$(WindowsSDK_MetadataPathVersioned)\**\*.winmd"> + true + false + $(TargetPlatformMoniker) + $(TargetPlatformDisplayName) + CppWinRTImplicitlyExpandTargetPlatform + True + + + + + + + + + + <_ResolveAssemblyReferenceResolvedFiles Include="@(_TargetPlatformWinMDs)" /> + + + <_TargetPlatformWinMDs Remove="@(_TargetPlatformWinMDs)" /> + + + @@ -215,11 +278,11 @@ Copyright (C) Microsoft Corporation. All rights reserved. <_CppWinRTPlatformWinMDInputs Remove="@(_CppWinRTPlatformWinMDInputs)" /> - <_CppWinRTPlatformWinMDInputs Include="$(WindowsSDK_MetadataPathVersioned)\**\*.winmd" /> + <_CppWinRTPlatformWinMDInputs Include="@(CppWinRTPlatformWinMDReferences)" /> %(FullPath) @@ -234,9 +297,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 +312,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 +443,10 @@ namespace $(RootNamespace) + Overwrite="true" /> @@ -400,10 +465,10 @@ $(XamlMetaDataProviderPch) + Overwrite="true" /> @@ -412,7 +477,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 +487,7 @@ $(XamlMetaDataProviderPch) <_MidlReferencesDistinct Remove="@(_MidlReferencesDistinct)" /> <_MidlReferencesDistinct Include="@(_MidlReferences->'%(WinMDPath)'->Distinct())" /> - %(Midl.AdditionalOptions) %40"$(IntDir)midlrt.rsp" + %(Midl.AdditionalOptions) %40"$(CppWinRTMidlResponseFile)" @@ -430,26 +495,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 +563,12 @@ $(XamlMetaDataProviderPch) <_MdMergeParameters>$(_MdMergeParameters) @(CppWinRTMdMergeInputs->'-i "%(Identity)"', ' ') <_MdMergeParameters>$(_MdMergeParameters) -o "$(CppWinRTMergedDir.TrimEnd('\'))" -partial $(_MdMergeDepth) + + File="$(CppWinRTMdMergeResponseFile)" Lines="$(_MdMergeParameters)" + Overwrite="true" /> + @@ -470,6 +578,10 @@ $(XamlMetaDataProviderPch) <_MdMergedOutput Include="$(CppWinRTMergedDir)*.winmd"/> + + + + @@ -485,15 +597,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 +657,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 +737,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 +815,7 @@ $(XamlMetaDataProviderPch) -prefix -pch $(CppWinRTPrecompiledHeader) - $(CppWinRTPath)cppwinrt %40"$(IntDir)cppwinrt_comp.rsp" + $(CppWinRTPath)cppwinrt %40"$(CppWinRTComponentProjectionResponseFile)" @@ -590,12 +843,17 @@ $(XamlMetaDataProviderPch) <_CppwinrtParameters>$(_CppwinrtParameters) @(_CppwinrtCompRefs->'-ref "%(WinMDPath)"', ' ') <_CppwinrtParameters>$(_CppwinrtParameters) -out "$(GeneratedFilesDir)." + + File="$(CppWinRTComponentProjectionResponseFile)" Lines="$(_CppwinrtParameters)" + Overwrite="true" /> + + + + @@ -622,20 +880,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. 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 000000000..b1f67069d Binary files /dev/null and b/test/nuget/ConsoleApplication1/ConsoleApplication1_TemporaryKey.pfx differ 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