-
Notifications
You must be signed in to change notification settings - Fork 0
/
YY.NuGet.Import.Helper.targets
66 lines (59 loc) · 4.48 KB
/
YY.NuGet.Import.Helper.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
<Target Name="EnsureNuGetImportsOK" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<NuGetImportBeforeCppPropsHelpText>NuGetImportBeforeCppProps 存在未执行导入动作,请考虑备选方案在紧挨着 “<Import Project="%24(VCTargetsPath)\Microsoft.Cpp.props" />” 之前插入:“<Import Condition="Exists('%24(NuGetForceImportBeforeCppPropsFallback)')" Project="%24(NuGetForceImportBeforeCppPropsFallback)" />”。</NuGetImportBeforeCppPropsHelpText>
<NuGetImportAfterCppPropsHelpText>NuGetImportAfterCppProps 存在未执行导入动作,请考虑备选方案在紧挨着 “<Import Project="%24(VCTargetsPath)\Microsoft.Cpp.props" />” 之后插入:“<Import Condition="Exists('%24(NuGetForceImportAfterCppPropsFallback)')" Project="%24(NuGetForceImportAfterCppPropsFallback)" />”。</NuGetImportAfterCppPropsHelpText>
</PropertyGroup>
<Error Condition="'$(NuGetImportBeforeCppPropsComplete)' != 'true' and '$(NuGetImportBeforeCppProps)' != ''" Text="$(NuGetImportBeforeCppPropsHelpText)" />
<Error Condition="'$(NuGetImportAfterCppPropsComplete)' != 'true' and '$(NuGetImportAfterCppProps)' != ''" Text="$(NuGetImportAfterCppPropsHelpText)" />
</Target>
<!--只有VS2017或者更高版本自带的MSBuild才支持 Update,所以我们对只在 $(VisualStudioVersion) >= 15.0 上尝试插入NuGet源码包-->
<!--处理NuGet PackageReference引用的Content-->
<Target Name="YY_ResolveNuGetPackagesPackageReferenceContent" AfterTargets="BeforeClCompile" Outputs="'%(Content.FileName)'" Condition="'$(VisualStudioVersion)' >= '15.0'">
<PropertyGroup>
<ThisNuGetPackageId>%(Content.FileName)</ThisNuGetPackageId>
<ThisNuGetPackageId Condition="'%(Content.FileName)' != '%(Content.NuGetPackageId)'"></ThisNuGetPackageId>
<ThisNuGetPackageVersion>%(Content.NuGetPackageVersion)</ThisNuGetPackageVersion>
</PropertyGroup>
<ItemGroup Condition="'$(ThisNuGetPackageId)' != ''">
<NuGetExConnentFiles Update="@(NuGetExConnentFiles)" Condition="'%(NuGetExConnentFiles.ExcludedFromBuild)' == '' and '%(NuGetExConnentFiles.NuGetPackageId)' == '$(ThisNuGetPackageId)'">
<ExcludedFromBuild>false</ExcludedFromBuild>
<NuGetPackageVersion Condition="'$(ThisNuGetPackageVersion)' != ''">$(ThisNuGetPackageVersion)</NuGetPackageVersion>
</NuGetExConnentFiles>
</ItemGroup>
</Target>
<!--处理传统NuGet引用的Content-->
<!--2008工具集添加Txt后会变成None节点,因此我们再额外处理下None-->
<Target Name="YY_ResolveNuGetPackagesNoneContent" AfterTargets="BeforeClCompile" Outputs="'%(None.FileName)'" Condition="'$(VisualStudioVersion)' >= '15.0'" >
<PropertyGroup>
<ThisNuGetPackageId>%(None.FileName)</ThisNuGetPackageId>
<ThisNuGetPackageExcludedFromBuild>%(None.ExcludedFromBuild)</ThisNuGetPackageExcludedFromBuild>
</PropertyGroup>
<ItemGroup Condition="'$(ThisNuGetPackageExcludedFromBuild)' != 'true'">
<NuGetExConnentFiles Update="@(NuGetExConnentFiles)" Condition="'%(NuGetExConnentFiles.ExcludedFromBuild)' == '' and '%(NuGetExConnentFiles.NuGetPackageId)' == '$(ThisNuGetPackageId)'">
<ExcludedFromBuild>false</ExcludedFromBuild>
</NuGetExConnentFiles>
</ItemGroup>
</Target>
<!--2012开始 IDE 支持Text了,我们解析下 Text-->
<Target Name="YY_ResolveNuGetPackagesTextContent" AfterTargets="BeforeClCompile" Outputs="'%(Text.FileName)'" Condition="'$(VisualStudioVersion)' >= '15.0'" >
<PropertyGroup>
<ThisNuGetPackageId>%(Text.FileName)</ThisNuGetPackageId>
<ThisNuGetPackageExcludedFromBuild>%(Text.ExcludedFromBuild)</ThisNuGetPackageExcludedFromBuild>
</PropertyGroup>
<ItemGroup Condition="'$(ThisNuGetPackageExcludedFromBuild)' != 'true'">
<NuGetExConnentFiles Update="@(NuGetExConnentFiles)" Condition="'%(NuGetExConnentFiles.ExcludedFromBuild)' == '' and '%(NuGetExConnentFiles.NuGetPackageId)' == '$(ThisNuGetPackageId)'">
<ExcludedFromBuild>false</ExcludedFromBuild>
</NuGetExConnentFiles>
</ItemGroup>
</Target>
<!--处理将项插入内存中-->
<Target Name="YY_ResolveNuGetPackages" AfterTargets="BeforeClCompile">
<CreateItem
Condition="'%(NuGetExConnentFiles.ExcludedFromBuild)' == 'false'"
Include="@(NuGetExConnentFiles)">
<Output TaskParameter="Include" ItemName="%(NuGetExConnentFiles.BuildAction)"/>
</CreateItem>
</Target>
</Project>