-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Directory.Build.targets
87 lines (75 loc) · 4.45 KB
/
Directory.Build.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
<Project>
<PropertyGroup>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<NoWarn>$(NoWarn);NU1903</NoWarn>
</PropertyGroup>
<!--<Target Name="BundlePackageBuildPropsAndTargets"
BeforeTargets="Build;CoreBuild;CoreCompile;Pack">
<PropertyGroup>
<_SourcePackagePropsFile Condition="Exists('build\Package.props')">build\Package.props</_SourcePackagePropsFile>
<_SourcePackagePropsFile Condition="$(_SourcePackagePropsFile) == '' AND Exists('Package.props')">Package.props</_SourcePackagePropsFile>
<_SourcePackageTargetsFile Condition="Exists('build\Package.targets')">build\Package.targets</_SourcePackageTargetsFile>
<_SourcePackageTargetsFile Condition="$(_SourcePackageTargetsFile) == '' AND Exists('Package.targets')">Package.targets</_SourcePackageTargetsFile>
</PropertyGroup>
<ItemGroup>
<None Remove="$(_SourcePackagePropsFile);$(_SourcePackageTargetsFile)" />
<None Include="$(_SourcePackagePropsFile)" Pack="true" PackagePath="build\$(PackageId).props" Condition="$(_SourcePackagePropsFile) != ''"/>
<None Include="$(_SourcePackageTargetsFile)" Pack="true" PackagePath="build\$(PackageId).targets" Condition="$(_SourcePackageTargetsFile) != ''"/>
</ItemGroup>
<Copy SourceFiles="$(MSBuildThisFileDirectory)Package.Transitive.props"
DestinationFolder="$(IntermediateOutputPath)\buildTransitive"
Condition="$(_SourcePackagePropsFile) != ''" />
<Copy SourceFiles="$(MSBuildThisFileDirectory)Package.Transitive.targets"
DestinationFolder="$(IntermediateOutputPath)\buildTransitive"
Condition="$(_SourcePackageTargetsFile) != ''" />
<ReplaceFileText Filename="$(IntermediateOutputPath)\buildTransitive\Package.Transitive.props"
MatchExpression="PackageId"
ReplacementText="$(PackageId)"
Condition="$(_SourcePackagePropsFile) != ''" />
<ReplaceFileText Filename="$(IntermediateOutputPath)\buildTransitive\Package.Transitive.targets"
MatchExpression="PackageId"
ReplacementText="$(PackageId)"
Condition="$(_SourcePackageTargetsFile) != ''" />
<ItemGroup>
<None Include="$(IntermediateOutputPath)\buildTransitive\Package.Transitive.props" Pack="true"
PackagePath="buildTransitive\$(PackageId).props"
Condition="$(_SourcePackagePropsFile) != ''" />
<None Include="$(IntermediateOutputPath)\buildTransitive\Package.Transitive.targets" Pack="true"
PackagePath="buildTransitive\$(PackageId).targets"
Condition="$(_SourcePackageTargetsFile) != ''" />
</ItemGroup>
</Target>-->
<Target Name="DeleteCachedPackage" Condition="'$(CI)' != 'true'" BeforeTargets="Pack">
<ItemGroup>
<ToDelete Include="$(PackageOutputPath)\$(PackageId).$(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch)*.*" />
<ToDelete Include="$(LocalArtifactStagingDirectory)\$(PackageId).$(GitBaseVersionMajor).$(GitBaseVersionMinor).*" />
</ItemGroup>
<Delete Files="@(ToDelete)" />
<Exec Command='rd "$(NuGetPackageRoot)$(PackageId.ToLowerInvariant())" /q /s'
Condition="Exists('$(NuGetPackageRoot)$(PackageId.ToLowerInvariant())') And '$(OS)' == 'Windows_NT'" />
<Exec Command='rm -rf "$(NuGetPackageRoot)$(PackageId.ToLowerInvariant())"'
Condition="Exists('$(NuGetPackageRoot)$(PackageId.ToLowerInvariant())') And '$(OS)' != 'Windows_NT'" />
</Target>
<Import Project="Directory.Build.targets.user" Condition="Exists('Directory.Build.targets.user')"/>
<!-- Using Regex Replace prevents XmlPoke from replacing Tabs with Spaces -->
<UsingTask TaskName="ReplaceFileText" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Filename ParameterType="System.String" Required="true" />
<MatchExpression ParameterType="System.String" Required="true" />
<ReplacementText ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
File.WriteAllText(
Filename,
Regex.Replace(File.ReadAllText(Filename), Regex.Escape(MatchExpression), ReplacementText)
);
]]>
</Code>
</Task>
</UsingTask>
</Project>