Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable passing custom properties to NativeProjectReference items with AdditionalProperties metadata #7237

Merged
merged 1 commit into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
</PropertyGroup>
</Target>

<Target Name="GetOutputPathForProjectReference" DependsOnTargets="GetRootCMakeListsDirectory;ResolveVSGenerator" Returns="$(_CMakeProjectReferenceFilesLocation)">
<Target Name="GetOutputPathForProjectReference" DependsOnTargets="GetRootCMakeListsDirectory;ResolveVSGenerator;IsMultiConfigurationGenerator" Returns="@(_CMakeProjectReferenceFilesLocationItem)">
<PropertyGroup>
<_NormalizedReferencedCMakeListsDirectory>$([System.IO.Path]::GetDirectoryName($(ReferencedCMakeLists)))</_NormalizedReferencedCMakeListsDirectory>
</PropertyGroup>
Expand All @@ -83,6 +83,9 @@
<_CMakeProjectReferenceFilesLocation
Condition="'$(_CMakeMultiConfigurationGenerator)' == 'true'">$([MSBuild]::NormalizePath('$(_CMakeProjectReferenceFilesLocation)','$(Configuration)'))</_CMakeProjectReferenceFilesLocation>
</PropertyGroup>
<ItemGroup>
<_CMakeProjectReferenceFilesLocationItem Include="$(_CMakeProjectReferenceFilesLocation)" IsMultiConfigurationGenerator="_CMakeMultiConfigurationGenerator" />
</ItemGroup>
</Target>

<Target Name="_ResolveVSCompilerToolchainForNonVSGenerators"
Expand Down
18 changes: 8 additions & 10 deletions src/Microsoft.DotNet.CMake.Sdk/sdk/ProjectReference.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@
</Target>

<Target Name="CopyNativeProjectBinaries">
<MSBuild Projects="$(ReferencedCMakeProject)"
Targets="IsMultiConfigurationGenerator">
<Output TaskParameter="TargetOutputs" PropertyName="_IsMultiConfigurationGenerator" />
</MSBuild>

<ItemGroup Condition="'$(_IsMultiConfigurationGenerator)' == 'true'">
<ItemGroup Condition="'$(IsMultiConfigurationGenerator)' == 'true'">
<NativeProjectBinaries Include="$(NativeProjectOutputFolder)\*.*" />
</ItemGroup>
<ItemGroup Condition="'$(_IsMultiConfigurationGenerator)' != 'true'">
<ItemGroup Condition="'$(IsMultiConfigurationGenerator)' != 'true'">

<!-- ############################################################### -->
<!-- The following is required because the single configuration -->
Expand Down Expand Up @@ -122,12 +117,14 @@

<MSBuild Projects="%(NativeProjectReferenceNormalized.CMakeProject)"
Targets="GetOutputPathForProjectReference"
Properties="ReferencedCMakeLists=%(NativeProjectReferenceNormalized.Identity)">
Properties="ReferencedCMakeLists=%(NativeProjectReferenceNormalized.Identity);%(NativeProjectReferenceNormalized.AdditionalProperties)">
<Output TaskParameter="TargetOutputs" ItemName="NativeProjectOutputFoldersToCopy" />
</MSBuild>

<ItemGroup>
<_NativeProjectReferenceToBuild Include="%(NativeProjectReferenceNormalized.CMakeProject)" Condition="'%(NativeProjectReferenceNormalized.BuildNative)' == 'true'" />
<_NativeProjectReferenceToBuild Include="%(NativeProjectReferenceNormalized.CMakeProject)"
Condition="'%(NativeProjectReferenceNormalized.BuildNative)' == 'true'"
AdditionalProperties="%(NativeProjectReferenceNormalized.AdditionalProperties)" />
</ItemGroup>

<RemoveDuplicates Inputs="@(_NativeProjectReferenceToBuild)">
Expand All @@ -142,7 +139,8 @@
<MSBuild Projects="$(MSBuildProjectFile)"
Targets="CopyNativeProjectBinaries"
Properties="NativeProjectOutputFolder=%(NativeProjectOutputFoldersToCopy.Identity);
ReferencedCMakeProject=%(NativeProjectOutputFoldersToCopy.MSBuildSourceProjectFile)"
ReferencedCMakeProject=%(NativeProjectOutputFoldersToCopy.MSBuildSourceProjectFile);
IsMultiConfigurationGenerator=%(NativeProjectOutputFoldersToCopy.IsMultiConfigurationGenerator)"
Condition="'@(NativeProjectReference)' != ''" />

</Target>
Expand Down