|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
| 2 | +<!-- |
| 3 | +*********************************************************************************************** |
| 4 | +depProj.targets |
| 5 | +
|
| 6 | +WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have |
| 7 | + created a backup copy. Incorrect changes to this file will make it |
| 8 | + impossible to load or build your projects from the command-line or the IDE. |
| 9 | +
|
| 10 | +This file defines the steps in the standard build process specific for NuGet deployment |
| 11 | +projects. The remainder of the build process is defined in Microsoft.Common.targets, |
| 12 | +which is imported by this file. |
| 13 | +
|
| 14 | +Licensed to the .NET Foundation under one or more agreements. |
| 15 | +The .NET Foundation licenses this file to you under the MIT license. |
| 16 | +See the LICENSE file in the project root for more information. |
| 17 | +*********************************************************************************************** |
| 18 | +--> |
| 19 | +<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 20 | + |
| 21 | + <!-- Deployment project |
| 22 | + Restores NuGet dependencies and copies them to the output directory. |
| 23 | + |
| 24 | + NuGetTargetMoniker - determined by the TargetFramework* and TargetPlatform* |
| 25 | + properties of the project, can be overidden. |
| 26 | + NuGetRuntimeIdentifier - defaults to <empty> (""), can be overidden. |
| 27 | + NuGetDeploySourceItem - defaults to ReferenceCopyLocalPaths, can be overidden to |
| 28 | + specify Reference (for compile assets) or Analyzer(for |
| 29 | + analyzer assets) |
| 30 | + |
| 31 | + For the appropriate behavior of P2P references the project should set the |
| 32 | + TargetName and TargetExt to match one of the files that will be copied |
| 33 | + from the packages. |
| 34 | + --> |
| 35 | + |
| 36 | + <PropertyGroup> |
| 37 | + <NuGetDeploySourceItem Condition="'$(NuGetDeploySourceItem)' == ''">ReferenceCopyLocalPaths</NuGetDeploySourceItem> |
| 38 | + |
| 39 | + <!-- suppress the attempt to copy build output. --> |
| 40 | + <CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory> |
| 41 | + |
| 42 | + <!-- Unless overridden, use no runtime identifier. This is transformed in packageresolve.targets. |
| 43 | + We specify "None" here to avoid being assigned the default runtime for projects which set CopyNuGetImplementations=true. --> |
| 44 | + <NuGetRuntimeIdentifier Condition="'$(NuGetRuntimeIdentifier)' == ''">None</NuGetRuntimeIdentifier> |
| 45 | + |
| 46 | + <!-- make sure we tell nuget targets to copy, even if output type would not by default --> |
| 47 | + <CopyNuGetImplementations>true</CopyNuGetImplementations> |
| 48 | + |
| 49 | + <!-- by default there shouldn't be any assets in depproj files that require signing --> |
| 50 | + <SkipSigning Condition="'$(SkipSigning)' == ''">true</SkipSigning> |
| 51 | + </PropertyGroup> |
| 52 | + |
| 53 | + <Target Name="CoreCompile"> |
| 54 | + |
| 55 | + <Error Condition="'$(NuGetDeploySourceItem)' != 'ReferenceCopyLocalPaths' AND |
| 56 | + '$(NuGetDeploySourceItem)' != 'Reference' AND |
| 57 | + '$(NuGetDeploySourceItem)' != 'Analyzer'" |
| 58 | + Text="Unexpected value for NuGetDeploySourceItem:'$(NuGetDeploySourceItem)'. Expected ReferenceCopyLocalPaths, Reference, or Analyzer." /> |
| 59 | + |
| 60 | + <ItemGroup> |
| 61 | + <!-- Don't set IntermediateAssembly since this is not produced --> |
| 62 | + <IntermediateAssembly Remove="@(IntermediateAssembly)" /> |
| 63 | + |
| 64 | + <NuGetDeploy Include="@($(NuGetDeploySourceItem))"/> |
| 65 | + |
| 66 | + <!-- filter to only items that came from packages --> |
| 67 | + <!-- the following condition must be applied after the include because msbuild doesn't seem |
| 68 | + to support property-defined-item-names in a metadata statement --> |
| 69 | + <NuGetDeploy Remove="@(NuGetDeploy)" Condition="'%(NuGetDeploy.NuGetPackageId)' == ''" /> |
| 70 | + |
| 71 | + <!-- remove all existing items from NuGet packages we'll be defining these in our own item --> |
| 72 | + <ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' != ''"/> |
| 73 | + <Reference Remove="@(Reference)" Condition="'%(Reference.NuGetPackageId)' != ''"/> |
| 74 | + <Analyzer Remove="@(Analyzer)" Condition="'%(Analyzer.NuGetPackageId)' != ''"/> |
| 75 | + |
| 76 | + <!-- add items defined by NuGetDeployItem property to Content so that we get clean behavior --> |
| 77 | + <ContentWithTargetPath Include="@(NuGetDeploy)"> |
| 78 | + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
| 79 | + <TargetPath>%(FileName)%(Extension)</TargetPath> |
| 80 | + </ContentWithTargetPath> |
| 81 | + </ItemGroup> |
| 82 | + |
| 83 | + <Error Condition="'@(NuGetDeploy)' == ''" Text="Error no assets were resolved from NuGet packages." /> |
| 84 | + <Message Importance="High" Text="%(FullPath) (%(NuGetPackageId).%(NuGetPackageVersion)) -> @(NuGetDeploy->'$(TargetDir)%(FileName)%(Extension)')" /> |
| 85 | + |
| 86 | + <!-- Include marker files if an extension has been provided --> |
| 87 | + <!-- internal builds use this to distinguish files which have already been signed --> |
| 88 | + <Touch Condition="'$(DeployMarkerExtension)' != ''" Files="@(NuGetDeploy->'$(TargetDir)%(FileName)$(DeployMarkerExtension)')" AlwaysCreate="true"> |
| 89 | + <Output TaskParameter="TouchedFiles" ItemName="FileWrites"/> |
| 90 | + </Touch> |
| 91 | + </Target> |
| 92 | + |
| 93 | + <Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" /> |
| 94 | + |
| 95 | + <!-- Required by Common.Targets but not used for depproj --> |
| 96 | + <Target Name="CreateManifestResourceNames" /> |
| 97 | + |
| 98 | + <PropertyGroup> |
| 99 | + <!-- don't use TargetingPackReference, we do our own filtering --> |
| 100 | + <SkipFilterTargetingPackResolvedNugetPackages>true</SkipFilterTargetingPackResolvedNugetPackages> |
| 101 | + </PropertyGroup> |
| 102 | + |
| 103 | + <!-- Support filtering to a subset of packages or files --> |
| 104 | + <Target Name="FilterNugetPackages" |
| 105 | + AfterTargets="ResolveNuGetPackages" |
| 106 | + Condition="'@(PackageToInclude)' != '' OR '@(PackageToExclude)' != '' OR '@(FileToInclude)' != '' OR '@(FileToExclude)' != ''"> |
| 107 | + <ItemGroup> |
| 108 | + <_nuGetDeploy Include="@($(NuGetDeploySourceItem))"/> |
| 109 | + <_nuGetDeployByFileName Include="@(_nuGetDeploy->'%(FileName)')"> |
| 110 | + <OriginalItemSpec>%(Identity)</OriginalItemSpec> |
| 111 | + </_nuGetDeployByFileName> |
| 112 | + |
| 113 | + <_nuGetDeployByFileNameToRemove Include="@(_nuGetDeployByFileName)" Exclude="@(FileToInclude)" Condition="'@(FileToInclude)' != ''" /> |
| 114 | + <_filteredNuGetDeployByFileName Include="@(_nuGetDeployByFileName)" Exclude="@(_nuGetDeployByFileNameToRemove);@(FileToExclude)" /> |
| 115 | + |
| 116 | + <_nuGetDeployByPackageId Include="@(_filteredNuGetDeployByFileName->'%(NuGetPackageId)')" /> |
| 117 | + |
| 118 | + <_nuGetDeployByPackageIdToRemove Include="@(_nuGetDeployByPackageId)" Exclude="@(PackageToInclude)" Condition="'@(PackageToInclude)' != ''" /> |
| 119 | + <_filteredNuGetDeployByPackageId Include="@(_nuGetDeployByPackageId)" Exclude="@(_nuGetDeployByPackageIdToRemove);@(PackageToExclude)" /> |
| 120 | + |
| 121 | + <ReferenceCopyLocalPaths Condition="'$(NuGetDeploySourceItem)' == 'ReferenceCopyLocalPaths'" Remove="@(ReferenceCopyLocalPaths)" /> |
| 122 | + <Reference Condition="'$(NuGetDeploySourceItem)' == 'Reference'" Remove="@(Reference)" /> |
| 123 | + <Analyzer Condition="'$(NuGetDeploySourceItem)' == 'Analyzer'" Remove="@(Analyzer)" /> |
| 124 | + </ItemGroup> |
| 125 | + |
| 126 | + <CreateItem Include="@(_filteredNuGetDeployByPackageId->'%(OriginalItemSpec)')"> |
| 127 | + <Output TaskParameter="Include" ItemName="$(NuGetDeploySourceItem)" /> |
| 128 | + </CreateItem> |
| 129 | + </Target> |
| 130 | + |
| 131 | +</Project> |
0 commit comments