dotnet-installer/old/build/Prepare.targets
2018-10-21 20:47:58 -07:00

153 lines
7.3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Microsoft.DotNet.Cli.tasks" />
<Import Project="prepare/CheckPrereqs.targets" />
<Target Name="Prepare"
DependsOnTargets="Init;DownloadHostAndSharedFxArtifacts;DownloadToolsetArtifacts;RestoreSrcPackages;RestoreToolsPackages;IsolateArtifactsFromDirectoryBuildFiles;CreatePropsForNextStage" />
<Target Name="Init"
DependsOnTargets="PrintBuildInfo;
SetTelemetryProfile;
BuildDotnetCliBuildFramework;
CheckPrereqs;">
</Target>
<Target Name="SandBoxPrepare"
DependsOnTargets="PrintBuildInfo;
CheckPrereqs;
DownloadHostAndSharedFxArtifacts;
IsolateArtifactsFromDirectoryBuildFiles;
CreatePropsForNextStage">
</Target>
<Target Name="PrintBuildInfo">
<Message Text="Host info - Rid: $(HostRid), OSName: $(HostOSName)" Importance="High" />
<Message Text="Build info - Rid: $(Rid), Architecture: $(Architecture), OSName: $(OSName)" Importance="High" />
<Message Text="If you intended to use a different Rid, Architecture, or OSName run the following command to generate your build state:" Importance="High" />
<Message Text="dotnet msbuild build.proj /p:Architecture=Architecture /p:Rid=Rid /p:OSName=OSName /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles" Importance="High" />
</Target>
<Target Name="SetTelemetryProfile"
DependsOnTargets="BuildDotnetCliBuildFramework" >
<SetEnvVar Name="DOTNET_CLI_TELEMETRY_PROFILE" Value="$(DOTNET_CLI_TELEMETRY_PROFILE);https://github.com/dotnet/cli;$(CommitHash)" />
</Target>
<Target Name="DownloadHostAndSharedFxArtifacts">
<PropertyGroup>
<OverwriteExtractionDestination>%(_DownloadAndExtractItem.OverwriteDestination)</OverwriteExtractionDestination>
<OverwriteExtractionDestination Condition="'$(OverwriteExtractionDestination)' == ''">True</OverwriteExtractionDestination>
</PropertyGroup>
<DownloadFile Condition=" '@(_DownloadAndExtractItem)' != '' And '%(_DownloadAndExtractItem.Local)' != 'true'"
Uri="%(_DownloadAndExtractItem.Url)"
DestinationPath="%(_DownloadAndExtractItem.DownloadFileName)" />
<Copy Condition=" '@(_DownloadAndExtractItem)' != '' And '%(_DownloadAndExtractItem.Local)' == 'true'"
SourceFiles="%(_DownloadAndExtractItem.Url)"
DestinationFiles="%(_DownloadAndExtractItem.DownloadFileName)" />
<ZipFileExtractToDirectory Condition=" '%(_DownloadAndExtractItem.ExtractDestination)' != '' AND $([System.String]::new('%(_DownloadAndExtractItem.DownloadFileName)').EndsWith('.zip')) "
SourceArchive="%(_DownloadAndExtractItem.DownloadFileName)"
DestinationDirectory="%(_DownloadAndExtractItem.ExtractDestination)"
OverwriteDestination="$(OverwriteExtractionDestination)" />
<TarGzFileExtractToDirectory Condition=" '%(_DownloadAndExtractItem.ExtractDestination)' != '' AND $([System.String]::new('%(_DownloadAndExtractItem.DownloadFileName)').EndsWith('.tar.gz')) "
SourceArchive="%(_DownloadAndExtractItem.DownloadFileName)"
DestinationDirectory="%(_DownloadAndExtractItem.ExtractDestination)"
OverwriteDestination="$(OverwriteExtractionDestination)" />
</Target>
<Target Name="DownloadToolsetArtifacts">
</Target>
<Target Name="RestoreSrcPackages"
DependsOnTargets="SetupRestoreSrcPackagesInputsOutputs;Init"
Inputs="@(RestoreSrcPackagesInput)"
Outputs="@(RestoreSrcPackagesInput->'%(RelativeDir)/obj/project.assets.json');@(RestoreSrcPackagesInput->'%(RelativeDir)/obj/%(Filename).csproj.nuget.g.props');@(RestoreSrcPackagesInput->'%(RelativeDir)/obj/%(Filename).csproj.nuget.g.targets')">
<CallTarget Targets="CleanSrcLockFiles" />
<DotNetRestore ToolPath="$(PreviousStageDirectory)"
ProjectPath="&quot;%(RestoreSrcPackagesInput.FullPath)&quot;" />
</Target>
<Target Name="CleanSrcLockFiles" >
<ItemGroup>
<SrcLockFiles Include="$(RepoRoot)/src/**/project.assets.json;$(RepoRoot)/src/**/*.csproj.nuget.g.props;$(RepoRoot)/src/**/*.csproj.nuget.g.targets" />
</ItemGroup>
<Delete Files="@(SrcLockFiles)" />
</Target>
<Target Name="SetupRestoreSrcPackagesInputsOutputs">
<ItemGroup>
<RestoreSrcPackagesInput Include="$(RepoRoot)/src/**/*.csproj" />
</ItemGroup>
</Target>
<Target Name="RestoreToolsPackages"
DependsOnTargets="SetupRestoreToolsPackagesInputsOutputs;Init"
Inputs="@(RestoreToolsPackagesInput)"
Outputs="@(RestoreToolsPackagesInput->'%(RelativeDir)/obj/project.assets.json');@(RestoreToolsPackagesInput->'%(RelativeDir)/obj/%(Filename).csproj.nuget.g.props');@(RestoreToolsPackagesInput->'%(RelativeDir)/obj/%(Filename).csproj.nuget.g.targets')">
<CallTarget Targets="CleanToolsLockFiles" />
<DotNetRestore ToolPath="$(PreviousStageDirectory)"
ProjectPath="&quot;%(RestoreToolsPackagesInput.FullPath)&quot;"
AdditionalParameters="/p:UsePortableLinuxSharedFramework=$(UsePortableLinuxSharedFramework)" />
</Target>
<Target Name="CleanToolsLockFiles" >
<ItemGroup>
<ToolsLockFiles Include="$(RepoRoot)/tools/**/project.assets.json;$(RepoRoot)/tools/**/*.csproj.nuget.g.props;$(RepoRoot)/tools/**/*.csproj.nuget.g.targets" />
</ItemGroup>
<Delete Files="@(ToolsLockFiles)" />
</Target>
<Target Name="SetupRestoreToolsPackagesInputsOutputs">
<ItemGroup>
<RestoreToolsPackagesInput Include="$(RepoRoot)/tools/**/*.csproj" />
</ItemGroup>
</Target>
<Target Name="IsolateArtifactsFromDirectoryBuildFiles">
<Copy SourceFiles="$(RepoRoot)TestAssets\Directory.Build.props"
DestinationFolder ="$(RepoRoot)bin"
SkipUnchangedFiles="true" />
</Target>
<Target Name="CreatePropsForNextStage">
<PropertyGroup>
<NextStagePropsContent>
&lt;Project&gt;
&lt;PropertyGroup&gt;
&lt;PreviousStageDirectory&gt;$(OutputDirectory)&lt;/PreviousStageDirectory&gt;
&lt;PreviousStageDotnet&gt;$(DotnetInOutputDirectory)&lt;/PreviousStageDotnet&gt;
&lt;CliOuterBuildStage&gt;$(CliBuildStage)&lt;/CliOuterBuildStage&gt;
&lt;/PropertyGroup&gt;
&lt;/Project&gt;
</NextStagePropsContent>
<ExistingNextStagePropsContent Condition=" Exists('$(NextStagePropsPath)') ">
$([System.IO.File]::ReadAllText($(NextStagePropsPath)))
</ExistingNextStagePropsContent>
<ShouldOverwriteNextStagePropsFile>false</ShouldOverwriteNextStagePropsFile>
<ShouldOverwriteNextStagePropsFile
Condition=" '$(ExistingNextStagePropsContent.Trim())' != '$(NextStagePropsContent.Trim())' ">true</ShouldOverwriteNextStagePropsFile>
</PropertyGroup>
<WriteLinesToFile File="$(NextStagePropsPath)"
Lines="$(NextStagePropsContent)"
Condition=" '$(ShouldOverwriteNextStagePropsFile)' == 'true' "
Overwrite="true" />
</Target>
</Project>