diff --git a/nuget/Microsoft.Windows.CppWinRT.targets b/nuget/Microsoft.Windows.CppWinRT.targets index a9fe6a3e2..da3756ebb 100644 --- a/nuget/Microsoft.Windows.CppWinRT.targets +++ b/nuget/Microsoft.Windows.CppWinRT.targets @@ -124,6 +124,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)" /> + + + 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