Skip to content
Closed
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
36 changes: 33 additions & 3 deletions src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.targets
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,36 @@ Copyright (c) .NET Foundation. All rights reserved.
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>

<!--
C++ has different toolsets, such as v140 (VS2015), v141 (VS2017), v142 (VS2019)

VS2017 toosets: 14.10.25017, 14.11.25503, 14.12.25827, 14.13.26128 ...
VS2019 toosets: 14.20.27508, 14.21.27702, 14.22.27905, 14.23.28105 ...
-->
<PropertyGroup Condition="'$(Language)' == 'C++'">
<!--
VS2017 VS2019 support VCToolsVersion, like:
14.16.27023 (2017)
14.20.27508 (2019)
14.24.28314 (2019)
-->
<NuGetVCToolsVersion>$(VCToolsVersion)</NuGetVCToolsVersion>

<!--
others using PlatformToolsetVersion

if PlatformToolsetVersion = 140, then NuGetVCToolsVersion = 14.0
if PlatformToolsetVersion = 141, then NuGetVCToolsVersion = 14.10

-->
<NuGetVCToolsVersion Condition="'$(NuGetVCToolsVersion)' == '' and '$(PlatformToolsetVersion)' != '' and '$([MSBuild]::Modulo($(PlatformToolsetVersion), 10))' == '0'">$([MSBuild]::Divide($(PlatformToolsetVersion),10).ToString('f1'))</NuGetVCToolsVersion>
<NuGetVCToolsVersion Condition="'$(NuGetVCToolsVersion)' == '' and '$(PlatformToolsetVersion)' != ''">$([MSBuild]::Divide($(PlatformToolsetVersion),10).ToString('f2'))</NuGetVCToolsVersion>


<NuGetTargetMoniker Condition="'$(NuGetTargetMoniker)' == ''">native,Version=v$([MSBuild]::ValueOrDefault('$(NuGetVCToolsVersion)', '0.0'))</NuGetTargetMoniker>
<TargetFramework Condition="'$(TargetFramework)' == ''">native$(NuGetVCToolsVersion)</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<ResolveNuGetPackages Condition="'$(ResolveNuGetPackages)' == '' and '$(MSBuildProjectExtension)' != '.xproj'">true</ResolveNuGetPackages>

Expand Down Expand Up @@ -98,7 +128,7 @@ Copyright (c) .NET Foundation. All rights reserved.

<!-- If RuntimeIdentifiers weren't already specified for non-UAP projects, then generate it -->
<PropertyGroup Condition="'$(BaseNuGetRuntimeIdentifier)' == 'win' and '$(NuGetRuntimeIdentifier)' != '' and '$(RuntimeIdentifiers)' == '' and '$(RuntimeIdentifier)' == ''">
<RuntimeIdentifiers>win;win-x86;win-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win;win-x86;win-x64;win-arm;win-arm64</RuntimeIdentifiers>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -228,7 +258,7 @@ Copyright (c) .NET Foundation. All rights reserved.

<!-- The items in _NuGetContentItems need to go into the appropriately-named item group, but the names depend upon the items
themselves. Split it apart. -->
<CreateItem Include="@(_NuGetContentItems)" Condition="'@(_NuGetContentItems)' != ''">
<CreateItem Include="@(_NuGetContentItems)" AdditionalMetadata="PrecompiledHeader=NotUsing" Condition="'@(_NuGetContentItems)' != ''">

@mingkuang-Chuyu mingkuang-Chuyu Dec 25, 2019 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PrecompiledHeader is unique to C++ projects, and this option reduces the generality of the asset. Because we don't know if the project has precompiled headers enabled. And we don't know the name of the precompiled header file.

For other projects adding PrecompiledHeader, nothing will happen.

So we can add “PrecompiledHeader=NotUsing”.

<Output TaskParameter="Include" ItemName="%(_NuGetContentItems.NuGetItemType)" />
</CreateItem>
</Target>
Expand Down Expand Up @@ -304,7 +334,7 @@ Copyright (c) .NET Foundation. All rights reserved.

<!-- The items in _NuGetContentItems need to go into the appropriately-named item group, but the names depend upon the items
themselves. Split it apart. -->
<CreateItem Include="@(_NuGetContentItems)" Condition="'@(_NuGetContentItems)' != ''">
<CreateItem Include="@(_NuGetContentItems)" AdditionalMetadata="PrecompiledHeader=NotUsing" Condition="'@(_NuGetContentItems)' != ''">
<Output TaskParameter="Include" ItemName="%(_NuGetContentItems.NuGetItemType)" />
</CreateItem>
</Target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ private static string GetNuGetLanguageName(string projectLanguage)
{
case "C#": return "cs";
case "F#": return "fs";
case "C++": return "cpp";
default: return projectLanguage.ToLowerInvariant();
}
}
Expand Down