|
3 | 3 | <Product>$(AssemblyName) ($(TargetFramework))</Product>
|
4 | 4 | </PropertyGroup>
|
5 | 5 |
|
| 6 | + <Target Name="BundlePackageBuildPropsAndTargets" |
| 7 | + BeforeTargets="Build"> |
| 8 | + |
| 9 | + <PropertyGroup> |
| 10 | + <_SourcePackagePropsFile Condition="Exists('build\Package.props')">build\Package.props</_SourcePackagePropsFile> |
| 11 | + <_SourcePackagePropsFile Condition="$(_SourcePackagePropsFile) == '' AND Exists('Package.props')">Package.props</_SourcePackagePropsFile> |
| 12 | + <_SourcePackageTargetsFile Condition="Exists('build\Package.targets')">build\Package.targets</_SourcePackageTargetsFile> |
| 13 | + <_SourcePackageTargetsFile Condition="$(_SourcePackageTargetsFile) == '' AND Exists('Package.targets')">Package.targets</_SourcePackageTargetsFile> |
| 14 | + </PropertyGroup> |
| 15 | + |
| 16 | + <ItemGroup> |
| 17 | + <None Remove="$(_SourcePackagePropsFile);$(_SourcePackageTargetsFile)" /> |
| 18 | + <None Include="$(_SourcePackagePropsFile)" Pack="true" PackagePath="build\$(PackageId).props" Condition="$(_SourcePackagePropsFile) != ''"/> |
| 19 | + <None Include="$(_SourcePackageTargetsFile)" Pack="true" PackagePath="build\$(PackageId).targets" Condition="$(_SourcePackageTargetsFile) != ''"/> |
| 20 | + </ItemGroup> |
| 21 | + |
| 22 | + <Copy SourceFiles="$(MSBuildThisFileDirectory)Package.Transitive.props" |
| 23 | + DestinationFolder="$(IntermediateOutputPath)\buildTransitive" |
| 24 | + Condition="$(_SourcePackagePropsFile) != ''" /> |
| 25 | + |
| 26 | + <Copy SourceFiles="$(MSBuildThisFileDirectory)Package.Transitive.targets" |
| 27 | + DestinationFolder="$(IntermediateOutputPath)\buildTransitive" |
| 28 | + Condition="$(_SourcePackageTargetsFile) != ''" /> |
| 29 | + |
| 30 | + <ReplaceFileText Filename="$(IntermediateOutputPath)\buildTransitive\Package.Transitive.props" |
| 31 | + MatchExpression="PackageId" |
| 32 | + ReplacementText="$(PackageId)" |
| 33 | + Condition="$(_SourcePackagePropsFile) != ''" /> |
| 34 | + |
| 35 | + <ReplaceFileText Filename="$(IntermediateOutputPath)\buildTransitive\Package.Transitive.targets" |
| 36 | + MatchExpression="PackageId" |
| 37 | + ReplacementText="$(PackageId)" |
| 38 | + Condition="$(_SourcePackageTargetsFile) != ''" /> |
| 39 | + |
| 40 | + <ItemGroup> |
| 41 | + <None Include="$(IntermediateOutputPath)\buildTransitive\Package.Transitive.props" Pack="true" |
| 42 | + PackagePath="buildTransitive\$(PackageId).props" |
| 43 | + Condition="$(_SourcePackagePropsFile) != ''" /> |
| 44 | + <None Include="$(IntermediateOutputPath)\buildTransitive\Package.Transitive.targets" Pack="true" |
| 45 | + PackagePath="buildTransitive\$(PackageId).targets" |
| 46 | + Condition="$(_SourcePackageTargetsFile) != ''" /> |
| 47 | + </ItemGroup> |
| 48 | + </Target> |
| 49 | + |
6 | 50 | <Target Name="DeleteCachedPackage" Condition="'$(CI)' != 'true'" BeforeTargets="Pack">
|
7 | 51 | <ItemGroup>
|
8 | 52 | <ToDelete Include="$(PackageOutputPath)\$(PackageId).$(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch)*.*" />
|
|
17 | 61 |
|
18 | 62 | <Import Project="Directory.Build.targets.user" Condition="Exists('Directory.Build.targets.user')"/>
|
19 | 63 |
|
| 64 | + <!-- Using Regex Replace prevents XmlPoke from replacing Tabs with Spaces --> |
| 65 | + <UsingTask TaskName="ReplaceFileText" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"> |
| 66 | + <ParameterGroup> |
| 67 | + <Filename ParameterType="System.String" Required="true" /> |
| 68 | + <MatchExpression ParameterType="System.String" Required="true" /> |
| 69 | + <ReplacementText ParameterType="System.String" Required="true" /> |
| 70 | + </ParameterGroup> |
| 71 | + <Task> |
| 72 | + <Using Namespace="System" /> |
| 73 | + <Using Namespace="System.IO" /> |
| 74 | + <Using Namespace="System.Text.RegularExpressions" /> |
| 75 | + <Code Type="Fragment" Language="cs"> |
| 76 | + <![CDATA[ |
| 77 | + File.WriteAllText( |
| 78 | + Filename, |
| 79 | + Regex.Replace(File.ReadAllText(Filename), Regex.Escape(MatchExpression), ReplacementText) |
| 80 | + ); |
| 81 | + ]]> |
| 82 | + </Code> |
| 83 | + </Task> |
| 84 | + </UsingTask> |
| 85 | + |
20 | 86 | </Project>
|
0 commit comments