Revert "Revert nuget to 2.0.200609.3" (#796)

* Revert "Nuget 2.0.200609.3 (#793)"

This reverts commit cfda4361db.

* Remove the use of TargetPlatformWinMDLocation as the C++ build targets put a problematic path in it.

* MSBuild only resolves refs for TargetPlatformIdentifier=UAP. C++/WinRT does it for non-UAP projects.

* Use Copy Local in the property name instead of Private.
This commit is contained in:
Johan Laanstra 2020-12-15 15:03:41 -08:00 коммит произвёл GitHub
Родитель 329b104182
Коммит ac252b2181
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
17 изменённых файлов: 640 добавлений и 54 удалений

Просмотреть файл

@ -76,4 +76,9 @@
Description="Enables or disables the generation of Windows Metadata"
Category="General" />
<BoolProperty Name="CppWinRTEnableDefaultCopyLocalFalse"
DisplayName="Enable C++/WinRT Copy Local Defaults"
Description="Enables or disables the default for copying binaries to the output folder to be false"
Category="General" />
</Rule>

Просмотреть файл

@ -23,6 +23,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<WinMDAssembly>true</WinMDAssembly>
<!--Set a value to prevent SDK's uap.props from setting it and pointing to the wrong headers-->
<CppWinRT_IncludePath>PreventSdkUapPropsAssignment</CppWinRT_IncludePath>
<CppWinRTEnableDefaultCopyLocalFalse Condition="'$(CppWinRTEnableDefaultCopyLocalFalse)' == ''"></CppWinRTEnableDefaultCopyLocalFalse>
</PropertyGroup>
<ItemDefinitionGroup>
@ -43,6 +44,18 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<ProxyFileName Condition="'%(Midl.ProxyFileName)'==''">nul</ProxyFileName>
<TypeLibraryName Condition="'%(Midl.TypeLibraryName)'==''"></TypeLibraryName>
</Midl>
<ProjectReference Condition="'$(XamlLanguage)' != 'C++' and '$(CppWinRTEnableDefaultCopyLocalFalse)' == 'true'">
<!-- By default, for a C++/WinRT project,
don't copy project reference output to the output directory
of the current project for projects that are not an exe. -->
<Private Condition="'$(ConfigurationType)' != 'Application' and '$(OutputType)'!='winexe' and '$(OutputType)'!='exe' and '$(OutputType)'!='appcontainerexe'">false</Private>
</ProjectReference>
<Reference Condition="'$(XamlLanguage)' != 'C++' and '$(CppWinRTEnableDefaultCopyLocalFalse)' == 'true'">
<!-- By default, for a C++/WinRT project,
don't copy reference output to the output directory
of the current project for projects that are not an exe. -->
<Private Condition="'$(ConfigurationType)' != 'Application' and '$(OutputType)'!='winexe' and '$(OutputType)'!='exe' and '$(OutputType)'!='appcontainerexe'">false</Private>
</Reference>
</ItemDefinitionGroup>
<ItemGroup>

Просмотреть файл

@ -21,16 +21,27 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<CppWinRTUseHardlinksIfPossible Condition="'$(CppWinRTUseHardlinksIfPossible)' == ''">false</CppWinRTUseHardlinksIfPossible>
<CppWinRTWriteOnlyWhenDifferent Condition="('$(CppWinRTWriteOnlyWhenDifferent)' == '') And (('$(MSBuildToolsVersion)' == 'Current') Or ('$(MSBuildToolsVersion)' &gt;= '15'))">true</CppWinRTWriteOnlyWhenDifferent>
<CppWinRTWriteOnlyWhenDifferent Condition="'$(CppWinRTWriteOnlyWhenDifferent)' != 'true'">false</CppWinRTWriteOnlyWhenDifferent>
<CppWinRTHasHashTask Condition="('$(CppWinRTHasHashTask)' == '') And (('$(MSBuildToolsVersion)' == 'Current'))">true</CppWinRTHasHashTask>
<CppWinRTHasHashTask Condition="'$(CppWinRTHasHashTask)' != 'true'">false</CppWinRTHasHashTask>
<CppWinRTPackageDir Condition="'$(CppWinRTPackage)' == 'true' and '$(CppWinRTPackageDir)'==''">$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)))..\..\</CppWinRTPackageDir>
<CppWinRTPackageDir Condition="'$(CppWinRTPackage)' != 'true' and '$(CppWinRTPackageDir)'==''">$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)))</CppWinRTPackageDir>
<CppWinRTParameters Condition="'$(CppWinRTFastAbi)'=='true'">$(CppWinRTParameters) -fastabi</CppWinRTParameters>
<CppWinRTPath Condition="'$(CppWinRTPackage)' == 'true' and '$(CppWinRTPath)'==''">"$(CppWinRTPackageDir)bin\"</CppWinRTPath>
<CppWinRTPath Condition="'$(CppWinRTPackage)' != 'true' and '$(CppWinRTPath)'==''">"$(CppWinRTPackageDir)"</CppWinRTPath>
<!-- By default enable C++/WinRT to include target platform winmds if we didn't overide sdk references and the C++ Project system isn't already adding them -->
<!-- _PrepareForReferenceResolution adds the references if TargetPlatformIdentifier is UAP -->
<CppWinRTImplicitlyExpandTargetPlatform Condition="'$(CppWinRTImplicitlyExpandTargetPlatform)' == '' and '$(CppWinRTOverrideSDKReferences)' != 'true' and '$(TargetPlatformIdentifier)' != 'UAP'">true</CppWinRTImplicitlyExpandTargetPlatform>
<XamlLanguage Condition="'$(CppWinRTProjectLanguage)' == 'C++/CX'">C++</XamlLanguage>
<XamlNamespace Condition="'$(XamlNamespace)' == ''">Windows.UI.Xaml</XamlNamespace>
<XamlMetaDataProviderIdl Condition="'$(XamlMetaDataProviderIdl)'== ''">$(GeneratedFilesDir)XamlMetaDataProvider.idl</XamlMetaDataProviderIdl>
<XamlMetaDataProviderCpp Condition="'$(XamlMetaDataProviderCpp)'== ''">$(GeneratedFilesDir)XamlMetaDataProvider.cpp</XamlMetaDataProviderCpp>
<CppWinRTMdMergeResponseFile Condition="'$(CppWinRTMdMergeResponseFile)'==''">$(IntDir)$(MSBuildProjectFile).mdmerge.rsp</CppWinRTMdMergeResponseFile>
<CppWinRTMidlResponseFile Condition="'$(CppWinRTMidlResponseFile)'==''">$(IntDir)$(MSBuildProjectFile).midlrt.rsp</CppWinRTMidlResponseFile>
<CppWinRTPlatformProjectionResponseFile Condition="'$(CppWinRTPlatformProjectionResponseFile)'==''">$(IntDir)$(MSBuildProjectFile).cppwinrt_plat.rsp</CppWinRTPlatformProjectionResponseFile>
<CppWinRTReferenceProjectionResponseFile Condition="'$(CppWinRTReferenceProjectionResponseFile)'==''">$(IntDir)$(MSBuildProjectFile).cppwinrt_ref.rsp</CppWinRTReferenceProjectionResponseFile>
<CppWinRTComponentProjectionResponseFile Condition="'$(CppWinRTComponentProjectionResponseFile)'==''">$(IntDir)$(MSBuildProjectFile).cppwinrt_comp.rsp</CppWinRTComponentProjectionResponseFile>
<!-- For CX projects, CppWinRT will never output a winmd-->
<!-- NOTE: We don't set a default here as the default requires evaluation of project references
and this is done by the CppWinRTComputeGenerateWindowsMetadata target. -->
@ -67,6 +78,10 @@ Copyright (C) Microsoft Corporation. All rights reserved.
GetResolvedWinMD;
CppWinRTCopyWinMDToOutputDirectory;
</AfterMidlTargets>
<ResolveReferencesDependsOn>
$(ResolveReferencesDependsOn);
CppWinRTImplicitlyExpandTargetPlatform
</ResolveReferencesDependsOn>
<ResolveAssemblyReferencesDependsOn>
$(ResolveAssemblyReferencesDependsOn);GetCppWinRTProjectWinMDReferences;CppWinRTMarkStaticLibrariesPrivate;
</ResolveAssemblyReferencesDependsOn>
@ -74,9 +89,12 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<BeforeClCompileTargets>
$(BeforeClCompileTargets);CppWinRTAddXamlMetaDataProviderCpp;CppWinRTMakeProjections;
</BeforeClCompileTargets>
<!-- Ensure ComputeCompileInputsTargets runs at the end so that FixupCLCompileOptions is the last to run -->
<ComputeCompileInputsTargets>
$(ComputeCompileInputsTargets);CppWinRTComputeXamlGeneratedCompileInputs;CppWinRTHeapEnforcementOptOut;
CppWinRTComputeXamlGeneratedCompileInputs;$(ComputeCompileInputsTargets);CppWinRTHeapEnforcementOptOut;
</ComputeCompileInputsTargets>
<MarkupCompilePass1DependsOn>
$(MarkupCompilePass1DependsOn);CppWinRTAddXamlReferences
</MarkupCompilePass1DependsOn>
@ -124,6 +142,51 @@ Copyright (C) Microsoft Corporation. All rights reserved.
</ItemGroup>
</Target>
<!--
The CppWinRTImplicitlyExpandTargetPlatform target will find the
appropriate platform in the requested SDK, gather the
list of references for that platform, and add them to the
ReferencePath item which is the ItemGroup which contains
resolved paths to pass to e.g. the compiler.
Xaml targets do this for UWP but for desktop,
apps can't opt-in to WinRT doing it for them.
-->
<Target Name="CppWinRTImplicitlyExpandTargetPlatform"
Condition="'$(CppWinRTImplicitlyExpandTargetPlatform)' == 'true'">
<ItemGroup>
<_TargetPlatformWinMDs Condition="'$(TargetPlatformSdkRootOverride)' != ''" Include="$(TargetPlatformSdkRootOverride)\References\$(XeWin10TargetVersion)\**\*.winmd">
<WinMDFile>true</WinMDFile>
<CopyLocal>false</CopyLocal>
<ReferenceGrouping>$(TargetPlatformMoniker)</ReferenceGrouping>
<ReferenceGroupingDisplayName>$(TargetPlatformDisplayName)</ReferenceGroupingDisplayName>
<ResolvedFrom>CppWinRTImplicitlyExpandTargetPlatform</ResolvedFrom>
<IsSystemReference>True</IsSystemReference>
</_TargetPlatformWinMDs>
<_TargetPlatformWinMDs Condition="'$(TargetPlatformSdkRootOverride)' == ''" Include="$(WindowsSDK_MetadataPathVersioned)\**\*.winmd">
<WinMDFile>true</WinMDFile>
<CopyLocal>false</CopyLocal>
<ReferenceGrouping>$(TargetPlatformMoniker)</ReferenceGrouping>
<ReferenceGroupingDisplayName>$(TargetPlatformDisplayName)</ReferenceGroupingDisplayName>
<ResolvedFrom>CppWinRTImplicitlyExpandTargetPlatform</ResolvedFrom>
<IsSystemReference>True</IsSystemReference>
</_TargetPlatformWinMDs>
</ItemGroup>
<Warning Condition="'@(_TargetPlatformWinMDs)' == ''"
Text="Could not find target platform winmds for the SDK specified by [$(SDKIdentifier), $(SDKVersion), $(TargetPlatformIdentifier), $(TargetPlatformMinVersion), $(TargetPlatformVersion)]"/>
<Message Importance="Low" Text="Including @(_TargetPlatformWinMDs)" />
<ItemGroup>
<ReferencePath Include="@(_TargetPlatformWinMDs)" />
<_ResolveAssemblyReferenceResolvedFiles Include="@(_TargetPlatformWinMDs)" />
<!-- Clear out 'temporary' variable -->
<_TargetPlatformWinMDs Remove="@(_TargetPlatformWinMDs)" />
</ItemGroup>
</Target>
<!-- Target used only to evaluate CppWinRTGenerateWindowsMetadata if it doesn't already have a value -->
<Target Name="CppWinRTComputeGenerateWindowsMetadata"
DependsOnTargets="CppWinRTComputeXamlGeneratedMidlInputs;GetCppWinRTProjectWinMDReferences;$(CppWinRTComputeGenerateWindowsMetadataDependsOn)">
@ -215,11 +278,11 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<!--Define platform projection WinMD inputs-->
<Target Name="GetCppWinRTPlatformWinMDInputs"
DependsOnTargets="ResolveAssemblyReferences"
DependsOnTargets="ResolveAssemblyReferences;GetCppWinRTPlatformWinMDReferences"
Returns="@(CppWinRTPlatformWinMDInputs)">
<ItemGroup>
<_CppWinRTPlatformWinMDInputs Remove="@(_CppWinRTPlatformWinMDInputs)" />
<_CppWinRTPlatformWinMDInputs Include="$(WindowsSDK_MetadataPathVersioned)\**\*.winmd" />
<_CppWinRTPlatformWinMDInputs Include="@(CppWinRTPlatformWinMDReferences)" />
<CppWinRTPlatformWinMDInputs Include="@(_CppWinRTPlatformWinMDInputs)">
<WinMDPath>%(FullPath)</WinMDPath>
</CppWinRTPlatformWinMDInputs>
@ -234,9 +297,10 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<ItemGroup>
<_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" />
<!-- Also include the winmds from the ImplicitlyExpandTargetPlatform target if it is enabled. -->
<_CppWinRTPlatformWinMDReferences Include="@(ReferencePath)" Condition="'%(ReferencePath.IsSystemReference)' == 'true' and '%(ReferencePath.WinMDFile)' == 'true' and '%(ReferencePath.ResolvedFrom)' == 'ImplicitlyExpandTargetPlatform'" />
<!-- Also include the winmds from the CppWinRTImplicitlyExpandTargetPlatform target if it is enabled. -->
<_CppWinRTPlatformWinMDReferences Include="@(ReferencePath)" Condition="'%(ReferencePath.IsSystemReference)' == 'true' and '%(ReferencePath.WinMDFile)' == 'true' and '%(ReferencePath.ResolvedFrom)' == 'CppWinRTImplicitlyExpandTargetPlatform'" />
<_CppWinRTPlatformWinMDReferences Include="$(CppWinRTSDKReferences)" />
<CppWinRTPlatformWinMDReferences Remove="@(CppWinRTPlatformWinMDReferences)"/>
<CppWinRTPlatformWinMDReferences Include="@(_CppWinRTPlatformWinMDReferences->'%(FullPath)'->Distinct())">
@ -248,11 +312,12 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<!--Get direct WinMD references (including Nuget packages) for projections, IDL processing, and AppX packaging-->
<Target Name="GetCppWinRTDirectWinMDReferences"
DependsOnTargets="ResolveAssemblyReferences;$(GetCppWinRTDirectWinMDReferencesDependsOn)"
DependsOnTargets="ExpandSDKReferences;ResolveAssemblyReferences;$(GetCppWinRTDirectWinMDReferencesDependsOn)"
Returns="@(CppWinRTDirectWinMDReferences)">
<ItemGroup>
<_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'" />
<CppWinRTDirectWinMDReferences Remove="@(CppWinRTDirectWinMDReferences)"/>
<CppWinRTDirectWinMDReferences Include="@(_CppWinRTDirectWinMDReferences)">
<WinMDPath>%(FullPath)</WinMDPath>
@ -378,10 +443,10 @@ namespace $(RootNamespace)
</PropertyGroup>
<WriteLinesToFile Condition="!$(CppWinRTWriteOnlyWhenDifferent)"
File="$(XamlMetaDataProviderIdl)" Lines="$(XamlMetaDataProviderIdlLines)"
ContinueOnError="true" Overwrite="true" />
Overwrite="true" />
<WriteLinesToFile Condition="$(CppWinRTWriteOnlyWhenDifferent)"
File="$(XamlMetaDataProviderIdl)" Lines="$(XamlMetaDataProviderIdlLines)"
ContinueOnError="true" Overwrite="true"
Overwrite="true"
WriteOnlyWhenDifferent="true" />
</Target>
@ -400,10 +465,10 @@ $(XamlMetaDataProviderPch)
</PropertyGroup>
<WriteLinesToFile Condition="!$(CppWinRTWriteOnlyWhenDifferent)"
File="$(XamlMetaDataProviderCpp)" Lines="$(XamlMetaDataProviderCppLines)"
ContinueOnError="true" Overwrite="true" />
Overwrite="true" />
<WriteLinesToFile Condition="$(CppWinRTWriteOnlyWhenDifferent)"
File="$(XamlMetaDataProviderCpp)" Lines="$(XamlMetaDataProviderCppLines)"
ContinueOnError="true" Overwrite="true"
Overwrite="true"
WriteOnlyWhenDifferent="true" />
</Target>
@ -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)">
<ItemGroup>
<_MidlReferences Remove="@(_MidlReferences)"/>
<_MidlReferences Include="@(CppWinRTDirectWinMDReferences)"/>
@ -422,7 +487,7 @@ $(XamlMetaDataProviderPch)
<_MidlReferencesDistinct Remove="@(_MidlReferencesDistinct)" />
<_MidlReferencesDistinct Include="@(_MidlReferences->'%(WinMDPath)'->Distinct())" />
<Midl Condition="'%(Midl.DisableReferences)'==''">
<AdditionalOptions>%(Midl.AdditionalOptions) %40"$(IntDir)midlrt.rsp"</AdditionalOptions>
<AdditionalOptions>%(Midl.AdditionalOptions) %40"$(CppWinRTMidlResponseFile)"</AdditionalOptions>
</Midl>
</ItemGroup>
<PropertyGroup>
@ -430,26 +495,67 @@ $(XamlMetaDataProviderPch)
</PropertyGroup>
<!-- Always write the midlrt.rsp file when the target runs, because the file is used as the output of this target. -->
<WriteLinesToFile
File="$(IntDir)midlrt.rsp" Lines="$(_MidlrtParameters)"
ContinueOnError="true" Overwrite="true" />
File="$(CppWinRTMidlResponseFile)" Lines="$(_MidlrtParameters)"
Overwrite="true" />
<Message Text="CppWinRTMidlReferences: @(_MidlReferences->'%(WinMDPath)')" Importance="$(CppWinRTVerbosity)"/>
</Target>
<!--Ctrl+F7 (selected file) midl compilation support-->
<Target Name="CppWinRTSetSelectMidlReferences" BeforeTargets="SelectMidl" DependsOnTargets="CppWinRTSetMidlReferences" />
<!--
============================================================
Generate a file used to track MdMerge dependencies between incremental build
executions. This handles cases where items are added or removed and can't
otherwise be detected with timestamp comparisons. The file contains a hash of
MdMerge inputs that are known to contribute to incremental build inconsistencies.
NOTE: this is not used when building with older MSBuild versions.
============================================================
-->
<Target Name="_CppWinRTGenerateMergeProjectWinMDDependencyCache" Condition="'$(CppWinRTHasHashTask)' == 'true'" DependsOnTargets="Midl;GetCppWinRTMdMergeInputs">
<ItemGroup>
<CustomAdditionalMdMergeInputs Include="$(IntermediateOutputPath)$(MSBuildProjectFile).MdMergeInputs.cache" />
<MdMergeCache Include="@(CppWinRTMdMergeInputs)" />
<MdMergeCache Include="@(Page)" />
<MdMergeCache Include="@(ApplicationDefinition)" />
<!-- No need to include properties here as those should be caught by having $(MSBuildAllProjects) as input to the target-->
</ItemGroup>
<Hash
ItemsToHash="@(MdMergeCache)"
IgnoreCase="$([MSBuild]::ValueOrDefault(`$(MdMergeCacheIgnoreCase)`, `true`))">
<Output TaskParameter="HashResult" PropertyName="MdMergeDependencyHash" />
</Hash>
<WriteLinesToFile Condition="!$(CppWinRTWriteOnlyWhenDifferent)"
File="$(IntermediateOutputPath)$(MSBuildProjectFile).MdMergeInputs.cache" Lines="$(MdMergeDependencyHash)"
Overwrite="true" />
<WriteLinesToFile Condition="$(CppWinRTWriteOnlyWhenDifferent)"
File="$(IntermediateOutputPath)$(MSBuildProjectFile).MdMergeInputs.cache" Lines="$(MdMergeDependencyHash)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(IntDir)$(MSBuildProjectFile).MdMergeInputs.cache" />
</ItemGroup>
</Target>
<Target Name="_CppWinRTCleanMdMergeOutputs">
<Delete Files="$(CppWinRTMdMergeResponseFile)" />
</Target>
<!--Merge project-generated WinMDs and project-referenced static library WinMDs into project WinMD-->
<Target Name="CppWinRTMergeProjectWinMDInputs"
DependsOnTargets="Midl;GetCppWinRTMdMergeInputs;$(CppWinRTMergeProjectWinMDInputsDependsOn)"
Inputs="$(MSBuildAllProjects);@(CppWinRTMdMergeInputs)"
Outputs="@(_MdMergedOutput);$(IntDir)mdmerge.rsp">
DependsOnTargets="Midl;GetCppWinRTMdMergeInputs;_CppWinRTGenerateMergeProjectWinMDDependencyCache;$(CppWinRTMergeProjectWinMDInputsDependsOn)"
Inputs="$(MSBuildAllProjects);@(CppWinRTMdMergeInputs);@(CustomAdditionalMdMergeInputs)"
Outputs="@(_MdMergedOutput);$(CppWinRTMdMergeResponseFile)">
<PropertyGroup>
<!--Note: CppWinRTNamespaceMergeDepth supersedes CppWinRTMergeDepth-->
<_MdMergeDepth Condition="'$(CppWinRTNamespaceMergeDepth)' != ''">-n:$(CppWinRTNamespaceMergeDepth)</_MdMergeDepth>
<_MdMergeDepth Condition="'$(_MdMergeDepth)' == ''">$(CppWinRTMergeDepth)</_MdMergeDepth>
<_MdMergeDepth Condition="'$(_MdMergeDepth)' == '' And '$(CppWinRTRootNamespaceAutoMerge)' == 'true'">-n:$(RootNamespace.Split('.').length)</_MdMergeDepth>
<_MdMergeDepth Condition="'$(_MdMergeDepth)' == '' And ('@(Page)' != '' Or '@(ApplicationDefinition)' != '')">-n:1</_MdMergeDepth>
<_MdMergeCommand>$(MdMergePath)mdmerge %40"$(IntDir)mdmerge.rsp"</_MdMergeCommand>
<_MdMergeCommand>$(MdMergePath)mdmerge %40"$(CppWinRTMdMergeResponseFile)"</_MdMergeCommand>
</PropertyGroup>
<PropertyGroup>
<!-- mdmerge.exe wants the folders to not have a trailing \ -->
@ -457,10 +563,12 @@ $(XamlMetaDataProviderPch)
<_MdMergeParameters>$(_MdMergeParameters) @(CppWinRTMdMergeInputs->'-i &quot;%(Identity)&quot;', '&#x0d;&#x0a;')</_MdMergeParameters>
<_MdMergeParameters>$(_MdMergeParameters) -o &quot;$(CppWinRTMergedDir.TrimEnd('\'))&quot; -partial $(_MdMergeDepth)</_MdMergeParameters>
</PropertyGroup>
<!-- Always write the mdmerge.rsp file when the target runs, because the file is used as the output of this target. -->
<WriteLinesToFile
File="$(IntDir)mdmerge.rsp" Lines="$(_MdMergeParameters)"
ContinueOnError="true" Overwrite="true" />
File="$(CppWinRTMdMergeResponseFile)" Lines="$(_MdMergeParameters)"
Overwrite="true" />
<MakeDir Directories="$(CppWinRTUnmergedDir);$(CppWinRTMergedDir)" />
<Message Text="$(_MdMergeCommand)" Importance="$(CppWinRTVerbosity)" Condition="'@(CppWinRTMdMergeInputs)' != ''" />
<!-- Only run mdmerge.exe when we actually have inputs -->
@ -470,6 +578,10 @@ $(XamlMetaDataProviderPch)
<_MdMergedOutput Include="$(CppWinRTMergedDir)*.winmd"/>
</ItemGroup>
<Message Text="CppWinRTMdMerge output: @(MdMergeOutput)" Importance="$(CppWinRTVerbosity)"/>
<!-- Clean the output file if the target failed to indicate it needs to be rebuild -->
<OnError ExecuteTargets="_CppWinRTCleanMdMergeOutputs" />
</Target>
<!-- Only copy winmd to output folder if CppWinRTGenerateWindowsMetadata is true -->
@ -485,15 +597,56 @@ $(XamlMetaDataProviderPch)
DestinationFiles="@(_MdMergedOutput->'$(OutDir)%(Filename)%(Extension)')" />
</Target>
<!-- Build the platform projection from the winmds that sip with the platform in the Windows SDK -->
<!--
============================================================
Generate a file used to track C++/WinRT platform WinMD input dependencies between incremental build
executions. This handles cases where items are added or removed and can't
otherwise be detected with timestamp comparisons. The file contains a hash of
the platform winmd inputs that are known to contribute to incremental build inconsistencies.
NOTE: this is not used when building with older MSBuild versions.
============================================================
-->
<Target Name="_CppWinRTMakePlatformProjectionDependencyCache" Condition="'$(CppWinRTHasHashTask)' == 'true'" DependsOnTargets="CppWinRTResolveReferences;GetCppWinRTPlatformWinMDInputs">
<ItemGroup>
<CustomAdditionalPlatformWinMDInputs Include="$(IntDir)$(MSBuildProjectFile).cppwinrt_plat.cache" />
<CppWinRTPlatformProjectionCache Include="@(CppWinRTPlatformWinMDInputs)" />
<!-- No need to include properties here as those should be caught by having $(MSBuildAllProjects) as input to the target-->
</ItemGroup>
<Hash
ItemsToHash="@(CppWinRTPlatformProjectionCache)"
IgnoreCase="$([MSBuild]::ValueOrDefault(`$(CppWinRTPlatformProjectionCacheIgnoreCase)`, `true`))">
<Output TaskParameter="HashResult" PropertyName="CppWinRTPlatformProjectionDependencyHash" />
</Hash>
<WriteLinesToFile Condition="!$(CppWinRTWriteOnlyWhenDifferent)"
File="$(IntDir)$(MSBuildProjectFile).cppwinrt_plat.cache"
Lines="$(CppWinRTPlatformProjectionDependencyHash)"
Overwrite="true" />
<WriteLinesToFile Condition="$(CppWinRTWriteOnlyWhenDifferent)"
File="$(IntDir)$(MSBuildProjectFile).cppwinrt_plat.cache"
Lines="$(CppWinRTPlatformProjectionDependencyHash)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(IntDir)$(MSBuildProjectFile).cppwinrt_plat.cache" />
</ItemGroup>
</Target>
<Target Name="_CppWinRTCleanMakePlatformProjectionOutputs">
<Delete Files="$(CppWinRTPlatformProjectionResponseFile)" />
</Target>
<!-- Build the platform projection from the winmds that ship with the platform in the Windows SDK -->
<!-- Note that Condition is evaluated before DependsOnTargets are run -->
<Target Name="CppWinRTMakePlatformProjection"
Condition="'$(CppWinRTEnablePlatformProjection)' == 'true' AND '$(CppWinRTOverrideSDKReferences)' != 'true'"
DependsOnTargets="GetCppWinRTPlatformWinMDInputs;$(CppWinRTMakePlatformProjectionDependsOn)"
Inputs="$(MSBuildAllProjects);@(CppWinRTPlatformWinMDInputs)"
Outputs="$(IntDir)cppwinrt_plat.rsp">
DependsOnTargets="CppWinRTResolveReferences;GetCppWinRTPlatformWinMDInputs;_CppWinRTMakePlatformProjectionDependencyCache;$(CppWinRTMakePlatformProjectionDependsOn)"
Inputs="$(MSBuildAllProjects);@(CppWinRTPlatformWinMDInputs);@(CustomAdditionalPlatformWinMDInputs)"
Outputs="$(CppWinRTPlatformProjectionResponseFile)">
<PropertyGroup>
<CppWinRTCommand>$(CppWinRTPath)cppwinrt %40"$(IntDir)cppwinrt_plat.rsp"</CppWinRTCommand>
<CppWinRTCommand>$(CppWinRTPath)cppwinrt %40"$(CppWinRTPlatformProjectionResponseFile)"</CppWinRTCommand>
</PropertyGroup>
<ItemGroup>
<_CppwinrtInputs Remove="@(_CppwinrtInputs)"/>
@ -504,23 +657,72 @@ $(XamlMetaDataProviderPch)
<_CppwinrtParameters>$(_CppwinrtParameters) @(_CppwinrtInputs->'-in &quot;%(WinMDPath)&quot;', '&#x0d;&#x0a;')</_CppwinrtParameters>
<_CppwinrtParameters>$(_CppwinrtParameters) -out &quot;$(GeneratedFilesDir).&quot;</_CppwinrtParameters>
</PropertyGroup>
<!-- Always write the cppwinrt_plat.rsp file when the target runs, because the file is used as the output of this target. -->
<WriteLinesToFile
File="$(IntDir)cppwinrt_plat.rsp" Lines="$(_CppwinrtParameters)"
ContinueOnError="true" Overwrite="true" />
File="$(CppWinRTPlatformProjectionResponseFile)" Lines="$(_CppwinrtParameters)"
Overwrite="true" />
<Message Text="$(CppWinRTCommand)" Importance="$(CppWinRTVerbosity)" Condition="'@(_CppwinrtInputs)' != ''" />
<Exec Command="$(CppWinRTCommand)" Condition="'@(_CppwinrtInputs)' != ''" />
<!-- Clean the output file if the target failed to indicate it needs to be rebuild -->
<OnError ExecuteTargets="_CppWinRTCleanMakePlatformProjectionOutputs" />
</Target>
<!--
============================================================
Generate a file used to track C++/WinRT reference WinMD input dependencies between incremental build
executions. This handles cases where items are added or removed and can't
otherwise be detected with timestamp comparisons. The file contains a hash of
the reference winmd inputs that are known to contribute to incremental build inconsistencies.
NOTE: this is not used when building with older MSBuild versions.
============================================================
-->
<Target Name="_CppWinRTMakeReferenceProjectionDependencyCache" Condition="'$(CppWinRTHasHashTask)' == 'true'" DependsOnTargets="CppWinRTResolveReferences">
<ItemGroup>
<CustomAdditionalReferenceWinMDInputs Include="$(IntDir)$(MSBuildProjectFile).cppwinrt_ref.cache" />
<CppWinRTReferenceProjectionCache Include="@(CppWinRTDirectWinMDReferences)" />
<CppWinRTReferenceProjectionCache Include="@(CppWinRTDynamicProjectWinMDReferences)" />
<CppWinRTReferenceProjectionCache Include="@(CppWinRTPlatformWinMDReferences)" />
<!-- No need to include properties here as those should be caught by having $(MSBuildAllProjects) as input to the target-->
</ItemGroup>
<Hash
ItemsToHash="@(CppWinRTReferenceProjectionCache)"
IgnoreCase="$([MSBuild]::ValueOrDefault(`$(CppWinRTReferenceProjectionCacheIgnoreCase)`, `true`))">
<Output TaskParameter="HashResult" PropertyName="CppWinRTReferenceProjectionDependencyHash" />
</Hash>
<WriteLinesToFile Condition="!$(CppWinRTWriteOnlyWhenDifferent)"
File="$(IntDir)$(MSBuildProjectFile).cppwinrt_ref.cache"
Lines="$(CppWinRTReferenceProjectionDependencyHash)"
Overwrite="true" />
<WriteLinesToFile Condition="$(CppWinRTWriteOnlyWhenDifferent)"
File="$(IntDir)$(MSBuildProjectFile).cppwinrt_ref.cache"
Lines="$(CppWinRTReferenceProjectionDependencyHash)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(IntDir)$(MSBuildProjectFile).cppwinrt_ref.cache" />
</ItemGroup>
</Target>
<Target Name="_CppWinRTCleanMakeReferenceProjectionOutputs">
<Delete Files="$(CppWinRTReferenceProjectionResponseFile)" />
</Target>
<!--Build reference projection from WinMD project references and dynamic library project references-->
<!-- Note that Condition is evaluated before DependsOnTargets are run -->
<Target Name="CppWinRTMakeReferenceProjection"
Condition="'@(CppWinRTDirectWinMDReferences)@(CppWinRTDynamicProjectWinMDReferences)' != '' AND '$(CppWinRTEnableReferenceProjection)' == 'true'"
DependsOnTargets="$(CppWinRTMakeReferenceProjectionDependsOn)"
Inputs="$(MSBuildAllProjects);@(CppWinRTDirectWinMDReferences);@(CppWinRTDynamicProjectWinMDReferences);@(CppWinRTPlatformWinMDReferences)"
Outputs="$(IntDir)cppwinrt_ref.rsp">
DependsOnTargets="CppWinRTResolveReferences;_CppWinRTMakeReferenceProjectionDependencyCache;$(CppWinRTMakeReferenceProjectionDependsOn)"
Inputs="$(MSBuildAllProjects);@(CppWinRTDirectWinMDReferences);@(CppWinRTDynamicProjectWinMDReferences);@(CppWinRTPlatformWinMDReferences);@(CustomAdditionalReferenceWinMDInputs)"
Outputs="$(CppWinRTReferenceProjectionResponseFile)">
<PropertyGroup>
<CppWinRTCommand>$(CppWinRTPath)cppwinrt %40"$(IntDir)cppwinrt_ref.rsp"</CppWinRTCommand>
<CppWinRTCommand>$(CppWinRTPath)cppwinrt %40"$(CppWinRTReferenceProjectionResponseFile)"</CppWinRTCommand>
</PropertyGroup>
<ItemGroup>
<_CppwinrtRefInputs Remove="@(_CppwinrtRefInputs)"/>
@ -535,21 +737,72 @@ $(XamlMetaDataProviderPch)
<_CppwinrtParameters>$(_CppwinrtParameters) @(_CppwinrtRefRefs->'-ref &quot;%(WinMDPath)&quot;', '&#x0d;&#x0a;')</_CppwinrtParameters>
<_CppwinrtParameters>$(_CppwinrtParameters) -out &quot;$(GeneratedFilesDir).&quot;</_CppwinrtParameters>
</PropertyGroup>
<!-- Always write the cppwinrt_ref.rsp file when the target runs, because the file is used as the output of this target. -->
<WriteLinesToFile
File="$(IntDir)cppwinrt_ref.rsp" Lines="$(_CppwinrtParameters)"
ContinueOnError="true" Overwrite="true" />
File="$(CppWinRTReferenceProjectionResponseFile)" Lines="$(_CppwinrtParameters)"
Overwrite="true" />
<Message Text="$(CppWinRTCommand)" Importance="$(CppWinRTVerbosity)" Condition="'@(_CppwinrtRefInputs)' != ''" />
<Exec Command="$(CppWinRTCommand)" Condition="'@(_CppwinrtRefInputs)' != ''" />
<!-- Clean the output file if the target failed to indicate it needs to be rebuild -->
<OnError ExecuteTargets="_CppWinRTCleanMakeReferenceProjectionOutputs" />
</Target>
<!--
============================================================
Generate a file used to track C++/WinRT reference WinMD input dependencies between incremental build
executions. This handles cases where items are added or removed and can't
otherwise be detected with timestamp comparisons. The file contains a hash of
the reference winmd inputs that are known to contribute to incremental build inconsistencies.
NOTE: this is not used when building with older MSBuild versions.
============================================================
-->
<Target Name="_CppWinRTMakeComponentProjectionDependencyCache" Condition="'$(CppWinRTHasHashTask)' == 'true'" DependsOnTargets="CppWinRTResolveReferences">
<ItemGroup>
<CustomAdditionalComponentWinMDInputs Include="$(IntDir)$(MSBuildProjectFile).cppwinrt_comp.cache" />
<CppWinRTComponentProjectionCache Include="@(CppWinRTMdMergeInputs)" />
<CppWinRTComponentProjectionCache Include="@(CppWinRTStaticProjectWinMDReferences)" />
<CppWinRTComponentProjectionCache Include="@(CppWinRTDirectWinMDReferences)"/>
<CppWinRTComponentProjectionCache Include="@(CppWinRTDynamicProjectWinMDReferences)"/>
<CppWinRTComponentProjectionCache Include="@(CppWinRTPlatformWinMDReferences)"/>
<!-- No need to include properties here as those should be caught by having $(MSBuildAllProjects) as input to the target-->
</ItemGroup>
<Hash
ItemsToHash="@(CppWinRTComponentProjectionCache)"
IgnoreCase="$([MSBuild]::ValueOrDefault(`$(CppWinRTComponentProjectionCacheIgnoreCase)`, `true`))">
<Output TaskParameter="HashResult" PropertyName="CppWinRTComponentProjectionDependencyHash" />
</Hash>
<WriteLinesToFile Condition="!$(CppWinRTWriteOnlyWhenDifferent)"
File="$(IntDir)$(MSBuildProjectFile).cppwinrt_comp.cache"
Lines="$(CppWinRTComponentProjectionDependencyHash)"
Overwrite="true" />
<WriteLinesToFile Condition="$(CppWinRTWriteOnlyWhenDifferent)"
File="$(IntDir)$(MSBuildProjectFile).cppwinrt_comp.cache"
Lines="$(CppWinRTComponentProjectionDependencyHash)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(IntDir)$(MSBuildProjectFile).cppwinrt_comp.cache" />
</ItemGroup>
</Target>
<Target Name="_CppWinRTCleanMakeComponentProjectionOutputs">
<Delete Files="$(CppWinRTComponentProjectionResponseFile)" />
</Target>
<!--Build component projection from project WinMD file and static library project references-->
<!-- Note that Condition is evaluated before DependsOnTargets are run -->
<Target Name="CppWinRTMakeComponentProjection"
Condition="'$(CppWinRTEnableComponentProjection)' == 'true'"
DependsOnTargets="GetCppWinRTMdMergeInputs;$(CppWinRTMakeComponentProjectionDependsOn)"
Inputs="$(MSBuildAllProjects);@(CppWinRTMdMergeInputs);@(CppWinRTStaticProjectWinMDReferences)"
Outputs="$(IntDir)cppwinrt_comp.rsp">
DependsOnTargets="CppWinRTResolveReferences;GetCppWinRTMdMergeInputs;_CppWinRTMakeComponentProjectionDependencyCache;$(CppWinRTMakeComponentProjectionDependsOn)"
Inputs="$(MSBuildAllProjects);@(CppWinRTMdMergeInputs);@(CppWinRTStaticProjectWinMDReferences);@(CustomAdditionalComponentWinMDInputs)"
Outputs="$(CppWinRTComponentProjectionResponseFile)">
<PropertyGroup>
<_PCH>@(ClCompile->Metadata('PrecompiledHeaderFile')->Distinct())</_PCH>
</PropertyGroup>
@ -562,7 +815,7 @@ $(XamlMetaDataProviderPch)
<PropertyGroup>
<CppWinRTCommandUsePrefixes Condition="'$(CppWinRTUsePrefixes)' == 'true'">-prefix</CppWinRTCommandUsePrefixes>
<CppWinRTCommandPrecompiledHeader Condition="'$(CppWinRTPrecompiledHeader)' != ''">-pch $(CppWinRTPrecompiledHeader)</CppWinRTCommandPrecompiledHeader>
<CppWinRTCommand>$(CppWinRTPath)cppwinrt %40"$(IntDir)cppwinrt_comp.rsp"</CppWinRTCommand>
<CppWinRTCommand>$(CppWinRTPath)cppwinrt %40"$(CppWinRTComponentProjectionResponseFile)"</CppWinRTCommand>
</PropertyGroup>
<ItemGroup>
<!-- use the output from MdMerge directly to generate the component projection. -->
@ -590,12 +843,17 @@ $(XamlMetaDataProviderPch)
<_CppwinrtParameters>$(_CppwinrtParameters) @(_CppwinrtCompRefs->'-ref &quot;%(WinMDPath)&quot;', '&#x0d;&#x0a;')</_CppwinrtParameters>
<_CppwinrtParameters>$(_CppwinrtParameters) -out &quot;$(GeneratedFilesDir).&quot;</_CppwinrtParameters>
</PropertyGroup>
<!-- Always write the cppwinrt_comp.rsp file when the target runs, because the file is used as the output of this target. -->
<WriteLinesToFile
File="$(IntDir)cppwinrt_comp.rsp" Lines="$(_CppwinrtParameters)"
ContinueOnError="true" Overwrite="true" />
File="$(CppWinRTComponentProjectionResponseFile)" Lines="$(_CppwinrtParameters)"
Overwrite="true" />
<Message Text="$(CppWinRTCommand)" Importance="$(CppWinRTVerbosity)" Condition="'@(_CppwinrtCompInputs)' != ''"/>
<Exec Command="$(CppWinRTCommand)" Condition="'@(_CppwinrtCompInputs)' != ''"/>
<!-- Clean the output file if the target failed to indicate it needs to be rebuild -->
<OnError ExecuteTargets="_CppWinRTCleanMakeComponentProjectionOutputs" />
</Target>
<Target Name="CppWinRTMakeProjections" DependsOnTargets="CppWinRTResolveReferences;CppWinRTMakePlatformProjection;CppWinRTMakeReferenceProjection;CppWinRTMakeComponentProjection;$(CppWinRTMakeProjectionsDependsOn)" />
@ -622,20 +880,20 @@ $(XamlMetaDataProviderPch)
<!--Append any additional item metadata after all default and project settings have been applied-->
<ItemDefinitionGroup>
<ClCompile>
<ClCompile>
<AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
<AdditionalOptions Condition="'%(ClCompile.LanguageStandard)' == 'stdcpp17'">%(AdditionalOptions) /await</AdditionalOptions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(GeneratedFilesDir)</AdditionalIncludeDirectories>
</ClCompile>
<Midl Condition="'$(CppWinRTModernIDL)' != 'false'">
<AdditionalMetadataDirectories Condition="'%(AdditionalMetadataDirectories)' == '' And '$(WindowsSDK_MetadataFoundationPath)' != ''">$(WindowsSDK_MetadataFoundationPath);%(AdditionalMetadataDirectories)</AdditionalMetadataDirectories>
<AdditionalMetadataDirectories Condition="'%(AdditionalMetadataDirectories)' == '' And '$(WindowsSDK_MetadataFoundationPath)' == ''">$(WindowsSDK_MetadataPath);%(AdditionalMetadataDirectories)</AdditionalMetadataDirectories>
<AdditionalOptions>%(AdditionalOptions) /nomidl</AdditionalOptions>
</Midl>
<Link>
<AdditionalDependencies Condition="'$(CppWinRTLibs)' != 'false'">%(AdditionalDependencies);WindowsApp.lib</AdditionalDependencies>
<AdditionalDependencies Condition="'$(CppWinRTFastAbi)'=='true'">%(AdditionalDependencies);$(CppWinRTPackageDir)build\native\lib\$(Platform)\cppwinrt_fast_forwarder.lib</AdditionalDependencies>
</Link>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(GeneratedFilesDir)</AdditionalIncludeDirectories>
</ClCompile>
<Midl Condition="'$(CppWinRTModernIDL)' != 'false'">
<AdditionalMetadataDirectories Condition="'%(AdditionalMetadataDirectories)' == '' And '$(WindowsSDK_MetadataFoundationPath)' != ''">$(WindowsSDK_MetadataFoundationPath);%(AdditionalMetadataDirectories)</AdditionalMetadataDirectories>
<AdditionalMetadataDirectories Condition="'%(AdditionalMetadataDirectories)' == '' And '$(WindowsSDK_MetadataFoundationPath)' == ''">$(WindowsSDK_MetadataPath);%(AdditionalMetadataDirectories)</AdditionalMetadataDirectories>
<AdditionalOptions>%(AdditionalOptions) /nomidl</AdditionalOptions>
</Midl>
<Link>
<AdditionalDependencies Condition="'$(CppWinRTLibs)' != 'false'">%(AdditionalDependencies);WindowsApp.lib</AdditionalDependencies>
<AdditionalDependencies Condition="'$(CppWinRTFastAbi)'=='true'">%(AdditionalDependencies);$(CppWinRTPackageDir)build\native\lib\$(Platform)\cppwinrt_fast_forwarder.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
</Project>

Просмотреть файл

@ -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.

Просмотреть файл

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.props')" />
<Import Project="$(ProjectDir)..\..\..\nuget\Microsoft.Windows.CppWinRT.props" />
<PropertyGroup Label="Globals">
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
<MinimalCoreWin>true</MinimalCoreWin>
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{4dd64eae-4b27-415a-863e-55cb8d5863dd}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ConsoleApplication1</RootNamespace>
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.19041.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.17134.0</WindowsTargetPlatformMinVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="PropertySheet.props" />
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.targets')" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<PreprocessorDefinitions>_CONSOLE;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level4</WarningLevel>
<AdditionalOptions>%(AdditionalOptions) /permissive- /bigobj</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="ConsoleApplication1Class.h" />
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="ConsoleApplication1Class.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="PropertySheet.props" />
<Text Include="readme.txt">
<DeploymentContent>false</DeploymentContent>
</Text>
</ItemGroup>
<ItemGroup>
<Midl Include="ConsoleApplication1Class.idl">
<SubType>Designer</SubType>
</Midl>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="$(ProjectDir)..\..\..\nuget\Microsoft.Windows.CppWinRT.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.201102.2\build\native\Microsoft.Windows.CppWinRT.targets'))" />
</Target>
</Project>

Просмотреть файл

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ConsoleApplication1Class.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ConsoleApplication1Class.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Text Include="readme.txt" />
</ItemGroup>
<ItemGroup>
<Midl Include="ConsoleApplication1Class.idl" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,10 @@
#include "pch.h"
#include "ConsoleApplication1Class.h"
#include "ConsoleApplication1Class.g.cpp"
namespace winrt::ConsoleApplication1::implementation
{
void ConsoleApplication1Class::Test()
{
}
}

Просмотреть файл

@ -0,0 +1,18 @@
#pragma once
#include "ConsoleApplication1Class.g.h"
namespace winrt::ConsoleApplication1::implementation
{
struct ConsoleApplication1Class : ConsoleApplication1ClassT<ConsoleApplication1Class>
{
ConsoleApplication1Class() = default;
void Test();
};
}
namespace winrt::ConsoleApplication1::factory_implementation
{
struct ConsoleApplication1Class : ConsoleApplication1ClassT<ConsoleApplication1Class, implementation::ConsoleApplication1Class>
{
};
}

Просмотреть файл

@ -0,0 +1,9 @@
namespace ConsoleApplication1
{
[default_interface]
runtimeclass ConsoleApplication1Class
{
ConsoleApplication1Class();
void Test();
}
}

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<!--
To customize common C++/WinRT project properties:
* right-click the project node
* expand the Common Properties item
* select the C++/WinRT property page
For more advanced scenarios, and complete documentation, please see:
https://github.com/Microsoft/cppwinrt/tree/master/nuget
-->
<PropertyGroup />
<ItemDefinitionGroup />
</Project>

Просмотреть файл

@ -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());
}

Просмотреть файл

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.201102.2" targetFramework="native" />
</packages>

Просмотреть файл

@ -0,0 +1 @@
#include "pch.h"

Просмотреть файл

@ -0,0 +1,3 @@
#pragma once
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>

Просмотреть файл

@ -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
<winrt/Windows.Foundation.h>.
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/
========================================================================

Просмотреть файл

@ -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