|
2 | 2 |
|
3 | 3 | <Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
|
4 | 4 |
|
| 5 | + <PropertyGroup> |
| 6 | + <TFMPackTempOutputDir>$([MSBuild]::NormalizeDirectory('$(BaseOutputPath)', 'pack'))</TFMPackTempOutputDir> |
| 7 | + </PropertyGroup> |
| 8 | + |
| 9 | + <!-- |
| 10 | + Disable Arcade util that populates PackTask properties. For these projects, the nuspec already |
| 11 | + contains everything. It's generated when the package is initially deconstructed and tends to be |
| 12 | + unique per package, so there's no benefit to this Arcade util. |
| 13 | + --> |
| 14 | + <Target Name="InitializeStandardNuspecProperties" /> |
| 15 | + |
| 16 | + <Target Name="GetProjectSrc"> |
| 17 | + <ItemGroup> |
| 18 | + <!-- |
| 19 | + Files that may need the 'constraint' token fixed before they can be assembled. They were |
| 20 | + decompiled with a 3.1 ildasm not compatible with 5.0 ilasm. In some cases the fix is not |
| 21 | + necessary for a given IL filename in a certain TFM, but is necessary for a file with the |
| 22 | + same name in a different TFM. The patch doesn't take a particularly long time, so prefer |
| 23 | + keeping this list simple. |
| 24 | + --> |
| 25 | + <TargetingPackSrcRequiringConstraintPatch |
| 26 | + Include=" |
| 27 | + $(MSBuildProjectDirectory)\**\Microsoft.AspNetCore.Components.il; |
| 28 | + $(MSBuildProjectDirectory)\**\Microsoft.AspNetCore.Mvc.Cors.il; |
| 29 | + $(MSBuildProjectDirectory)\**\Microsoft.AspNetCore.Routing.il; |
| 30 | + $(MSBuildProjectDirectory)\**\netstandard.il; |
| 31 | + $(MSBuildProjectDirectory)\**\presentationframework.*.il; |
| 32 | + $(MSBuildProjectDirectory)\**\PresentationFramework.*.il; |
| 33 | + $(MSBuildProjectDirectory)\**\PresentationFramework.il; |
| 34 | + $(MSBuildProjectDirectory)\**\System.Activities.Presentation.il; |
| 35 | + $(MSBuildProjectDirectory)\**\System.ComponentModel.Composition.il; |
| 36 | + $(MSBuildProjectDirectory)\**\System.Data.Common.il; |
| 37 | + $(MSBuildProjectDirectory)\**\System.Data.Entity.il; |
| 38 | + $(MSBuildProjectDirectory)\**\System.Data.il; |
| 39 | + $(MSBuildProjectDirectory)\**\System.Design.il; |
| 40 | + $(MSBuildProjectDirectory)\**\System.Reflection.Metadata.il; |
| 41 | + $(MSBuildProjectDirectory)\**\System.Web.il; |
| 42 | + $(MSBuildProjectDirectory)\**\System.Xml.il; |
| 43 | + $(MSBuildProjectDirectory)\**\System.XML.il; |
| 44 | + $(MSBuildProjectDirectory)\**\WindowsFormsIntegration.il" /> |
| 45 | + |
| 46 | + <!-- Find all IL. Leave out IL that needs to be patched before being built. --> |
| 47 | + <TargetingPackSrc |
| 48 | + Include="$(MSBuildProjectDirectory)\**\*.il" |
| 49 | + Exclude="@(TargetingPackSrcRequiringConstraintPatch)" /> |
| 50 | + <TargetingPackSrc |
| 51 | + RelativeOutputAssemblyFile="%(RecursiveDir)%(Filename).dll" /> |
| 52 | + |
| 53 | + <PotentialCompileSrc Include="**\*.cs" /> |
| 54 | + |
| 55 | + <NuGetGeneratedMetadataFile Include=" |
| 56 | + .signature.p7s; |
| 57 | + _rels\**; |
| 58 | + [Content_Types].xml; |
| 59 | + " /> |
| 60 | + |
| 61 | + <StructureFile |
| 62 | + Include="**\*.*" |
| 63 | + Exclude=" |
| 64 | + @(TargetingPackSrc); |
| 65 | + @(TargetingPackSrcRequiringConstraintPatch); |
| 66 | + @(PotentialCompileSrc); |
| 67 | + **\*.csproj; |
| 68 | + @(NuGetGeneratedMetadataFile); |
| 69 | + " |
| 70 | + Condition="'$(TextOnlyPackage)' != 'true'" /> |
| 71 | + <StructureFile |
| 72 | + Include="**\*" |
| 73 | + Exclude="$(MSBuildProjectFullPath)" |
| 74 | + Condition="'$(TextOnlyPackage)' == 'true'"/> |
| 75 | + |
| 76 | + <StaticAssetFile |
| 77 | + Include="@(StructureFile)" |
| 78 | + Destination="$(TFMPackTempOutputDir)%(RecursiveDir)%(Filename)%(Extension)" /> |
| 79 | + </ItemGroup> |
| 80 | + </Target> |
| 81 | + |
| 82 | + <Target Name="CopyStaticAssetsToOutput" |
| 83 | + BeforeTargets="GenerateNuspec" |
| 84 | + DependsOnTargets="GetProjectSrc"> |
| 85 | + <!-- Ensure TFMPackTempOutputDir defined, to avoid globbing entire machine... --> |
| 86 | + <Error Condition="'$(TFMPackTempOutputDir)' == ''" Text="TFMPackTempOutputDir not defined" /> |
| 87 | + |
| 88 | + <Copy |
| 89 | + SourceFiles="@(StaticAssetFile)" |
| 90 | + DestinationFiles="@(StaticAssetFile -> '%(Destination)')" /> |
| 91 | + </Target> |
| 92 | + |
| 93 | + <!-- |
| 94 | + Instead of using the nuspec specified by a static property, use one that we find dynamically. In |
| 95 | + this case, the project file has already statically set the nuspec property to some other value, |
| 96 | + which takes priority over Directory.Build.props, so we override it dynamically in this target. |
| 97 | +
|
| 98 | + This target is also a nice place to enforce that we do actually have a nuspec. |
| 99 | + --> |
| 100 | + <Target Name="SetManualPackTaskInputs" |
| 101 | + BeforeTargets="_CalculateInputsOutputsForPack;GenerateNuspec"> |
| 102 | + <ItemGroup> |
| 103 | + <NuspecFile Include="*.nuspec" /> |
| 104 | + </ItemGroup> |
| 105 | + |
| 106 | + <Error Condition="@(NuspecFile->Count()) != 1" Text="Expected exactly one nuspec file." /> |
| 107 | + |
| 108 | + <PropertyGroup> |
| 109 | + <NuspecFile>$(TFMPackTempOutputDir)@(NuspecFile)</NuspecFile> |
| 110 | + </PropertyGroup> |
| 111 | + </Target> |
| 112 | + |
5 | 113 | </Project>
|
0 commit comments