forked from dotnet/fsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FSharpBuild.Directory.Build.targets
134 lines (108 loc) · 6.7 KB
/
FSharpBuild.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
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
<Project>
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<Import Project="eng\targets\Imports.targets" />
<Import Project="eng\targets\NGenBinaries.targets" />
<Import Project="eng\targets\NuGet.targets" />
<Import Project="FSharp.Profiles.props" />
<Target Name="NoneSubstituteTextFiles"
Inputs="@(NoneSubstituteText)"
Outputs="@(NoneSubstituteText->'$(IntermediateOutputPath)%(Filename)%(Extension)')"
BeforeTargets="AssignTargetPaths;BeforeBuild;GenerateFSharpTextResources">
<PropertyGroup>
<__TargetFilePath>@(NoneSubstituteText->'$(IntermediateOutputPath)%(Filename)%(Extension)')</__TargetFilePath>
<__TargetFileName>@(NoneSubstituteText->'%(Filename)%(Extension)')</__TargetFileName>
<__TargetLink>@(NoneSubstituteText->'%(Link)')</__TargetLink>
<_ReplacementText>$([System.IO.File]::ReadAllText('%(NoneSubstituteText.FullPath)'))</_ReplacementText>
<_ReplacementText Condition="'%(NoneSubstituteText.Pattern1)' != ''">$(_ReplacementText.Replace('%(NoneSubstituteText.Pattern1)', '%(NoneSubstituteText.Replacement1)'))</_ReplacementText>
<_ReplacementText Condition="'%(NoneSubstituteText.Pattern2)' != ''">$(_ReplacementText.Replace('%(NoneSubstituteText.Pattern2)', '%(NoneSubstituteText.Replacement2)'))</_ReplacementText>
<_ReplacementText Condition="'%(NoneSubstituteText.Pattern3)' != ''">$(_ReplacementText.Replace('%(NoneSubstituteText.Pattern3)', '%(NoneSubstituteText.Replacement3)'))</_ReplacementText>
<_CopyToOutputDirectory Condition="'%(NoneSubstituteText.CopyToOutputDirectory)' != ''">%(NoneSubstituteText.CopyToOutputDirectory)</_CopyToOutputDirectory>
<_CopyToOutputDirectory Condition="'%(NoneSubstituteText.CopyToOutputDirectory)' == ''">Never</_CopyToOutputDirectory>
<_IncludeInVsix>false</_IncludeInVsix>
<_IncludeInVsix Condition="'%(NoneSubstituteText.IncludeInVsix)' == 'true'">true</_IncludeInVsix>
</PropertyGroup>
<MakeDir Directories="$(IntermediateOutputPath)"
Condition="!Exists('$(IntermediateOutputPath)')" />
<WriteLinesToFile File="$(__TargetFilePath)" Lines="$(_ReplacementText)" Overwrite="true" WriteOnlyWhenDifferent="true" />
<ItemGroup>
<None Include="$(__TargetFilePath)" CopyToOutputDirectory="$(_CopyToOutputDirectory)" />
<FileWrites Include="$(__TargetFilePath)" Condition="'$(__TargetFileName)' != 'App.config'" />
<Content Include="$(__TargetFilePath)" CopyToOutputDirectory="Always" IncludeInVsix="true" Link="$(__TargetLink)" Condition="'$(_IncludeInVsix)'=='true'" />
</ItemGroup>
</Target>
<Target Name="_GenerateBuildPropertiesFile"
Outputs="$(IntermediateOutputPath)buildproperties.fs"
BeforeTargets="BeforeBuild"
Condition="'$(Language)'=='F#'">
<ItemGroup>
<_BuildPropertyLines Remove="@(_BuildPropertyLines)" />
<_BuildPropertyLines Include="// <auto-generated >" />
<_BuildPropertyLines Include="// <Generated by the FSharp WriteCodeFragment class./>" />
<_BuildPropertyLines Include="// </auto-generated/>" />
<_BuildPropertyLines Include="//" />
<_BuildPropertyLines Include="module internal FSharp.BuildProperties" />
<_BuildPropertyLines Include="let fsProductVersion = "$(FSPRODUCTVERSION)"" />
<_BuildPropertyLines Include="let fsLanguageVersion = "$(FSLANGUAGEVERSION)"" />
</ItemGroup>
<MakeDir
Directories="$(IntermediateOutputPath)"
Condition="!Exists('$(IntermediateOutputPath)')" />
<WriteLinesToFile File="$(IntermediateOutputPath)buildproperties.fs" Lines="@(_BuildPropertyLines)" Overwrite="true" WriteOnlyWhenDifferent="true" />
<!-- Make sure it will get cleaned -->
<ItemGroup>
<CompileBefore Include="$(IntermediateOutputPath)buildproperties.fs" />
<FsGeneratedSource Include="$(IntermediateOutputPath)buildproperties.fs" />
<FileWrites Include="$(IntermediateOutputPath)buildproperties.fs" />
</ItemGroup>
</Target>
<Target Name="BeforeResGen"
Inputs="@(EmbeddedResource->'$(IntermediateOutputPath)%(Filename)%(Extension)')"
Outputs="@(EmbeddedResource->'$(IntermediateOutputPath)resources\%(Filename)%(Extension)')"
Condition="'$(Configuration)' != 'Proto' and '$(Language)'=='F#' and '$(DisableCompilerRedirection)' != 'true' ">
<MakeDir Directories="$(IntermediateOutputPath)" Condition="!Exists('$(IntermediateOutputPath)')" />
<MakeDir Directories="$(IntermediateOutputPath)resources\" Condition="!Exists('$(IntermediateOutputPath)resources\')" />
<SubstituteText EmbeddedResources="@(EmbeddedResource)">
<Output TaskParameter="CopiedFiles" ItemName="CopiedFiles" />
</SubstituteText>
<ItemGroup>
<IntermediateFiles Include="$(IntermediateOutputPath)\*.resx" />
<IntermediateResourcesFiles Include="$(IntermediateOutputPath)resources\*.resx" />
</ItemGroup>
<!-- IntermediateFiles Hashes -->
<GetFileHash Files="@(IntermediateFiles)">
<Output
TaskParameter="Items"
ItemName="IntermediateFilesHashes" />
</GetFileHash>
<Hash ItemsToHash="@(IntermediateFilesHashes->'%(FileHash)')">
<Output TaskParameter="HashResult" PropertyName="IntermediateFilesHash" />
</Hash>
<!-- CopiedFilesForHash Hashes -->
<GetFileHash Files="@(IntermediateResourceFilesForHash)">
<Output
TaskParameter="Items"
ItemName="IntermediateResourceFilesHashes" />
</GetFileHash>
<Hash ItemsToHash="@(IntermediateResourceFilesHashes->'%(FileHash)')">
<Output TaskParameter="HashResult" PropertyName="IntermediateResourceFilesHash" />
</Hash>
<!-- Update EmbeddedResources -->
<ItemGroup Condition="'$(IntermediateFilesHash)' != '$(IntermediateResourceFilesHash)'">
<EmbeddedResource Remove="@(EmbeddedResource)"/>
<EmbeddedResource Include="@(CopiedFiles)"/>
</ItemGroup>
<Copy SourceFiles="@(CopyVsixResources)" DestinationFolder="$(IntermediateOutputPath)\resources\Resources" Condition="'$(IntermediateFilesHash)' != '$(IntermediateResourceFilesHash)'" />
</Target>
<PropertyGroup>
<CoreBuildDependsOn>$(CoreBuildDependsOn);PrefixRepoToReleaseNotes</CoreBuildDependsOn>
</PropertyGroup>
<Target Name="PrefixRepoToReleaseNotes"
BeforeTargets="InitializeStandardNuspecProperties"
DependsOnTargets="InitializeSourceControlInformationFromSourceControlManager"
Condition="'$(IsPackable)'=='true'">
<PropertyGroup>
<_GitUrl>$([System.Text.RegularExpressions.Regex]::Replace($(ScmRepositoryUrl), ".git$", ""))</_GitUrl>
<PackageReleaseNotes>$(_GitUrl)$(PackageReleaseNotes)</PackageReleaseNotes>
</PropertyGroup>
</Target>
</Project>