-
Notifications
You must be signed in to change notification settings - Fork 3
/
Build.proj
96 lines (87 loc) · 5.45 KB
/
Build.proj
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?xml version="1.0" encoding="utf-8"?>
<!--
MSBuild.exe "Build.proj"
-->
<Project InitialTargets="ValidateSolutionConfiguration" DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(_GetProjectAllConfiguration)' != 'true'">
<GlobalProperties></GlobalProperties>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)MSBuildCppTasks.sln">
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<AdditionalProperties>Configuration=%(Configuration);Platform=%(Platform)</AdditionalProperties>
</ProjectReference>
</ItemGroup>
<Target Name="ValidateSolutionConfiguration">
<Message Text="正在生成解决方案配置“$(Configuration)|$(Platform)”。" />
</Target>
<Target Name="Build">
<!--包还原-->
<MSBuild Projects="@(ProjectReference)" Targets="Restore" StopOnFirstFailure="True" Properties="$(GlobalProperties)"/>
<!--启动编译-->
<MSBuild Projects="@(ProjectReference)" StopOnFirstFailure="True" BuildInParallel="True" Properties="$(GlobalProperties)"/>
<RemoveDir Directories="$(MSBuildThisFileDirectory)\Release"/>
<!--复制文件到产出目录-->
<ItemGroup>
<VCTargetsFiles Include="$(MSBuildThisFileDirectory)\VCTargets\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="@(VCTargetsFiles)" DestinationFiles="$(MSBuildThisFileDirectory)\Release\VCTargets\%(RecursiveDir)%(Filename)%(Extension)" />
<Copy SourceFiles="$(MSBuildThisFileDirectory)\Microsoft.Build.CppTasks.Common\bin\Release\net6.0\Microsoft.Build.CppTasks.Common.dll" DestinationFolder="$(MSBuildThisFileDirectory)\Release\VCTargets\v170" />
<PropertyGroup>
<ApplicationTypeDefaultPropsRootPath>$(MSBuildThisFileDirectory)VCTargets\v170\Application Type\</ApplicationTypeDefaultPropsRootPath>
</PropertyGroup>
<ItemGroup>
<ApplicationTypeDefaultPropsPath Include="$(ApplicationTypeDefaultPropsRootPath)\*\Default.props"/>
</ItemGroup>
<ItemGroup>
<ApplicationType
Include="@(ApplicationTypeDefaultPropsPath->Remove(0, $(ApplicationTypeDefaultPropsRootPath.Length))->Replace('\Default.props','')->Replace('/Default.props',''))"/>
</ItemGroup>
<MSBuild Projects="$(MSBuildThisFileFullPath)" StopOnFirstFailure="True" Targets="CopyApplicationTypeFiles" BuildInParallel="True" Properties="CurrentApplicationType=%(ApplicationType.Identity)"/>
<!--复制Patch文件-->
<ItemGroup>
<PatchFiles Include="$(MSBuildThisFileDirectory)\Patch\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="@(PatchFiles)" DestinationFiles="$(MSBuildThisFileDirectory)\Release\VCTargets\%(RecursiveDir)%(Filename)%(Extension)" />
<!--下载NuGet还原插件-->
<DownloadFile
Condition="!Exists('$(MSBuildThisFileDirectory)Release\NuGet.zip')"
SourceUrl="https://github.com/mingkuang-Chuyu/NuGet.BuildTasks/releases/download/v1.0.0/NuGet.zip"
DestinationFolder="$(MSBuildThisFileDirectory)Release" DestinationFileName="NuGet.zip"/>
<Unzip
SourceFiles="$(MSBuildThisFileDirectory)Release\NuGet.zip"
DestinationFolder="$(MSBuildThisFileDirectory)Release\VCTargets\v170\Microsoft\NuGet"
OverwriteReadOnlyFiles="true"/>
</Target>
<Target Name="CopyApplicationTypeFiles">
<PropertyGroup>
<PlatformsRootPath>$(MSBuildThisFileDirectory)VCTargets\v170\Application Type\$(CurrentApplicationType)\1.0\Platforms\</PlatformsRootPath>
</PropertyGroup>
<ItemGroup>
<PlatformsPath Include="$(PlatformsRootPath)*\Platform.props"/>
</ItemGroup>
<ItemGroup>
<PlatformsName
Include="@(PlatformsPath->Remove(0, $(PlatformsRootPath.Length))->Replace('\Platform.props','')->Replace('/Platform.props',''))"/>
</ItemGroup>
<MSBuild Projects="$(MSBuildThisFileFullPath)" StopOnFirstFailure="True" Targets="CopyPlatformToolsetsFiles" BuildInParallel="True" Properties="CurrentPlatformName=%(PlatformsName.Identity)"/>
</Target>
<Target Name="CopyPlatformToolsetsFiles">
<ItemGroup>
<PlatformsRootFiles Include="$(MSBuildThisFileDirectory)\YY.Build.Cross.Tasks\Targets\$(CurrentApplicationType)\*.*"/>
<PlatformsFiles Include="$(MSBuildThisFileDirectory)\YY.Build.Cross.Tasks\Targets\$(CurrentApplicationType)\Platforms\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="@(PlatformsRootFiles)" DestinationFolder="$(MSBuildThisFileDirectory)\Release\VCTargets\v170\Application Type\$(CurrentApplicationType)\1.0" />
<Copy SourceFiles="@(PlatformsFiles)" DestinationFiles="$(MSBuildThisFileDirectory)\Release\VCTargets\v170\Application Type\$(CurrentApplicationType)\1.0\Platforms\$(CurrentPlatformName)\PlatformToolsets\%(RecursiveDir)%(Filename)%(Extension)" />
</Target>
<Target Name="_GetProjectAllConfiguration" Returns="@(AllProjectReferenceConfigurations)">
<!--故意过滤Debug配置-->
<CreateItem
Condition="'%(ProjectConfiguration.Configuration)' != 'Debug' and '%(ProjectConfiguration.Configuration)' != 'Release' and '%(ProjectConfiguration.Platform)' != 'ARM64'"
Include="$(MSBuildProjectFullPath)"
AdditionalMetadata="Configuration=%(ProjectConfiguration.Configuration);Platform=%(ProjectConfiguration.Platform);AdditionalProperties=Configuration=%(ProjectConfiguration.Configuration)%3BPlatform=%(ProjectConfiguration.Platform)%3B">
<Output TaskParameter="Include" ItemName="AllProjectReferenceConfigurations"/>
</CreateItem>
</Target>
</Project>