YY.NuGet.Import.Helper 1.0.0.2

There is a newer version of this package available.
See the version list below for details.

Requires NuGet 2.5 or higher.

dotnet add package YY.NuGet.Import.Helper --version 1.0.0.2
NuGet\Install-Package YY.NuGet.Import.Helper -Version 1.0.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="YY.NuGet.Import.Helper" Version="1.0.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add YY.NuGet.Import.Helper --version 1.0.0.2
#r "nuget: YY.NuGet.Import.Helper, 1.0.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install YY.NuGet.Import.Helper as a Cake Addin
#addin nuget:?package=YY.NuGet.Import.Helper&version=1.0.0.2

// Install YY.NuGet.Import.Helper as a Cake Tool
#tool nuget:?package=YY.NuGet.Import.Helper&version=1.0.0.2

NuGet属性表导入助手

1. 关于NuGet属性表导入助手

我们知道,C++项目大致框架如下:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    
    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
    
    
    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
    
    
    
    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
    
    
</Project>

而 NuGet原生仅仅支持二个属性表导入时机(即项目开头时,与项目结束时),这对于C++工程来说实在是太少了。比如说我们希望将属性表插入PropertySheets ImportGroup就无法做到。 而新的 PackageReference 想操作 vcxproj 更是困难,而本项目就是解决这个问题。NuGet属性表导入助手提供了4组导入时机,让我们能充分利用C++特性!

  • 在 $(VCTargetsPath)\Microsoft.Cpp.props 之前
  • 在 $(VCTargetsPath)\Microsoft.Cpp.props 之后
  • 在 $(VCTargetsPath)\Microsoft.Cpp.targets 之前
  • 在 $(VCTargetsPath)\Microsoft.Cpp.targets 之后

1.1. 兼容性

兼容 Visual Studio 2010及其以上所有IDE(不关心平台工具集版本)。

导入时机 最低支持IDE 最佳支持IDE
Microsoft.Cpp.props 之前 Visual Studio 2019 Visual Studio 2019
Microsoft.Cpp.props 之后 Visual Studio 2010 Visual Studio 2019
Microsoft.Cpp.targets 之前 Visual Studio 2010 Visual Studio 2010
Microsoft.Cpp.targets 之后 Visual Studio 2010 Visual Studio 2010

1.2. 原理

1.2.1. $(VCTargetsPath)\Microsoft.Cpp.props 之前导入

警告:Visual Studio 2019 IDE以及更高版本才能无缝使用此功能!

针对 Visual Studio 2019 IDE以及更高版本直接使用 $(VCTargetsPath)\Microsoft.Cpp.props 提供的 ForceImportBeforeCppProps 属性实现。

其他版本需要使用备选方案,在紧挨着 Microsoft.Cpp.props 之前手工添加,比如说:

<Import Condition="Exists('$(NuGetForceImportBeforeCppPropsFallback)')" Project="$(NuGetForceImportBeforeCppPropsFallback)" />

<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
1.2.2. $(VCTargetsPath)\Microsoft.Cpp.props 之后导入

针对 Visual Studio 2019 IDE以及更高版本直接采用 $(VCTargetsPath)\Microsoft.Cpp.props 提供的 ForceImportAfterCppProps 属性实现。

其他版本通过 Microsoft.Cpp.$(Platform).user.props 跳转实现,如果您的工程不加载 Microsoft.Cpp.$(Platform).user.props,那么需要使用备选方案,在紧挨着 Microsoft.Cpp.props 之后手工添加,比如说:

<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

<Import Condition="Exists('$(NuGetForceImportAfterCppPropsFallback)')" Project="$(NuGetForceImportAfterCppPropsFallback)" />

1.2.3. $(VCTargetsPath)\Microsoft.Cpp.targets 之前导入

直接使用 $(VCTargetsPath)\Microsoft.Cpp.targets 提供的 ForceImportBeforeCppTargets 属性实现。

1.2.4. $(VCTargetsPath)\Microsoft.Cpp.targets 之后导入

直接使用 $(VCTargetsPath)\Microsoft.Cpp.targets 提供的 ForceImportAfterCppTargets 属性实现。

2. 使用方式

首先需要在 nuspec 清单中设置 dependency 设置依赖于 YY.NuGet.Import.Helper 包,比如说:


<package>
    <metadata>
        
        <dependencies>
            <dependency id="YY.NuGet.Import.Helper" version="1.0.0.2" />
            
        </dependencies>
    </metadata>
    
</package>

设置完毕后,您可以按下文所述方式使用。

2.1. 如何在 $(VCTargetsPath)\Microsoft.Cpp.props 之前导入?

比如说,您需要在这个时机导入 C:\111.props,那么请在的NuGet包里的props文件添加如下内容:


<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <NuGetImportBeforeCppProps Condition="Exists('C:\111.props')">$(NuGetImportBeforeCppProps);C:\111.props</NuGetImportBeforeCppProps>
  </PropertyGroup>
</Project>

请严格按上述内容使用,不要破坏 NuGetImportBeforeCppProps 链,以免影响到其他NuGet包。

2.2. 如何在 $(VCTargetsPath)\Microsoft.Cpp.props 之后导入?

比如说,您需要在这个时机导入 C:\222.props,那么请在的NuGet包里的props文件添加如下内容:


<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <NuGetImportAfterCppProps Condition="Exists('C:\222.props')">$(NuGetImportAfterCppProps);C:\222.props</NuGetImportAfterCppProps>
  </PropertyGroup>
</Project>

请严格按上述内容使用,不要破坏 NuGetImportAfterCppProps 链,以免影响到其他NuGet包。

2.3. 如何在 $(VCTargetsPath)\Microsoft.Cpp.targets 之前导入?

比如说,您需要在这个时机导入 C:\333.props,那么请在的NuGet包里的props文件添加如下内容:


<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <NuGetImportBeforeCppTargets Condition="Exists('C:\333.props')">$(NuGetImportBeforeCppTargets);C:\333.props</NuGetImportBeforeCppTargets>
  </PropertyGroup>
</Project>

请严格按上述内容使用,不要破坏 NuGetImportBeforeCppTargets 链,以免影响到其他NuGet包。

2.4. 如何在 $(VCTargetsPath)\Microsoft.Cpp.targets 之后导入?

比如说,您需要在这个时机导入 C:\444.props,那么请在的NuGet包里的props文件添加如下内容:


<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <NuGetImportAfterCppTargets Condition="Exists('C:\444.props')">$(NuGetImportAfterCppTargets);C:\444.props</NuGetImportAfterCppTargets>
  </PropertyGroup>
</Project>

请严格按上述内容使用,不要破坏 NuGetImportAfterCppTargets 链,以免影响到其他NuGet包。

Product Compatible and additional computed target framework versions.
native native is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (11)

Showing the top 5 NuGet packages that depend on YY.NuGet.Import.Helper:

Package Downloads
VC-LTL

功能 —— 编译精巧的程序原来如此简单 * 晚起的鸟儿也有虫虫吃,优雅的引用方式,仅添加一个属性表就能享受极致的体积体验。 * 无缝使用最新C/C++库以及最新编译器,尽情的使用最新规范。神马异常流防护(guard:cf)、静态对象线程安全初始化(threadSafeInit)……统统放马过来吧!! * 拥有比微软原版更好的兼容性,即使想兼容Windows XP RTM也可以安心的对新编译器说“Yes”。 * 完全的开放代码,广泛的接受用户意见,希望大家能踊跃的 pull requests,为VC-LTL添砖加瓦。

ucxxrt

The Universal C++ RunTime library, supporting kernel-mode C++ exception-handler and STL.

zlib.static

zlib is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).

libpng.static

Reference library for supporting the Portable Network Graphics (PNG) format.

libjpeg.static

This distribution contains the ninth public release of the Independent JPEG Group's free JPEG software. You are welcome to redistribute this software and to use it for any purpose, subject to the conditions under LEGAL ISSUES, below. This software is the work of Tom Lane, Guido Vollbeding, Philip Gladstone, Bill Allombert, Jim Boucher, Lee Crocker, Bob Friesenhahn, Ben Jackson, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, Ge' Weijers, and other members of the Independent JPEG Group.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0.4 29,499 9/19/2020
1.0.0.2 16,489 1/14/2020
1.0.0.1 482 1/4/2020

* 解决Bug,Fallback 重复导入警告问题。