Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View File

@@ -5,7 +5,9 @@
# the default owners for everything in the repo.
* @marek-safar
/analyzer @radekdoulik
/src/analyzer @radekdoulik
/corebuild @sbomer
/src/linker @marek-safar @mrvoorhe
/test @marek-safar @mrvoorhe
netci.groovy @sbomer

View File

@@ -27,12 +27,9 @@ bin/
**/Dependencies/*.dll
# corebuild build/test artifacts
corebuild/Tools
corebuild/bootstrap.log
corebuild/global.json
corebuild/**/bin
corebuild/**/obj
corebuild/testbin
# arcade artifacts
.dotnet
.packages
artifacts
monobuild/TestResults.xml

View File

@@ -1,3 +1,3 @@
[submodule "cecil"]
path = cecil
path = external/cecil
url = git://github.com/mono/cecil.git

6
external/linker/Directory.Build.props vendored Normal file
View File

@@ -0,0 +1,6 @@
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" Condition=" '$(ArcadeBuild)' == 'true' " />
<PropertyGroup>
<IsPackable>false</IsPackable>
</PropertyGroup>
</Project>

14
external/linker/Directory.Build.targets vendored Normal file
View File

@@ -0,0 +1,14 @@
<Project>
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" Condition=" '$(ArcadeBuild)' == 'true' " />
<!-- Map the Arcade "Test" target to the "VSTest" target used by "dotnet test" -->
<Target Name="Test"
Condition=" '$(ArcadeBuild)' == 'true' And '$(DisableArcadeTestFramework)' == 'true' ">
<MSBuild Projects="$(MSBuildProjectFile)" Targets="VSTest" />
</Target>
<Target Name="VSTestIfTestProject">
<CallTarget Targets="VSTest" Condition="'$(IsTestProject)' == 'true'" />
</Target>
</Project>

View File

@@ -4,7 +4,9 @@
<!-- nuget-build is necessary for the integration package to
depend on the same NuGet package that the sdk uses -->
<add key="nuget-build" value="https://dotnet.myget.org/F/nuget-build/api/v3/index.json" />
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="dotnet-core-myget" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
<add key="dotnet-coreclr" value="https://dotnetfeed.blob.core.windows.net/dotnet-coreclr/index.json" />
</packageSources>
</configuration>

View File

@@ -1,4 +1,4 @@
# [IL Linker](linker/README.md)
# [IL Linker](src/linker/README.md)
The IL Linker is a tool one can use to only ship the minimal possible IL code and metadata that a set of
programs might require to run as opposed to the full libraries.
@@ -6,9 +6,9 @@ programs might require to run as opposed to the full libraries.
It is used by the various Xamarin products to extract only the bits of code that are needed to run
an application on Android, iOS and other platforms.
It can also be used in the form of [ILLink.Tasks](corebuild/README.md) to reduce the size of .NET Core apps.
It can also be used in the form of [ILLink.Tasks](src/ILLink.Tasks/README.md) to reduce the size of .NET Core apps.
# [Analyzer](analyzer/README.md)
# [Analyzer](src/analyzer/README.md)
The analyzer is a tool to analyze dependencies which were recorded during linker processing and led linker to mark an item to keep it in the resulting linked assembly.

View File

@@ -0,0 +1,6 @@
<Project>
<!-- Workaround for https://github.com/dotnet/corefx/issues/16322 -->
<Target Name="VSTest">
<MSBuild Projects="@(ProjectReference)" Targets="VSTestIfTestProject" />
</Target>
</Project>

View File

@@ -1 +0,0 @@
2.0.0

View File

@@ -1,67 +0,0 @@
param
(
[Parameter(Mandatory=$false)][string]$RepositoryRoot = $PSScriptRoot,
[Parameter(Mandatory=$false)][string]$ToolsLocalPath = (Join-Path $RepositoryRoot "Tools"),
[Parameter(Mandatory=$false)][string]$CliLocalPath = (Join-Path $ToolsLocalPath "dotnetcli"),
[Parameter(Mandatory=$false)][string]$SharedFrameworkSymlinkPath = (Join-Path $ToolsLocalPath "dotnetcli\shared\Microsoft.NETCore.App\version"),
[Parameter(Mandatory=$false)][string]$SharedFrameworkVersion = "<auto>",
[Parameter(Mandatory=$false)][string]$Architecture = "<auto>",
[Parameter(Mandatory=$false)][string]$DotNetInstallBranch = "release/2.0.0",
[switch]$Force = $false
)
$rootCliVersion = Join-Path $RepositoryRoot ".cliversion"
$globalJson = Join-Path $RepositoryRoot "global.json"
$bootstrapComplete = Join-Path $ToolsLocalPath "bootstrap.complete"
# if the force switch is specified delete the semaphore file if it exists
if ($Force -and (Test-Path $bootstrapComplete))
{
del $bootstrapComplete
}
# if the semaphore file exists and is identical to the specified version then exit
if ((Test-Path $bootstrapComplete) -and !(Compare-Object (Get-Content $rootCliVersion) (Get-Content $bootstrapComplete)))
{
exit 0
}
$initCliScript = "dotnet-install.ps1"
$dotnetInstallPath = Join-Path $ToolsLocalPath $initCliScript
# blow away the tools directory so we can start from a known state
if (Test-Path $ToolsLocalPath)
{
# if the bootstrap.ps1 script was downloaded to the tools directory don't delete it
rd -recurse -force $ToolsLocalPath -exclude "bootstrap.ps1"
}
else
{
mkdir $ToolsLocalPath | Out-Null
}
# download CLI boot-strapper script
Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/$DotNetInstallBranch/scripts/obtain/dotnet-install.ps1" -OutFile $dotnetInstallPath
# load the version of the CLI
$dotNetCliVersion = Get-Content $rootCliVersion
if (-Not (Test-Path $CliLocalPath))
{
mkdir $CliLocalPath | Out-Null
}
# now execute the script
Write-Host "$dotnetInstallPath -Version $dotNetCliVersion -InstallDir $CliLocalPath -Architecture ""$Architecture"""
Invoke-Expression "$dotnetInstallPath -Version $dotNetCliVersion -InstallDir $CliLocalPath -Architecture ""$Architecture"""
if ($LastExitCode -ne 0)
{
Write-Output "The .NET CLI installation failed with exit code $LastExitCode"
exit $LastExitCode
}
"{ `"sdk`": { `"version`": `"$dotNetCliVersion`" } }" | Out-File -Encoding utf8 -FilePath $globalJson
# write semaphore file
copy $rootCliVersion $bootstrapComplete
exit 0

View File

@@ -1,206 +0,0 @@
#!/usr/bin/env bash
# Stop script on NZEC
# set -e
# Stop script if unbound variable found (use ${var:-} if intentional)
set -u
# By default cmd1 | cmd2 returns exit code of cmd2 regardless of cmd1 success
# This is causing it to fail
set -o pipefail
# Use in the the functions: eval $invocation
invocation='say_verbose "Calling: ${FUNCNAME[0]}"'
# standard output may be used as a return value in the functions
# we need a way to write text on the screen in the functions so that
# it won't interfere with the return value.
# Exposing stream 3 as a pipe to standard output of the script itself
exec 3>&1
say_err() {
printf "%b\n" "bootstrap: Error: $1" >&2
}
say() {
# using stream 3 (defined in the beginning) to not interfere with stdout of functions
# which may be used as return value
printf "%b\n" "bootstrap: $1" >&3
}
say_verbose() {
if [ "$verbose" = true ]; then
say "$1"
fi
}
machine_has() {
eval $invocation
hash "$1" > /dev/null 2>&1
return $?
}
check_min_reqs() {
if ! machine_has "curl"; then
say_err "curl is required to download dotnet. Install curl to proceed."
return 1
fi
return 0
}
# args:
# remote_path - $1
# [out_path] - $2 - stdout if not provided
download() {
eval $invocation
local remote_path=$1
local out_path=${2:-}
local failed=false
if [ -z "$out_path" ]; then
curl --retry 10 -sSL --create-dirs $remote_path || failed=true
else
curl --retry 10 -sSL --create-dirs -o $out_path $remote_path || failed=true
fi
if [ "$failed" = true ]; then
say_err "Download failed"
return 1
fi
}
verbose=false
repoRoot=`pwd`
toolsLocalPath="<auto>"
cliLocalPath="<auto>"
symlinkPath="<auto>"
sharedFxVersion="<auto>"
force=
forcedCliLocalPath="<none>"
architecture="<auto>"
dotNetInstallBranch="release/2.0.0"
while [ $# -ne 0 ]
do
name=$1
case $name in
-r|--repositoryRoot|-[Rr]epositoryRoot)
shift
repoRoot="$1"
;;
-t|--toolsLocalPath|-[Tt]oolsLocalPath)
shift
toolsLocalPath="$1"
;;
-c|--cliInstallPath|--cliLocalPath|-[Cc]liLocalPath)
shift
cliLocalPath="$1"
;;
-u|--useLocalCli|-[Uu]seLocalCli)
shift
forcedCliLocalPath="$1"
;;
-a|--architecture|-[Aa]rchitecture)
shift
architecture="$1"
;;
--dotNetInstallBranch|-[Dd]ot[Nn]et[Ii]nstall[Bb]ranch)
shift
dotNetInstallBranch="$1"
;;
--sharedFrameworkSymlinkPath|--symlink|-[Ss]haredFrameworkSymlinkPath)
shift
symlinkPath="$1"
;;
--sharedFrameworkVersion|-[Ss]haredFrameworkVersion)
sharedFxVersion="$1"
;;
--force|-[Ff]orce)
force=true
;;
-v|--verbose|-[Vv]erbose)
verbose=true
;;
*)
say_err "Unknown argument \`$name\`"
exit 1
;;
esac
shift
done
if [ $toolsLocalPath = "<auto>" ]; then
toolsLocalPath="$repoRoot/Tools"
fi
if [ $cliLocalPath = "<auto>" ]; then
if [ $forcedCliLocalPath = "<none>" ]; then
cliLocalPath="$toolsLocalPath/dotnetcli"
else
cliLocalPath=$forcedCliLocalPath
fi
fi
if [ $symlinkPath = "<auto>" ]; then
symlinkPath="$toolsLocalPath/dotnetcli/shared/Microsoft.NETCore.App/version"
fi
rootCliVersion="$repoRoot/.cliversion"
globalJson="$repoRoot/global.json"
bootstrapComplete="$toolsLocalPath/bootstrap.complete"
# if the force switch is specified delete the semaphore file if it exists
if [[ $force && -f $bootstrapComplete ]]; then
rm -f $bootstrapComplete
fi
# if the semaphore file exists and is identical to the specified version then exit
if [[ -f $bootstrapComplete && ! `cmp $bootstrapComplete $rootCliVersion` ]]; then
say "$bootstrapComplete appears to show that bootstrapping is complete. Use --force if you want to re-bootstrap."
exit 0
fi
initCliScript="dotnet-install.sh"
dotnetInstallPath="$toolsLocalPath/$initCliScript"
# blow away the tools directory so we can start from a known state
if [ -d $toolsLocalPath ]; then
# if the bootstrap.sh script was downloaded to the tools directory don't delete it
find $toolsLocalPath -type f -not -name bootstrap.sh -exec rm -f {} \;
else
mkdir $toolsLocalPath
fi
if [ $forcedCliLocalPath = "<none>" ]; then
check_min_reqs
# download CLI boot-strapper script
download "https://raw.githubusercontent.com/dotnet/cli/$dotNetInstallBranch/scripts/obtain/dotnet-install.sh" "$dotnetInstallPath"
chmod u+x "$dotnetInstallPath"
# load the version of the CLI
dotNetCliVersion=`cat $rootCliVersion`
if [ ! -e $cliLocalPath ]; then
mkdir -p "$cliLocalPath"
fi
# now execute the script
say_verbose "installing CLI: $dotnetInstallPath --version \"$dotNetCliVersion\" --install-dir $cliLocalPath --architecture \"$architecture\""
$dotnetInstallPath --version "$dotNetCliVersion" --install-dir $cliLocalPath --architecture "$architecture"
if [ $? != 0 ]; then
say_err "The .NET CLI installation failed with exit code $?"
exit $?
fi
echo "{ \"sdk\": { \"version\": \"$dotNetCliVersion\" } }" > $globalJson
fi
cp $rootCliVersion $bootstrapComplete
say "Bootstrap finished successfully."

View File

@@ -2,5 +2,5 @@
REM build.cmd will bootstrap the cli and ultimately call "dotnet pack"
@call %~dp0dotnet.cmd pack %~dp0integration\ILLink.Tasks\ILLink.Tasks.csproj %*
@call %~dp0dotnet.cmd pack %~dp0..\src\ILLink.Tasks\ILLink.Tasks.csproj %*
@exit /b %ERRORLEVEL%

View File

@@ -3,5 +3,5 @@
# build.sh will bootstrap the cli and ultimately call "dotnet build"
working_tree_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
$working_tree_root/dotnet.sh build $working_tree_root/linker.sln $@
$working_tree_root/../eng/dotnet.sh build $working_tree_root/../illink.sln $@
exit $?

View File

@@ -2,14 +2,18 @@
setlocal
if not defined VisualStudioVersion (
if defined VS150COMNTOOLS (
call "%VS150COMNTOOLS%\VsDevCmd.bat"
goto :Run
)
if defined VS140COMNTOOLS (
call "%VS140COMNTOOLS%\VsDevCmd.bat"
goto :Run
)
echo Error: Visual Studio 2015 required.
echo Error: Visual Studio 2015 or 2017 required.
exit /b 1
)
:Run
powershell -NoProfile -ExecutionPolicy unrestricted -Command "%~dp0dotnet.ps1 -- %*"
powershell -NoProfile -ExecutionPolicy unrestricted -Command "%~dp0..\eng\dotnet.ps1 -- %*"
exit /b %ERRORLEVEL%

View File

@@ -1,27 +0,0 @@
# set the base tools directory
$toolsLocalPath = Join-Path $PSScriptRoot "Tools"
$bootStrapperPath = Join-Path $toolsLocalPath "bootstrap.ps1"
# if the boot-strapper script doesn't exist copy it to the tools path
if ((Test-Path $bootStrapperPath) -eq 0)
{
if ((Test-Path $toolsLocalPath) -eq 0)
{
mkdir $toolsLocalPath | Out-Null
}
cp (Join-Path $PSScriptRoot "bootstrap.ps1") $bootStrapperPath
}
# now execute it
& $bootStrapperPath $PSScriptRoot $toolsLocalPath | Out-File (Join-Path $PSScriptRoot "bootstrap.log")
if ($LastExitCode -ne 0)
{
Write-Output "Boot-strapping failed with exit code $LastExitCode, see bootstrap.log for more information."
exit $LastExitCode
}
# execute the tool using the dotnet.exe host
$dotNetExe = Join-Path $toolsLocalPath "dotnetcli\dotnet.exe"
& $dotNetExe $args
exit $LastExitCode

View File

@@ -1,25 +0,0 @@
#!/usr/bin/env bash
__scriptpath=$(cd "$(dirname "$0")"; pwd -P)
toolsLocalPath=$__scriptpath/Tools
bootStrapperPath=$toolsLocalPath/bootstrap.sh
if [ ! -e $bootStrapperPath ]; then
if [ ! -e $toolsLocalPath ]; then
mkdir $toolsLocalPath
fi
cp $__scriptpath/bootstrap.sh $__scriptpath/Tools
fi
$bootStrapperPath --verbose --repositoryRoot $__scriptpath --toolsLocalPath $toolsLocalPath > bootstrap.log
lastExitCode=$?
if [ $lastExitCode -ne 0 ]; then
echo "Boot-strapping failed with exit code $lastExitCode, see bootstrap.log for more information."
exit $lastExitCode
fi
dotNetExe=$toolsLocalPath/dotnetcli/dotnet
echo $dotNetExe $@
$dotNetExe $@
exit $?

View File

@@ -1,31 +0,0 @@
using System.Linq;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace ILLink.Tasks
{
public class ComputeCrossgenedAssemblies : Task
{
/// <summary>
/// Paths to assemblies.
/// </summary>
[Required]
public ITaskItem[] Assemblies { get; set; }
/// <summary>
/// This will contain the output list of crossgen-ed
/// assemblies. Metadata from the input parameter
/// Assemblies is preserved.
/// </summary>
[Output]
public ITaskItem[] CrossgenedAssemblies { get; set; }
public override bool Execute()
{
CrossgenedAssemblies = Assemblies
.Where(f => Utils.IsCrossgenedAssembly(f.ItemSpec))
.ToArray();
return true;
}
}
}

View File

@@ -1,84 +0,0 @@
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.NET.Build.Tasks; // LockFileCache
using NuGet.Frameworks; // NuGetFramework.Parse(targetframework)
using NuGet.ProjectModel; // LockFileTargetLibrary
namespace ILLink.Tasks
{
public class GetRuntimeLibraries : Task
{
/// <summary>
/// Path to the assets file.
/// </summary>
[Required]
public ITaskItem AssetsFilePath { get; set; }
/// <summary>
/// Target framework for which to get the platform
/// libraries.
/// </summary>
[Required]
public string TargetFramework { get; set; }
/// <summary>
/// Runtime identifier for which to get the platform
/// libraries.
/// </summary>
[Required]
public string RuntimeIdentifier { get; set; }
/// <summary>
/// Name of the library to consider the "platform"
/// library.
/// </summary>
[Required]
public string[] PackageNames { get; set; }
[Output]
public ITaskItem[] RuntimeLibraries { get; private set; }
public override bool Execute()
{
var lockFile = new LockFileCache(BuildEngine4).GetLockFile(AssetsFilePath.ItemSpec);
var lockFileTarget = lockFile.GetTarget(NuGetFramework.Parse(TargetFramework), RuntimeIdentifier);
if (lockFileTarget == null) {
var targetString = string.IsNullOrEmpty(RuntimeIdentifier) ? TargetFramework : $"{TargetFramework}/{RuntimeIdentifier}";
throw new Exception($"Missing target section {targetString} from assets file {AssetsFilePath}. Ensure you have restored this project previously.");
}
Dictionary<string, LockFileTargetLibrary> packages = new Dictionary<string, LockFileTargetLibrary>(lockFileTarget.Libraries.Count, StringComparer.OrdinalIgnoreCase);
foreach (var lib in lockFileTarget.Libraries) {
packages.Add(lib.Name, lib);
}
HashSet<string> packageNames = new HashSet<string>(PackageNames);
var rootPackages = lockFileTarget.Libraries.Where(l => packageNames.Contains(l.Name));
var packageQueue = new Queue<LockFileTargetLibrary>(rootPackages);
var libraries = new List<string>();
while (packageQueue.Count > 0) {
var package = packageQueue.Dequeue();
foreach (var lib in package.RuntimeAssemblies) {
libraries.Add(lib.ToString());
}
foreach (var dep in package.Dependencies.Select(d => d.Id)) {
packageQueue.Enqueue(packages[dep]);
}
}
RuntimeLibraries = libraries.Select(l => new TaskItem(l)).ToArray();
return true;
}
}
}

View File

@@ -1,229 +0,0 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CrossGenDuringPublish Condition=" '$(CrossGenDuringPublish)' == '' And '$(RuntimeIdentifier)' != '' And '$(LinkDuringPublish)' == 'true' ">true</CrossGenDuringPublish>
</PropertyGroup>
<PropertyGroup>
<IntermediateOptimizedDirName Condition=" '$(IntermediateOptimizedDirName)' == '' ">optimized</IntermediateOptimizedDirName>
<IntermediateOptimizedDir Condition=" '$(IntermediateOptimizedDir)' == '' ">$(IntermediateOutputPath)$(IntermediateOptimizedDirName)</IntermediateOptimizedDir>
<IntermediateCrossGenDirName Condition=" '$(IntermediateCrossGenDirName)' == '' ">crossgen</IntermediateCrossGenDirName>
<IntermediateCrossGenDir Condition=" '$(IntermediateCrossGenDir)' == '' ">$(IntermediateOutputPath)$(IntermediateCrossGenDirName)</IntermediateCrossGenDir>
</PropertyGroup>
<PropertyGroup>
<ComputeCrossGenFilesToPublishAfter Condition=" '$(LinkDuringPublish)' == 'true' ">ComputeLinkedFilesToPublish</ComputeCrossGenFilesToPublishAfter>
<ComputeCrossGenFilesToPublishBefore Condition=" '$(LinkDuringPublish)' != 'true' ">ComputeFilesToPublish</ComputeCrossGenFilesToPublishBefore>
</PropertyGroup>
<!-- Rewrite inputs to ComputeFilesToPublish, so that crossgen'd
files get published instead of the pre-crossgen assemblies. -->
<Target Name="ComputeCrossGenFilesToPublish"
BeforeTargets="$(ComputeCrossGenFilesToPublishBefore)"
AfterTargets="$(ComputeCrossGenFilesToPublishAfter)"
Condition=" '$(CrossGenDuringPublish)' == 'true' "
DependsOnTargets="_CrossGenForPublish">
<!-- Rewrite ResolvedAssembliesToPublish, preserving metadata. -->
<ItemGroup>
<_CrossGenResolvedAssembliesToPublishCandidates Include="@(ResolvedAssembliesToPublish->'$(IntermediateOptimizedDir)/%(Filename)%(Extension)')" />
<_CrossGenResolvedAssembliesToPublish Include="@(_CrossGenResolvedAssembliesToPublishCandidates)" Condition="Exists('%(Identity)')" />
<ResolvedAssembliesToPublish Remove="@(FilesToCrossGen)" />
<ResolvedAssembliesToPublish Include="@(_CrossGenResolvedAssembliesToPublish)" />
</ItemGroup>
<!-- Rewrite IntermediateAssembly, preserving metadata. -->
<ItemGroup>
<_CrossGenIntermediateAssemblyCandidates Include="@(IntermediateAssembly->'$(IntermediateOptimizedDir)/%(Filename)%(Extension)')" />
<_CrossGenIntermediateAssembly Include="@(_CrossGenIntermediateAssemblyCandidates)" Condition="Exists('%(Identity)')" />
<IntermediateAssembly Remove="@(FilesToCrossGen)" />
<IntermediateAssembly Include="@(_CrossGenIntermediateAssembly)" />
</ItemGroup>
</Target>
<!-- The target that runs crossgen on all input assemblies. We could
probably also reuse _RunCrossgen, but this gets its inputs from
ResolvedFileToPublish, so we would need to run crossgen after
ComputeFilesToPublish. -->
<Target Name="_CrossGenForPublish"
DependsOnTargets="PrepOptimizer;_ComputeCrossGenInputs">
<MakeDir Directories="$(IntermediateOptimizedDir)" />
<PropertyGroup>
<_CrossGenPlatformAssemblies>@(_CrossGenPlatformAssemblies)</_CrossGenPlatformAssemblies>
</PropertyGroup>
<ItemGroup>
<CrossGenInvocations Include="$(MSBuildProjectFullPath)">
<Properties>
CrossGenExe=$(Crossgen);
CrossGenInput=%(FilesToCrossGen.FullPath);
CrossGenOutput=$(IntermediateOptimizedDir)/%(Filename)%(Extension);
CrossGenPlatformAssemblies=$(_CrossGenPlatformAssemblies)
</Properties>
</CrossGenInvocations>
</ItemGroup>
<MSBuild Projects="@(CrossGenInvocations)"
Targets="RunCrossGenForPublish" />
</Target>
<!-- Workarounds for SDK issues around the interdependency between
ComposeStore targets and CrossGen targets. These let us reuse
PrepOptimizer from the SDK to obtain a crossgen executable for
the target RID. -->
<!-- _RestoreCrossgen (a dependency of PrepOptimizer) requires _TFM
to be set, but it is only set in an unrelated target called
during ComposeStore (PrepareForComposeStore). -->
<Target Name="_SetTFMForCrossGenRestore"
BeforeTargets="_RestoreCrossgen"
Condition=" '$(CrossGenDuringPublish)' == 'true' ">
<PropertyGroup>
<_TFM Condition=" '$(_TFM)' == '' ">$(TargetFramework)</_TFM>
</PropertyGroup>
</Target>
<!-- _RestoreCrossgen also requires _CrossProjAssetsFile to be
set. This path is computed from ComposeWorkingDir in the target
_GetCrossgenProps, but ComposeWorkingDir is set only in
store-related targets. We hook into _GetCrossgenProps to
specify where to restore crossgen. -->
<Target Name="_SetComposeWorkingDirForCrossGenRestore"
AfterTargets="_GetCrossgenProps"
Condition=" '$(CrossGenDuringPublish)' == 'true' ">
<PropertyGroup>
<_CrossProjFileDir>$([System.IO.Path]::GetFullPath($(IntermediateCrossGenDir)))</_CrossProjFileDir>
<_NetCoreRefDir>$([System.IO.Path]::Combine($(_CrossProjFileDir), "netcoreapp"))</_NetCoreRefDir>
<_CrossProjAssetsFile>$([System.IO.Path]::Combine($(_CrossProjFileDir), project.assets.json))</_CrossProjAssetsFile>
</PropertyGroup>
<MakeDir Directories="$(_CrossProjFileDir)" />
</Target>
<!-- PrepforRestoreForComposeStore (a dependency of
_RestoreCrossgen) sets BaseIntermediateOutputPath and
ProjectAssetsFile to the compose working directory. We don't
want this because we are not composing a package store, so we
save and restore these properties. -->
<Target Name="_SavePropsModifiedByPrepforRestoreForComposeStore"
BeforeTargets="PrepforRestoreForComposeStore"
Condition=" '$(CrossGenDuringPublish)' == 'true' ">
<PropertyGroup>
<_SavedBaseIntermediateOutputPath>$(BaseIntermediateOutputPath)</_SavedBaseIntermediateOutputPath>
<_SavedProjectAssetsFile>$(ProjectAssetsFile)</_SavedProjectAssetsFile>
</PropertyGroup>
</Target>
<Target Name="_RestorePropsModifiedByPrepforRestoreForComposeStore"
AfterTargets="PrepforRestoreForComposeStore">
<PropertyGroup>
<BaseIntermediateOutputPath>$(_SavedBaseIntermediateOutputPath)</BaseIntermediateOutputPath>
<ProjectAssetsFile>$(_SavedProjectAssetsFile)</ProjectAssetsFile>
</PropertyGroup>
</Target>
<!-- Run crossgen on a single input assembly. -->
<Target Name="RunCrossGenForPublish"
Inputs="$(CrossGenInput);$(CrossGenPlatformAssemblies)"
Outputs="$(CrossGenOutput)">
<!-- The property CrossGenPlatformAssemblies must be
semicolon-delimited for incremental build to work correctly,
but the directory paths have to be passed with
platform-specific path separators in the crossgen command.
-->
<ItemGroup>
<_CrossGenPlatformAssemblies Include="$(CrossGenPlatformAssemblies)" />
<__CrossGenPlatformAssembliesPaths Include="@(_CrossGenPlatformAssemblies->'%(RootDir)%(Directory)')" />
<_CrossGenPlatformAssembliesPaths Include="@(__CrossGenPlatformAssembliesPaths->Distinct())" />
</ItemGroup>
<PropertyGroup>
<_PathSeparator>$([System.IO.Path]::PathSeparator)</_PathSeparator>
<_CrossGenPlatformAssembliesPaths>@(_CrossGenPlatformAssembliesPaths, '$(_PathSeparator)')</_CrossGenPlatformAssembliesPaths>
</PropertyGroup>
<PropertyGroup>
<CrossGenCommand>$(CrossGenExe) -readytorun -in $(CrossGenInput) -out $(CrossGenOutput) -platform_assemblies_paths $(_CrossGenPlatformAssembliesPaths)</CrossGenCommand>
</PropertyGroup>
<Message Text="$(CrossGenCommand)" />
<Exec Command="$(CrossGenCommand)" />
</Target>
<Target Name="_ComputeCrossGenInputs"
DependsOnTargets="_ComputeCrossGenPlatformAssemblies;_ComputeFilesToCrossGen" />
<!-- Compute the platform assembly paths, a parameter to crossgen
that lets it find dependencies of the input file. This needs to
include the path to the input file and its dependency closure,
including System.Private.CoreLib. -->
<Target Name="_ComputeCrossGenPlatformAssemblies"
DependsOnTargets="_ComputeManagedResolvedAssembliesForCrossGen">
<ItemGroup>
<_CrossGenPlatformAssemblies Include="@(_ManagedResolvedAssembliesForCrossGen)" />
<_CrossGenPlatformAssemblies Include="@(IntermediateAssembly)" />
</ItemGroup>
</Target>
<!-- _ManagedResolvedAssembliesForCrossGen includes the app's
managed dependency closure, including System.Private.CoreLib,
but not the app itself or resource assemblies. -->
<Target Name="_ComputeManagedResolvedAssembliesForCrossGen">
<ComputeManagedAssemblies Assemblies="@(ResolvedAssembliesToPublish)">
<Output TaskParameter="ManagedAssemblies" ItemName="_ManagedResolvedAssembliesForCrossGen" />
</ComputeManagedAssemblies>
<ItemGroup>
<_ManagedResolvedAssembliesForCrossGen Remove="@(_ManagedResolvedAssembliesForCrossGen->WithMetadataValue('AssetType', 'resources'))" />
</ItemGroup>
</Target>
<UsingTask TaskName="FilterByMetadata" AssemblyFile="$(LinkTaskDllPath)" />
<!-- This computes the default set of files that we want to be
crossgen'd. Some of these may already be crossgen images, and
these will not be crossgen'd again. The default is to crossgen
the app and platform libraries. Defaults will be used only if
FilesToCrossGen hasn't been set elsewhere, allowing users and
other props/targets to select what will be crossgen'd. -->
<Target Name="_ComputeDefaultFilesToCrossGen"
DependsOnTargets="_ComputeManagedResolvedAssembliesForCrossGen;_ComputePlatformLibraries"
Condition=" '@(FilesToCrossGen->Count())' == '0' ">
<FilterByMetadata Items="@(_ManagedResolvedAssembliesForCrossGen)"
MetadataName="Filename"
MetadataValues="@(PlatformLibraries->'%(Filename)')">
<Output TaskParameter="FilteredItems" ItemName="_PlatformLibrariesForCrossGen" />
</FilterByMetadata>
<ItemGroup>
<FilesToCrossGen Include="@(IntermediateAssembly)" />
<FilesToCrossGen Include="@(_PlatformLibrariesForCrossGen)" />
</ItemGroup>
</Target>
<UsingTask TaskName="ComputeCrossgenedAssemblies" AssemblyFile="$(LinkTaskDllPath)" />
<Target Name="_ComputeFilesToCrossGen"
DependsOnTargets="_ComputeDefaultFilesToCrossGen">
<ComputeCrossgenedAssemblies Assemblies="@(FilesToCrossGen)">
<Output TaskParameter="CrossgenedAssemblies" ItemName="_CrossgenedFiles" />
</ComputeCrossgenedAssemblies>
<!-- Don't try to run crossgen on assemblies that are already
crossgen'd. -->
<ItemGroup>
<FilesToCrossGen Remove="@(_CrossgenedFiles)" />
</ItemGroup>
<Message Text="files to crossgen: @(FilesToCrossGen)" />
</Target>
</Project>

View File

@@ -1,33 +0,0 @@
// 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.
using System;
using System.Globalization;
namespace Microsoft.NET.Build.Tasks
{
/// <summary>
/// Represents an error that is neither avoidable in all cases nor indicative of a bug in this library.
/// It will be logged as a plain build error without the exception type or stack.
/// </summary>
internal class BuildErrorException : Exception
{
public BuildErrorException()
{
}
public BuildErrorException(string message) : base(message)
{
}
public BuildErrorException(string message, Exception innerException) : base(message, innerException)
{
}
public BuildErrorException(string format, params string[] args)
: this(string.Format(CultureInfo.CurrentCulture, format, args))
{
}
}
}

Some files were not shown because too many files have changed in this diff Show More