Directory.Build.targets 3.1 KB
Newer Older
B
Brett V. Forsgren 已提交
1
<Project>
K
Kevin Ransom (msft) 已提交
2

3 4 5 6
  <Target Name="NoneSubstituteTextFiles"
          Inputs="@(NoneSubstituteText)"
          Outputs="@(NoneSubstituteText->'$(IntermediateOutputPath)%(Filename)%(Extension)')"
          BeforeTargets="AssignTargetPaths;BeforeBuild">
K
Kevin Ransom (msft) 已提交
7 8

    <PropertyGroup>
9 10
      <__TargetFilePath>@(NoneSubstituteText->'$(IntermediateOutputPath)%(Filename)%(Extension)')</__TargetFilePath>
      <__TargetFileName>@(NoneSubstituteText->'%(Filename)%(Extension)')</__TargetFileName>
K
Kevin Ransom (msft) 已提交
11

12 13 14 15 16 17
      <_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>

      <_CopyToOutputDirectory Condition="'%(NoneSubstituteText.CopyToOutputDirectory)' != ''">%(NoneSubstituteText.CopyToOutputDirectory)</_CopyToOutputDirectory>
      <_CopyToOutputDirectory Condition="'%(NoneSubstituteText.CopyToOutputDirectory)' == ''">Never</_CopyToOutputDirectory>
K
Kevin Ransom (msft) 已提交
18 19
    </PropertyGroup>

20 21
    <MakeDir Directories="$(IntermediateOutputPath)"
             Condition="!Exists('$(IntermediateOutputPath)')" />
D
Don Syme 已提交
22
    <WriteLinesToFile File="$(__TargetFilePath)" Lines="$(_ReplacementText)" Overwrite="true" WriteOnlyWhenDifferent="true" />
K
Kevin Ransom (msft) 已提交
23 24 25

    <!-- Make sure it will get cleaned  -->
    <ItemGroup >
26
      <None Include="$(__TargetFilePath)" CopyToOutputDirectory="$(_CopyToOutputDirectory)" />
K
Kevin Ransom (msft) 已提交
27 28 29 30 31
      <FileWrites Include="$(__TargetFilePath)" Condition="'$(__TargetFileName)' != 'App.config'" />
    </ItemGroup>
  </Target>

  <Target Name="_GenerateBuildPropertiesFile"
32
          Outputs="$(IntermediateOutputPath)$(ProjectName).BuildProperties.fs"
K
Kevin Ransom (msft) 已提交
33 34 35 36 37 38 39 40 41 42 43 44 45 46
          BeforeTargets="BeforeBuild"
          Condition="'$(Language)'=='F#'">

    <ItemGroup>
      <_BuildPropertyLines Remove="@(_BuildPropertyLines)" />
      <_BuildPropertyLines Include="//  &lt;auto-generated &gt;" />
      <_BuildPropertyLines Include="//    &lt;Generated by the FSharp WriteCodeFragment class./&gt;" />
      <_BuildPropertyLines Include="//  &lt;/auto-generated/&gt;" />
      <_BuildPropertyLines Include="//" />
      <_BuildPropertyLines Include="module internal FSharp.BuildProperties" />
      <_BuildPropertyLines Include="let fsProductVersion = &quot;$(FSPRODUCTVERSION)&quot;" />
      <_BuildPropertyLines Include="let fsLanguageVersion = &quot;$(FSLANGUAGEVERSION)&quot;" />
    </ItemGroup>

47
    <WriteLinesToFile File="$(IntermediateOutputPath)$(ProjectName).BuildProperties.fs" Lines="@(_BuildPropertyLines)" Overwrite="true"  WriteOnlyWhenDifferent="true" />
K
Kevin Ransom (msft) 已提交
48 49 50

    <!-- Make sure it will get cleaned  -->
    <ItemGroup>
51 52
      <FileWrites Include="$(IntermediateOutputPath)$(ProjectName).BuildProperties.fs" />
      <CompileBefore Include="$(IntermediateOutputPath)$(ProjectName).BuildProperties.fs" />
K
Kevin Ransom (msft) 已提交
53 54 55
    </ItemGroup>
  </Target>

B
Brett V. Forsgren 已提交
56
</Project>