summaryrefslogtreecommitdiff
path: root/.packages/microsoft.dotnet.arcade.sdk/1.0.0-beta.19461.7/tools/Build.proj
blob: 2b0ae68e503fae692d54fe0b8e9e519d883a736c (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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project DefaultTargets="Execute" TreatAsLocalProperty="RepoRoot">
  <!--

  Required parameters:
    RepoRoot                        Repository root.
    Projects                        List of projects to build. Semicolon separated, may include globs.

  Optional parameters:
    Configuration                   Build configuration: "Debug", "Release", etc.

    DotNetBuildFromSource           Building the entire stack from source with no external dependencies.
    DotNetOutputBlobFeedDir         Directory to publish Source Build assets to (packages, symbol packages, installers, etc.).
    DotNetPublishUsingPipelines     Publish assets using Azure DevOps release pipelines.
    DotNetArtifactsCategory         Type of assets being produced by the build.
    DotNetPublishToBlobFeed         Publish assets to blob feed using DotNetPublishBlobFeedUrl and DotNetPublishBlobFeedKey.
    DotNetPublishBlobFeedUrl        Target feed URL, or empty if not publishing to Azure blob feed.
    DotNetPublishBlobFeedKey        Azure blob feed account key.
    DotNetSymbolServerTokenMsdl     Personal access token for MSDL symbol server. Available from variable group DotNet-Symbol-Publish.
    DotNetSymbolServerTokenSymWeb   Personal access token for SymWeb symbol server. Available from variable group DotNet-Symbol-Publish.
    DotNetSymbolExpirationInDays    Symbol expiration time in days (defaults to 10 years).
    DotNetSignType                  Specifies the signing type: 'real' (default), 'test'.

    ContinuousIntegrationBuild      "true" when building on a CI server (PR build or official build)
    Restore                         "true" to restore toolset and solution
    Build                           "true" to build solution
    Rebuild                         "true" to rebuild solution
    Deploy                          "true" to deploy assets (e.g. VSIXes)
    Test                            "true" to run tests
    IntegrationTest                 "true" to run integration tests
    PerformanceTest                 "true" to run performance tests
    Pack                            "true" to build NuGet packages and VS insertion manifests
    Sign                            "true" to sign built binaries
    Publish                         "true" to publish artifacts (e.g. symbols)
  -->

  <PropertyGroup>
    <_RepoRootOriginal>$(RepoRoot)</_RepoRootOriginal>
    <RepoRoot>$([System.IO.Path]::GetFullPath('$(RepoRoot)/'))</RepoRoot>

    <_OriginalProjectsValue>$(Projects)</_OriginalProjectsValue>
  </PropertyGroup>

  <ItemDefinitionGroup>
    <ProjectToBuild>
      <RestoreInParallel>true</RestoreInParallel>
    </ProjectToBuild>
  </ItemDefinitionGroup>

  <Import Project="RepoLayout.props"/>

  <!-- Allow for repo specific Build properties such as the list of Projects to build -->
  <Import Project="$(RepositoryEngineeringDir)Build.props" Condition="Exists('$(RepositoryEngineeringDir)Build.props')" />

  <PropertyGroup>
    <_ProjectsPropertyWasUpdatedInBuildProps Condition="'$(_OriginalProjectsValue)' != '$(Projects)'">true</_ProjectsPropertyWasUpdatedInBuildProps>
  </PropertyGroup>

  <ItemGroup Condition="'$(Projects)' != ''">
    <!-- Copy the original list so we can log diagnostics later. -->
    <_OriginalProjectToBuild Include="@(ProjectToBuild)" />
    <!-- Setting 'Projects' overrides the ProjectToBuild list. -->
    <ProjectToBuild Remove="@(ProjectToBuild)" />
    <ProjectToBuild Include="$(Projects)" />
  </ItemGroup>

  <!--
    Default values.
  -->
  <!-- If Projects is unspecified and ProjectToBuild was not set via Build.props, fallback to building .sln files in the repo root. -->
  <ItemGroup Condition="'@(ProjectToBuild)' == ''">
    <ProjectToBuild Include="$(RepoRoot)*.sln" />
  </ItemGroup>

  <PropertyGroup>
    <_DotNetOutputBlobFeedDir>$(DotNetOutputBlobFeedDir)</_DotNetOutputBlobFeedDir>
    <_DotNetOutputBlobFeedDir Condition="'$(_DotNetOutputBlobFeedDir)' != '' and !HasTrailingSlash('$(_DotNetOutputBlobFeedDir)')">$(_DotNetOutputBlobFeedDir)\</_DotNetOutputBlobFeedDir>
  </PropertyGroup>

  <Target Name="Execute">
    <Error Text="No projects were found to build. Either the 'Projects' property or 'ProjectToBuild' item group must be specified." Condition="'@(ProjectToBuild)' == ''"/>
    <Error Text="Property 'RepoRoot' must be specified" Condition="'$(_RepoRootOriginal)' == ''"/>
    <Error Text="File 'global.json' must exist in directory specified by RepoRoot: '$(_RepoRootOriginal)'" Condition="'$(_RepoRootOriginal)' != '' and !Exists('$(RepoRoot)global.json')"/>

    <ItemGroup>
      <_SolutionBuildTargets Include="Rebuild" Condition="'$(Rebuild)' == 'true'" />
      <_SolutionBuildTargets Include="Build" Condition="'$(Build)' == 'true' and '$(Rebuild)' != 'true'" />
      <!-- Extensibility point to run addition build targets after build. -->
      <_SolutionBuildTargets Include="@(SolutionBuildTargets)" />
      <!-- Deploy target is set up to chain after Build so that F5 in VS works. -->
      <_SolutionBuildTargets Include="Test" Condition="'$(Test)' == 'true'" />
      <!-- Pack before running integration and performance tests so that these tests can test packages produced by the repo. -->
      <_SolutionBuildTargets Include="Pack" Condition="'$(Pack)' == 'true'" />
      <_SolutionBuildTargets Include="IntegrationTest" Condition="'$(IntegrationTest)' == 'true'" />
      <_SolutionBuildTargets Include="PerformanceTest" Condition="'$(PerformanceTest)' == 'true'" />
    </ItemGroup>

    <PropertyGroup>
      <_RemoveProps>Projects;Restore;Deploy;Sign;Publish;NETCORE_ENGINEERING_TELEMETRY;@(_SolutionBuildTargets)</_RemoveProps>
    </PropertyGroup>

    <ItemGroup>
      <_CommonProps Include="Configuration=$(Configuration)"/>
      <_CommonProps Include="ContinuousIntegrationBuild=$(ContinuousIntegrationBuild)"/>
      <_CommonProps Include="RepoRoot=$(RepoRoot)"/>
      <_CommonProps Include="VersionsPropsPath=$(VersionsPropsPath)"/>

      <!--
        When building from source we suppress restore for projects that set ExcludeFromSourceBuild=true.
        NuGet Restore task reports a warning for such projects, which we suppress here.
      -->
      <_CommonProps Include="DisableWarnForInvalidRestoreProjects=true" Condition="'$(DotNetBuildFromSource)' == 'true'"/>

      <!--
        C++ projects expect VCTargetsPath property to be set. MSBuild generates this property to solution
        metaproject when solution is build directly, but doesn't do so when the solution is built using MSBuild task.
      -->
      <_CommonProps Include="VCTargetsPath=$([MSBuild]::ValueOrDefault('$(VCTargetsPath)', '$([MSBuild]::GetVsInstallRoot())\Common7\IDE\VC\VCTargets\'))" Condition="'$(MSBuildRuntimeType)' != 'Core'"/>
    </ItemGroup>

    <ItemGroup Condition="'$(Restore)' == 'true'">
      <_RestoreToolsProps Include="@(_CommonProps)"/>
      <_RestoreToolsProps Include="BaseIntermediateOutputPath=$(ArtifactsToolsetDir)Common"/>
      <_RestoreToolsProps Include="ExcludeRestorePackageImports=true"/>
      <_RestoreToolsProps Include="PublishingToBlobStorage=$(DotNetPublishToBlobFeed)"/>
    </ItemGroup>

    <ItemGroup>
      <_PublishProps Include="@(_CommonProps)"/>
      <_PublishProps Include="PublishToAzureDevOpsArtifacts=$(DotNetPublishUsingPipelines)" />
      <_PublishProps Include="ArtifactsCategory=$(DotNetArtifactsCategory)" />
      <_PublishProps Include="AzureFeedUrl=$(DotNetPublishBlobFeedUrl)" Condition="'$(DotNetPublishToBlobFeed)' == 'true'" />
      <_PublishProps Include="AzureAccountKey=$(DotNetPublishBlobFeedKey)" Condition="'$(DotNetPublishToBlobFeed)' == 'true'" />
      <_PublishProps Include="DotNetOutputBlobFeedDir=$(_DotNetOutputBlobFeedDir)" Condition="'$(_DotNetOutputBlobFeedDir)' != ''" />
    </ItemGroup>

    <ItemGroup>
      <_SolutionBuildProps Include="@(_CommonProps)"/>
      <_SolutionBuildProps Include="__DeployProjectOutput=$(Deploy)" Condition="'$(Deploy)' != ''"/>
    </ItemGroup>

    <!--
      Restore built-in tools.
    -->
    <MSBuild Projects="Tools.proj"
             Targets="Restore"
             Properties="@(_RestoreToolsProps);_NETCORE_ENGINEERING_TELEMETRY=Restore"
             Condition="'$(Restore)' == 'true'"/>

    <!--
      Restore solutions and projects.

      Run solution restore separately from the other targets, in a different build phase.
      Since restore brings in new .props and .targets files we need to rerun evaluation.

      Workarounds:
      - Invoke restore using NuGet.targets directly (see https://github.com/NuGet/Home/issues/7648).
        This avoids duplicate calls to RestoreTask and race conditions on writing restore results to disk.

      - msbuild caches the metaproject for the solution (see https://github.com/Microsoft/msbuild/issues/1695)
        We invalidate the cache by changing the value of __BuildPhase property.
    -->

    <PropertyGroup>
      <!-- This can be set to false as an optimization for repos that don't use NuGet. -->
      <RestoreUsingNuGetTargets Condition="'$(RestoreUsingNuGetTargets)' == ''">true</RestoreUsingNuGetTargets>

      <!-- IsRunningFromVisualStudio may be true even when running msbuild.exe from command line. This generally means that MSBUild is Visual Studio installation and therefore we need to find NuGet.targets in a different location.  -->
      <_NuGetRestoreTargets>$(MSBuildToolsPath)\NuGet.targets</_NuGetRestoreTargets>
      <_NuGetRestoreTargets Condition="'$([MSBuild]::IsRunningFromVisualStudio())' == 'true'">$(MSBuildToolsPath32)\..\..\..\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets</_NuGetRestoreTargets>
    </PropertyGroup>

    <!--
      Detect which projects support restoring with NuGet targets.
      As a perf optimization, the Properties list here should match exactly with
      the properties passed to the "Restore" target a few lines below.
      This helps MSBuild cache the result of _IsProjectRestoreSupported.
    -->
    <MSBuild Projects="@(ProjectToBuild)"
             Properties="@(_SolutionBuildProps);__BuildPhase=SolutionRestore;_NETCORE_ENGINEERING_TELEMETRY=Restore"
             RemoveProperties="$(_RemoveProps)"
             Targets="_IsProjectRestoreSupported"
             SkipNonexistentTargets="true"
             BuildInParallel="true"
             Condition="'$(RestoreUsingNuGetTargets)' != 'false' and '%(ProjectToBuild.Extension)' != '.sln' and '$(Restore)' == 'true'">

      <Output TaskParameter="TargetOutputs" ItemName="_ProjectToRestoreWithNuGet" />
    </MSBuild>

    <PropertyGroup>
      <!-- Normalize paths to avoid false warnings by NuGet about missing project references. -->
      <_ProjectToRestoreWithNuGetList>@(_ProjectToRestoreWithNuGet->'%(FullPath)')</_ProjectToRestoreWithNuGetList>
    </PropertyGroup>

    <ItemGroup>
      <_ProjectToRestore Include="$(_NuGetRestoreTargets)" Condition="'$(_ProjectToRestoreWithNuGetList)' != '' and '$(RestoreUsingNuGetTargets)' != 'false'">
        <AdditionalProperties>RestoreGraphProjectInput=$(_ProjectToRestoreWithNuGetList)</AdditionalProperties>
        <RestoreInParallel>true</RestoreInParallel>
      </_ProjectToRestore>

      <!-- Invoke the 'Restore' target on solutions and projects which do not support NuGet. -->
      <_ProjectToRestore Include="@(ProjectToBuild)" Exclude="@(_ProjectToRestoreWithNuGet)" />
    </ItemGroup>

    <MSBuild Projects="@(_ProjectToRestore)"
             Properties="@(_SolutionBuildProps);__BuildPhase=SolutionRestore;_NETCORE_ENGINEERING_TELEMETRY=Restore"
             RemoveProperties="$(_RemoveProps)"
             Targets="Restore"
             SkipNonexistentTargets="true"
             BuildInParallel="%(_ProjectToRestore.RestoreInParallel)"
             Condition="'$(Restore)' == 'true'"/>

    <!--
      Build solution.
    -->
    <MSBuild Projects="@(ProjectToBuild)"
             Properties="@(_SolutionBuildProps);__BuildPhase=SolutionBuild;_NETCORE_ENGINEERING_TELEMETRY=Build"
             RemoveProperties="$(_RemoveProps)"
             Targets="@(_SolutionBuildTargets)"
             BuildInParallel="true"
             Condition="'@(_SolutionBuildTargets)' != ''" />

    <MSBuild Projects="AfterSolutionBuild.proj"
             Properties="@(_CommonProps);_NETCORE_ENGINEERING_TELEMETRY=Build"
             Targets="@(_SolutionBuildTargets)"
             SkipNonexistentTargets="true"
             Condition="'@(_SolutionBuildTargets)' != ''" />

    <!--
      Sign artifacts.
    -->
    <MSBuild Projects="Sign.proj"
             Properties="@(_CommonProps)"
             Targets="Sign"
             Condition="'$(Sign)' == 'true'"/>

    <MSBuild Projects="AfterSigning.proj"
             Properties="@(_CommonProps);_NETCORE_ENGINEERING_TELEMETRY=Sign"
             Targets="@(_SolutionBuildTargets)"
             SkipNonexistentTargets="true"
             Condition="'@(_SolutionBuildTargets)' != ''"/>

    <MSBuild Projects="Publish.proj"
             Properties="@(_PublishProps);_NETCORE_ENGINEERING_TELEMETRY=Publish"
             Targets="Publish"
             Condition="'$(Publish)' == 'true'"/>
  </Target>
</Project>