forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdepProj.targets
157 lines (125 loc) · 8.2 KB
/
depProj.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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!--
***********************************************************************************************
depProj.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
This file defines the steps in the standard build process specific for NuGet deployment
projects. The remainder of the build process is defined in Microsoft.Common.targets,
which is imported by this file.
Licensed to the .NET Foundation under one or more agreements.
The .NET Foundation licenses this file to you under the MIT license.
See the LICENSE file in the project root for more information.
***********************************************************************************************
-->
<Project InitialTargets="RemoveImplicitPackageReferences">
<!-- Deployment project
Restores NuGet dependencies and copies them to the output directory.
NuGetTargetMoniker - determined by the TargetFramework* and TargetPlatform*
properties of the project, can be overidden.
NuGetRuntimeIdentifier - defaults to <empty> (""), can be overidden.
NuGetDeploySourceItem - defaults to ReferenceCopyLocalPaths, can be overidden to
specify Reference (for compile assets) or Analyzer(for
analyzer assets)
For the appropriate behavior of P2P references the project should set the
TargetName and TargetExt to match one of the files that will be copied
from the packages.
-->
<PropertyGroup>
<!-- Always raise runtime/lib items even for frameworks that may not use them -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<!-- We don't need the SDK to validate that we get runtime packages -->
<EnsureRuntimePackageDependencies>false</EnsureRuntimePackageDependencies>
<!-- don't generate netcoreapp files -->
<GenerateDependencyFile>false</GenerateDependencyFile>
<GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
<PropertyGroup>
<NuGetDeploySourceItem Condition="'$(NuGetDeploySourceItem)' == ''">ReferenceCopyLocalPaths</NuGetDeploySourceItem>
<!-- suppress the attempt to copy build output. -->
<CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory>
<!-- Unless overridden, use no runtime identifier. This is transformed in packageresolve.targets.
We specify "None" here to avoid being assigned the default runtime for projects which set CopyNuGetImplementations=true. -->
<NuGetRuntimeIdentifier Condition="'$(NuGetRuntimeIdentifier)' == ''">None</NuGetRuntimeIdentifier>
<!-- make sure we tell nuget targets to copy, even if output type would not by default -->
<CopyNuGetImplementations>true</CopyNuGetImplementations>
</PropertyGroup>
<!-- This file results in importing the Build Target. -->
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
<Target Name="RemoveImplicitPackageReferences">
<ItemGroup>
<!-- Remove all implicit framework packages, depprojs are meant to be wholly explicit -->
<PackageReference Remove="@(PackageReference)" Condition="'%(PackageReference.IsImplicitlyDefined)' == 'true'" />
</ItemGroup>
</Target>
<Target Name="RunRestoreDuringBuild"
DependsOnTargets="Restore"
BeforeTargets="ResolvePackageAssets"
Condition="'$(VSDesignTimeBuild)' != 'true'" />
<Target Name="CoreCompile">
<Error Condition="'$(NuGetDeploySourceItem)' != 'ReferenceCopyLocalPaths' and
'$(NuGetDeploySourceItem)' != 'Reference' and
'$(NuGetDeploySourceItem)' != 'Analyzer'"
Text="Unexpected value for NuGetDeploySourceItem:'$(NuGetDeploySourceItem)'. Expected ReferenceCopyLocalPaths, Reference, or Analyzer." />
<ItemGroup>
<!-- Don't set IntermediateAssembly since this is not produced -->
<IntermediateAssembly Remove="@(IntermediateAssembly)" />
<NuGetDeploy Include="@($(NuGetDeploySourceItem))"/>
<!-- filter to only items that came from packages -->
<!-- the following condition must be applied after the include because msbuild doesn't seem
to support property-defined-item-names in a metadata statement -->
<NuGetDeploy Remove="@(NuGetDeploy)" Condition="'%(NuGetDeploy.NuGetPackageId)' == ''" />
<!-- remove all existing items from NuGet packages we'll be defining these in our own item -->
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' != ''"/>
<Reference Remove="@(Reference)" Condition="'%(Reference.NuGetPackageId)' != ''"/>
<Analyzer Remove="@(Analyzer)" Condition="'%(Analyzer.NuGetPackageId)' != ''"/>
<!-- add items defined by NuGetDeployItem property to Content so that we get clean behavior -->
<ContentWithTargetPath Include="@(NuGetDeploy)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>%(NuGetDeploy.SubFolder)%(FileName)%(Extension)</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<Message Importance="High"
Condition="'@(NuGetDeploy)' == ''"
Text="$(MSBuildProjectFile): No assets were resolved from NuGet packages." />
<Message Importance="High"
Condition="'@(NuGetDeploy)' != ''"
Text="%(FullPath) (%(NuGetPackageId).%(NuGetPackageVersion)) -> @(NuGetDeploy->'$(TargetDir)%(SubFolder)%(FileName)%(Extension)')" />
<!-- Include marker files if an extension has been provided -->
<!-- internal builds use this to distinguish files which have already been signed -->
<Touch Condition="'$(DeployMarkerExtension)' != ''" Files="@(NuGetDeploy->'$(TargetDir)%(FileName)$(DeployMarkerExtension)')" AlwaysCreate="true">
<Output TaskParameter="TouchedFiles" ItemName="FileWrites"/>
</Touch>
</Target>
<!-- Required by Common.Targets but not used for depproj -->
<Target Name="CreateManifestResourceNames" />
<Target Name="RemoveFrameworkReferences"
AfterTargets="ResolvePackageAssets">
<ItemGroup>
<ResolvedFrameworkAssemblies Remove="@(ResolvedFrameworkAssemblies)" Condition="'%(ResolvedFrameworkAssemblies.NuGetIsFrameworkReference)' == 'true'" />
</ItemGroup>
</Target>
<!-- Support filtering to a subset of packages or files -->
<Target Name="FilterNugetPackages"
BeforeTargets="ResolveAssemblyReferences"
DependsOnTargets="ResolvePackageAssets"
Condition="'@(PackageToInclude)' != '' or '@(PackageToExclude)' != '' or '@(FileToInclude)' != '' or '@(FileToExclude)' != ''">
<ItemGroup>
<_nuGetDeploy Include="@($(NuGetDeploySourceItem))"/>
<_nuGetDeployByFileName Include="@(_nuGetDeploy->'%(FileName)')">
<OriginalItemSpec>%(Identity)</OriginalItemSpec>
</_nuGetDeployByFileName>
<_nuGetDeployByFileNameToRemove Include="@(_nuGetDeployByFileName)" Exclude="@(FileToInclude)" Condition="'@(FileToInclude)' != ''" />
<_filteredNuGetDeployByFileName Include="@(_nuGetDeployByFileName)" Exclude="@(_nuGetDeployByFileNameToRemove);@(FileToExclude)" />
<_nuGetDeployByPackageId Include="@(_filteredNuGetDeployByFileName->'%(NuGetPackageId)')" />
<_nuGetDeployByPackageIdToRemove Include="@(_nuGetDeployByPackageId)" Exclude="@(PackageToInclude)" Condition="'@(PackageToInclude)' != ''" />
<_filteredNuGetDeployByPackageId Include="@(_nuGetDeployByPackageId)" Exclude="@(_nuGetDeployByPackageIdToRemove);@(PackageToExclude)" />
<ReferenceCopyLocalPaths Condition="'$(NuGetDeploySourceItem)' == 'ReferenceCopyLocalPaths'" Remove="@(ReferenceCopyLocalPaths)" />
<Reference Condition="'$(NuGetDeploySourceItem)' == 'Reference'" Remove="@(Reference)" />
<Analyzer Condition="'$(NuGetDeploySourceItem)' == 'Analyzer'" Remove="@(Analyzer)" />
</ItemGroup>
<CreateItem Include="@(_filteredNuGetDeployByPackageId->'%(OriginalItemSpec)')">
<Output TaskParameter="Include" ItemName="$(NuGetDeploySourceItem)" />
</CreateItem>
</Target>
</Project>