Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dir.targets - github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9898710dcd8509f646b41698a09860354c596633 (plain)
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
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" InitialTargets="_RestoreBuildToolsWrapper" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <!-- Inline task to bootstrap the build to enable downloading nuget.exe -->
  <UsingTask TaskName="DownloadFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
    <ParameterGroup>
      <Address ParameterType="System.String" Required="true" />
      <FileName ParameterType="System.String" Required="true" />
    </ParameterGroup>
    <Task>
      <Reference Include="System" />
      <Reference Include="System.IO" />
      <Code Type="Fragment" Language="cs">
        <![CDATA[
            var directory = System.IO.Path.GetDirectoryName(FileName);
            Directory.CreateDirectory(directory);

            var tempFile = Path.Combine(directory, Path.GetRandomFileName());
            var client = new System.Net.WebClient();
            client.Proxy = System.Net.WebRequest.DefaultWebProxy;
            if (client.Proxy != null) client.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
            var tryCount = 1;
            var maxTries = 3;

            while (tryCount <= maxTries)
            {
                try
                {
                    Log.LogMessage("Attempting to download {0}...", Address);
                    client.DownloadFile(Address, tempFile);
                    break;
                }
                catch (System.Net.WebException e)
                {
                    tryCount++;
                    if (tryCount > maxTries)
                    {
                        throw;
                    }
                    else
                    {
                        Log.LogMessage(MessageImportance.High, "Download failed, retrying: {0}", e.Message);
                    }
                }
            }

            try
            {
                if (!File.Exists(FileName))
                    File.Move(tempFile, FileName);
            }
            finally
            {
                if (File.Exists(tempFile))
                    File.Delete(tempFile);
            }
        ]]>
      </Code>
    </Task>
  </UsingTask>

  <!--
    Use a semaphore file to determine the need to restore build tools to avoid conflicts with locked binaries.
  -->
  <PropertyGroup>
    <BuildToolsSemaphore>$(ToolsDir)BuildTools.semaphore</BuildToolsSemaphore>
  </PropertyGroup>

  <!--
    Needed to avoid the IntialTargets from having an Output which ends up getting
    added to the output references when you have a project to project reference.
  -->
  <Target Name="_RestoreBuildToolsWrapper" DependsOnTargets="_RestoreBuildTools"/>

  <Target Name="_RestoreBuildTools"
          Inputs="$(MSBuildThisFileDirectory)dir.props;$(SourceDir).nuget/packages.$(OsEnvironment).config"
          Outputs="$(BuildToolsSemaphore)">
    <Message Importance="High" Text="Restoring build tools..." />

    <Copy Condition="Exists('$(NuGetCachedPath)')" SourceFiles="$(NuGetCachedPath)" DestinationFiles="$(NuGetToolPath)" SkipUnchangedFiles="true" />

    <!-- Download latest nuget.exe -->
    <DownloadFile FileName="$(NuGetToolPath)"
                  Address="https://www.nuget.org/nuget.exe"
                  Condition="!Exists('$(NuGetToolPath)') and '$(OsEnvironment)'=='Windows_NT'" />

    <Exec Command="curl -sSL --create-dirs -o $(NuGetToolPath) https://api.nuget.org/downloads/nuget.exe"
          Condition="!Exists('$(NuGetToolPath)') and '$(OsEnvironment)'=='Unix'" />

    <PropertyGroup>
      <_RestoreBuildToolsCommand>$(NugetRestoreCommand) "$(SourceDir).nuget/packages.$(OsEnvironment).config"</_RestoreBuildToolsCommand>
    </PropertyGroup>

    <!-- Restore build tools -->
    <Exec Command="$(_RestoreBuildToolsCommand)" StandardOutputImportance="Low" />

    <!-- Add DNU and Roslyn tool execute rights -->
    <Exec Condition="'$(OsEnvironment)'=='Unix'"
          Command="chmod a+x &quot;$(DnxPackageDir)/bin/dnu&quot;" />
    <Exec Condition="'$(OsEnvironment)'=='Unix'"
          Command="chmod a+x &quot;$(DnxPackageDir)/bin/dnx&quot;" />
    <Exec Condition="'$(OsEnvironment)'=='Unix'"
          Command="find '$(RoslynPackageDir)tools' -name &quot;*.exe&quot; -exec chmod &quot;+x&quot; '{}' ';'" />

    <!--
      Touch our semaphore file to ensure Inputs/Outputs comparison for this target will show that we're up to date.
      Ignore failures in the unlikely, but possible, event that we hit this from two projects simultaneously.
    -->
    <Touch Files="$(BuildToolsSemaphore)"
           ContinueOnError="WarnAndContinue"
           AlwaysCreate="true"
           ForceTouch="true" />

    <Error Condition="'$(ErrorIfBuildToolsRestoredFromIndividualProject)'=='true'"
           Text="The build tools package was just restored and so we cannot continue the build of an individual project because targets from the build tools package were not able to be imported. Please retry the build the individual project again." />
  </Target>

  <!-- Provide default targets which can be hooked onto or overridden as necessary -->
  <Target Name="BuildAndTest" DependsOnTargets="Build;Test" />
  <Target Name="RebuildAndTest" DependsOnTargets="Rebuild;Test" />
  <Target Name="Test" />
</Project>