Merge branch 'rel/1.0.0' into hostpfiles
This commit is contained in:
commit
c5320732c4
112 changed files with 2364 additions and 1329 deletions
|
@ -27,7 +27,7 @@ Installers
|
|||
|
||||
| |Ubuntu 14.04 |Windows |Mac OS X |CentOS 7.1 |
|
||||
|---------|:------:|:------:|:------:|:------:|
|
||||
|**Version**|||||
|
||||
|**Version**|||||
|
||||
|**Installers**|[Download Debian Package](https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-ubuntu-x64.latest.deb)|[Download Msi](https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-win-x64.latest.exe)|[Download Pkg](https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-osx-x64.latest.pkg) |N/A |
|
||||
|**Binaries**|[Download tar file](https://dotnetcli.blob.core.windows.net/dotnet/beta/Binaries/Latest/dotnet-ubuntu-x64.latest.tar.gz)|[Download zip file](https://dotnetcli.blob.core.windows.net/dotnet/beta/Binaries/Latest/dotnet-win-x64.latest.zip)|[Download tar file](https://dotnetcli.blob.core.windows.net/dotnet/beta/Binaries/Latest/dotnet-osx-x64.latest.tar.gz) |[Download tar file](https://dotnetcli.blob.core.windows.net/dotnet/beta/Binaries/Latest/dotnet-centos-x64.latest.tar.gz) |
|
||||
|
||||
|
|
3
TestAssets/TestProjects/BuildTestPortableProject/Lib.cs
Normal file
3
TestAssets/TestProjects/BuildTestPortableProject/Lib.cs
Normal file
|
@ -0,0 +1,3 @@
|
|||
public static class Thingy
|
||||
{
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"dependencies": {
|
||||
},
|
||||
"frameworks": {
|
||||
"netstandardapp1.5": {
|
||||
"imports": [
|
||||
"dnxcore50",
|
||||
"portable-net45+win8"
|
||||
],
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23901"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
public static class Thingy
|
||||
{
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"dependencies": { },
|
||||
"frameworks": {
|
||||
"netstandardapp1.5": {
|
||||
"imports": [
|
||||
"dnxcore50",
|
||||
"portable-net45+win8"
|
||||
],
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23901"
|
||||
}
|
||||
}
|
||||
},
|
||||
"runtimes": {
|
||||
"win7-x64": {},
|
||||
"win7-x86": {},
|
||||
"osx.10.10-x64": {},
|
||||
"osx.10.11-x64": {},
|
||||
"ubuntu.14.04-x64": {},
|
||||
"centos.7-x64": {},
|
||||
"rhel.7.2-x64": {},
|
||||
"debian.8.2-x64": {}
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@
|
|||
},
|
||||
|
||||
"debian_dependencies":{
|
||||
"libssl-dev" : {},
|
||||
"libssl1.0.0" : {},
|
||||
"clang-3.5" : {},
|
||||
"libcurl3" : {}
|
||||
},
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
},
|
||||
|
||||
"debian_dependencies":{
|
||||
"libssl-dev" : {},
|
||||
"libssl1.0.0" : {},
|
||||
"clang-3.5" : {},
|
||||
"libcurl3" : {}
|
||||
},
|
||||
|
|
|
@ -13,8 +13,10 @@ if ($versionSuffix -ne "") {
|
|||
$versionArg = "--version-suffix"
|
||||
}
|
||||
|
||||
. "$PSScriptRoot\..\..\scripts\common\_common.ps1"
|
||||
. "$REPOROOT\scripts\package\projectsToPack.ps1"
|
||||
$RepoRoot = Convert-Path "$PSScriptRoot\..\.."
|
||||
|
||||
. "$RepoRoot\scripts\common\_common.ps1"
|
||||
. "$RepoRoot\scripts\package\projectsToPack.ps1"
|
||||
|
||||
$IntermediatePackagesDir = "$RepoRoot\artifacts\packages\intermediate"
|
||||
$PackagesDir = "$RepoRoot\artifacts\packages"
|
||||
|
|
|
@ -12,26 +12,65 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
|
|||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source "$DIR/../../scripts/common/_common.sh"
|
||||
help(){
|
||||
echo "Usage: $0 [--version <pkg version>] [--input <input directory>] [--output <output pkg>] [--help]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --version <pkg version> Specify a version for the package. Version format is 4 '.' separated numbers - <major>.<minor>.<patch>.<revision>"
|
||||
echo " --input <input directory> Package the entire contents of the directory tree."
|
||||
echo " --output <output pkg> The path to where the package will be written."
|
||||
exit 1
|
||||
}
|
||||
|
||||
while [[ $# > 0 ]]; do
|
||||
lowerI="$(echo $1 | awk '{print tolower($0)}')"
|
||||
case $lowerI in
|
||||
-v|--version)
|
||||
DOTNET_CLI_VERSION=$2
|
||||
shift
|
||||
;;
|
||||
-o|--output)
|
||||
OUTPUT_PKG=$2
|
||||
shift
|
||||
;;
|
||||
-i|--input)
|
||||
INPUT_DIR=$2
|
||||
shift
|
||||
;;
|
||||
--help)
|
||||
help
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "$DOTNET_CLI_VERSION" ]; then
|
||||
echo "Provide a version number (DOTNET_CLI_VERSION) $DOTNET_CLI_VERSION" && exit 1
|
||||
echo "Provide a version number. Missing option '--version'" && help
|
||||
fi
|
||||
|
||||
STAGE2_DIR=$REPOROOT/artifacts/$RID/stage2
|
||||
if [ -z "$OUTPUT_PKG" ]; then
|
||||
echo "Provide an output pkg. Missing option '--output'" && help
|
||||
fi
|
||||
|
||||
if [ ! -d "$STAGE2_DIR" ]; then
|
||||
echo "Missing stage2 output in $STAGE2_DIR" 1>&2
|
||||
if [ -z "$INPUT_DIR" ]; then
|
||||
echo "Provide an input directory. Missing option '--input'" && help
|
||||
fi
|
||||
|
||||
if [ ! -d "$INPUT_DIR" ]; then
|
||||
echo "'$INPUT_DIR' - is either missing or not a directory" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PACKAGE_DIR=$REPOROOT/artifacts/packages/pkg
|
||||
PACKAGE_DIR=$(dirname "${OUTPUT_PKG}")
|
||||
[ -d "$PACKAGE_DIR" ] || mkdir -p $PACKAGE_DIR
|
||||
|
||||
PACKAGE_ID=dotnet-osx-x64.${DOTNET_CLI_VERSION}.pkg
|
||||
PACKAGE_NAME=$PACKAGE_DIR/$PACKAGE_ID
|
||||
#chmod -R 755 $STAGE2_DIR
|
||||
pkgbuild --root $STAGE2_DIR \
|
||||
PACKAGE_ID=$(basename "${OUTPUT_PKG}")
|
||||
|
||||
#chmod -R 755 $INPUT_DIR
|
||||
pkgbuild --root $INPUT_DIR \
|
||||
--version $DOTNET_CLI_VERSION \
|
||||
--scripts $DIR/scripts \
|
||||
--identifier com.microsoft.dotnet.cli.pkg.dotnet-osx-x64 \
|
||||
|
@ -40,10 +79,8 @@ pkgbuild --root $STAGE2_DIR \
|
|||
|
||||
cat $DIR/Distribution-Template | sed "/{VERSION}/s//$DOTNET_CLI_VERSION/g" > $DIR/Dist
|
||||
|
||||
productbuild --version $DOTNET_CLI_VERSION --identifier com.microsoft.dotnet.cli --package-path $DIR --resources $DIR/resources --distribution $DIR/Dist $PACKAGE_NAME
|
||||
productbuild --version $DOTNET_CLI_VERSION --identifier com.microsoft.dotnet.cli --package-path $DIR --resources $DIR/resources --distribution $DIR/Dist $OUTPUT_PKG
|
||||
|
||||
#Clean temp files
|
||||
rm $DIR/$PACKAGE_ID
|
||||
rm $DIR/Dist
|
||||
|
||||
$REPOROOT/scripts/publish/publish.sh $PACKAGE_NAME
|
||||
|
|
108
packaging/windows/generatebundle.ps1
Normal file
108
packaging/windows/generatebundle.ps1
Normal file
|
@ -0,0 +1,108 @@
|
|||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$DotnetMSIFile,
|
||||
[Parameter(Mandatory=$true)][string]$DotnetBundleOutput,
|
||||
[Parameter(Mandatory=$true)][string]$WixRoot,
|
||||
[Parameter(Mandatory=$true)][string]$DotnetMSIVersion,
|
||||
[Parameter(Mandatory=$true)][string]$DotnetCLIVersion,
|
||||
[Parameter(Mandatory=$true)][string]$Architecture,
|
||||
[Parameter(Mandatory=$true)][string]$ReleaseSuffix
|
||||
)
|
||||
|
||||
. "$PSScriptRoot\..\..\scripts\common\_common.ps1"
|
||||
$RepoRoot = Convert-Path "$PSScriptRoot\..\.."
|
||||
|
||||
function RunCandleForBundle
|
||||
{
|
||||
$result = $true
|
||||
pushd "$WixRoot"
|
||||
|
||||
Write-Host Running candle for bundle..
|
||||
$AuthWsxRoot = Join-Path $RepoRoot "packaging\windows"
|
||||
|
||||
.\candle.exe -nologo `
|
||||
-dDotnetSrc="$inputDir" `
|
||||
-dMicrosoftEula="$RepoRoot\packaging\osx\resources\en.lproj\eula.rtf" `
|
||||
-dBuildVersion="$DotnetMSIVersion" `
|
||||
-dDisplayVersion="$DotnetCLIVersion" `
|
||||
-dReleaseSuffix="$ReleaseSuffix" `
|
||||
-dMsiSourcePath="$DotnetMSIFile" `
|
||||
-arch "$Architecture" `
|
||||
-ext WixBalExtension.dll `
|
||||
-ext WixUtilExtension.dll `
|
||||
-ext WixTagExtension.dll `
|
||||
"$AuthWsxRoot\bundle.wxs" | Out-Host
|
||||
|
||||
if($LastExitCode -ne 0)
|
||||
{
|
||||
$result = $false
|
||||
Write-Host "Candle failed with exit code $LastExitCode."
|
||||
}
|
||||
|
||||
popd
|
||||
return $result
|
||||
}
|
||||
|
||||
function RunLightForBundle
|
||||
{
|
||||
$result = $true
|
||||
pushd "$WixRoot"
|
||||
|
||||
Write-Host Running light for bundle..
|
||||
$AuthWsxRoot = Join-Path $RepoRoot "packaging\windows"
|
||||
|
||||
.\light.exe -nologo `
|
||||
-cultures:en-us `
|
||||
bundle.wixobj `
|
||||
-ext WixBalExtension.dll `
|
||||
-ext WixUtilExtension.dll `
|
||||
-ext WixTagExtension.dll `
|
||||
-b "$AuthWsxRoot" `
|
||||
-out $DotnetBundleOutput | Out-Host
|
||||
|
||||
if($LastExitCode -ne 0)
|
||||
{
|
||||
$result = $false
|
||||
Write-Host "Light failed with exit code $LastExitCode."
|
||||
}
|
||||
|
||||
popd
|
||||
return $result
|
||||
}
|
||||
|
||||
|
||||
if(!(Test-Path $DotnetMSIFile))
|
||||
{
|
||||
throw "$DotnetMSIFile not found"
|
||||
}
|
||||
|
||||
Write-Host "Creating dotnet Bundle at $DotnetBundleOutput"
|
||||
|
||||
if([string]::IsNullOrEmpty($WixRoot))
|
||||
{
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(-Not (RunCandleForBundle))
|
||||
{
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(-Not (RunLightForBundle))
|
||||
{
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(!(Test-Path $DotnetBundleOutput))
|
||||
{
|
||||
throw "Unable to create the dotnet bundle."
|
||||
Exit -1
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Green "Successfully created dotnet bundle - $DotnetBundleOutput"
|
||||
|
||||
_ $RepoRoot\test\Installer\testmsi.ps1 @("$DotnetMSIFile")
|
||||
|
||||
exit $LastExitCode
|
|
@ -2,42 +2,21 @@
|
|||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$inputDir
|
||||
[Parameter(Mandatory=$true)][string]$inputDir,
|
||||
[Parameter(Mandatory=$true)][string]$DotnetMSIOutput,
|
||||
[Parameter(Mandatory=$true)][string]$WixRoot,
|
||||
[Parameter(Mandatory=$true)][string]$DotnetMSIVersion,
|
||||
[Parameter(Mandatory=$true)][string]$DotnetCLIVersion,
|
||||
[Parameter(Mandatory=$true)][string]$Architecture,
|
||||
[Parameter(Mandatory=$true)][string]$ReleaseSuffix
|
||||
)
|
||||
|
||||
. "$PSScriptRoot\..\..\scripts\common\_common.ps1"
|
||||
$RepoRoot = Convert-Path "$PSScriptRoot\..\.."
|
||||
|
||||
$DotnetMSIOutput = ""
|
||||
$DotnetBundleOutput = ""
|
||||
$WixRoot = ""
|
||||
$InstallFileswsx = "install-files.wxs"
|
||||
$InstallFilesWixobj = "install-files.wixobj"
|
||||
|
||||
function AcquireWixTools
|
||||
{
|
||||
$result = Join-Path $OutputDir WiXTools
|
||||
|
||||
if(Test-Path "$result\candle.exe")
|
||||
{
|
||||
return $result
|
||||
}
|
||||
|
||||
Write-Host Downloading Wixtools..
|
||||
New-Item $result -type directory -force | Out-Null
|
||||
# Download Wix version 3.10.2 - https://wix.codeplex.com/releases/view/619491
|
||||
Invoke-WebRequest -Uri https://wix.codeplex.com/downloads/get/1540241 -Method Get -OutFile $result\WixTools.zip
|
||||
|
||||
Write-Host Extracting Wixtools..
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory("$result\WixTools.zip", $result)
|
||||
|
||||
if($LastExitCode -ne 0)
|
||||
{
|
||||
throw "Unable to download and extract the WixTools."
|
||||
}
|
||||
|
||||
return $result
|
||||
}
|
||||
|
||||
function RunHeat
|
||||
{
|
||||
$result = $true
|
||||
|
@ -68,10 +47,10 @@ function RunCandle
|
|||
.\candle.exe -nologo `
|
||||
-dDotnetSrc="$inputDir" `
|
||||
-dMicrosoftEula="$RepoRoot\packaging\osx\resources\en.lproj\eula.rtf" `
|
||||
-dBuildVersion="$env:DOTNET_MSI_VERSION" `
|
||||
-dDisplayVersion="$env:DOTNET_CLI_VERSION" `
|
||||
-dReleaseSuffix="$env:ReleaseSuffix" `
|
||||
-arch "$env:ARCHITECTURE" `
|
||||
-dBuildVersion="$DotnetMSIVersion" `
|
||||
-dDisplayVersion="$DotnetCLIVersion" `
|
||||
-dReleaseSuffix="$ReleaseSuffix" `
|
||||
-arch "$Architecture" `
|
||||
-ext WixDependencyExtension.dll `
|
||||
"$AuthWsxRoot\dotnet.wxs" `
|
||||
"$AuthWsxRoot\provider.wxs" `
|
||||
|
@ -121,83 +100,12 @@ function RunLight
|
|||
return $result
|
||||
}
|
||||
|
||||
function RunCandleForBundle
|
||||
{
|
||||
$result = $true
|
||||
pushd "$WixRoot"
|
||||
|
||||
Write-Host Running candle for bundle..
|
||||
$AuthWsxRoot = Join-Path $RepoRoot "packaging\windows"
|
||||
|
||||
.\candle.exe -nologo `
|
||||
-dDotnetSrc="$inputDir" `
|
||||
-dMicrosoftEula="$RepoRoot\packaging\osx\resources\en.lproj\eula.rtf" `
|
||||
-dBuildVersion="$env:DOTNET_MSI_VERSION" `
|
||||
-dDisplayVersion="$env:DOTNET_CLI_VERSION" `
|
||||
-dReleaseSuffix="$env:ReleaseSuffix" `
|
||||
-dMsiSourcePath="$DotnetMSIOutput" `
|
||||
-arch "$env:ARCHITECTURE" `
|
||||
-ext WixBalExtension.dll `
|
||||
-ext WixUtilExtension.dll `
|
||||
-ext WixTagExtension.dll `
|
||||
"$AuthWsxRoot\bundle.wxs" | Out-Host
|
||||
|
||||
if($LastExitCode -ne 0)
|
||||
{
|
||||
$result = $false
|
||||
Write-Host "Candle failed with exit code $LastExitCode."
|
||||
}
|
||||
|
||||
popd
|
||||
return $result
|
||||
}
|
||||
|
||||
function RunLightForBundle
|
||||
{
|
||||
$result = $true
|
||||
pushd "$WixRoot"
|
||||
|
||||
Write-Host Running light for bundle..
|
||||
$AuthWsxRoot = Join-Path $RepoRoot "packaging\windows"
|
||||
|
||||
.\light.exe -nologo `
|
||||
-cultures:en-us `
|
||||
bundle.wixobj `
|
||||
-ext WixBalExtension.dll `
|
||||
-ext WixUtilExtension.dll `
|
||||
-ext WixTagExtension.dll `
|
||||
-b "$AuthWsxRoot" `
|
||||
-out $DotnetBundleOutput | Out-Host
|
||||
|
||||
if($LastExitCode -ne 0)
|
||||
{
|
||||
$result = $false
|
||||
Write-Host "Light failed with exit code $LastExitCode."
|
||||
}
|
||||
|
||||
popd
|
||||
return $result
|
||||
}
|
||||
|
||||
|
||||
if(!(Test-Path $inputDir))
|
||||
{
|
||||
throw "$inputDir not found"
|
||||
}
|
||||
|
||||
if(!(Test-Path $PackageDir))
|
||||
{
|
||||
mkdir $PackageDir | Out-Null
|
||||
}
|
||||
|
||||
$DotnetMSIOutput = Join-Path $PackageDir "dotnet-win-$env:ARCHITECTURE.$env:DOTNET_CLI_VERSION.msi"
|
||||
$DotnetBundleOutput = Join-Path $PackageDir "dotnet-win-$env:ARCHITECTURE.$env:DOTNET_CLI_VERSION.exe"
|
||||
|
||||
Write-Host "Creating dotnet MSI at $DotnetMSIOutput"
|
||||
Write-Host "Creating dotnet Bundle at $DotnetBundleOutput"
|
||||
|
||||
$WixRoot = AcquireWixTools
|
||||
|
||||
|
||||
if([string]::IsNullOrEmpty($WixRoot))
|
||||
{
|
||||
|
@ -214,39 +122,17 @@ if(-Not (RunCandle))
|
|||
Exit -1
|
||||
}
|
||||
|
||||
if(-Not (RunCandleForBundle))
|
||||
{
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(-Not (RunLight))
|
||||
{
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(-Not (RunLightForBundle))
|
||||
{
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(!(Test-Path $DotnetMSIOutput))
|
||||
{
|
||||
throw "Unable to create the dotnet msi."
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(!(Test-Path $DotnetBundleOutput))
|
||||
{
|
||||
throw "Unable to create the dotnet bundle."
|
||||
Exit -1
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Green "Successfully created dotnet MSI - $DotnetMSIOutput"
|
||||
Write-Host -ForegroundColor Green "Successfully created dotnet bundle - $DotnetBundleOutput"
|
||||
|
||||
_ $RepoRoot\test\Installer\testmsi.ps1 @("$DotnetMSIOutput")
|
||||
|
||||
$PublishScript = Join-Path $PSScriptRoot "..\..\scripts\publish\publish.ps1"
|
||||
& $PublishScript -file $DotnetBundleOutput
|
||||
|
||||
exit $LastExitCode
|
||||
|
|
|
@ -48,6 +48,65 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
}
|
||||
}
|
||||
|
||||
public static bool IsRHEL
|
||||
{
|
||||
get
|
||||
{
|
||||
var osname = PlatformServices.Default.Runtime.OperatingSystem;
|
||||
return string.Equals(osname, "rhel", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsUnix
|
||||
{
|
||||
get
|
||||
{
|
||||
return IsLinux || IsOSX;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsDebian
|
||||
{
|
||||
get
|
||||
{
|
||||
var osname = PlatformServices.Default.Runtime.OperatingSystem;
|
||||
return string.Equals(osname, "debian", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsLinux
|
||||
{
|
||||
get
|
||||
{
|
||||
return IsUbuntu || IsCentOS || IsRHEL || IsDebian;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsPlatform(BuildPlatform platform)
|
||||
{
|
||||
switch (platform)
|
||||
{
|
||||
case BuildPlatform.Windows:
|
||||
return IsWindows;
|
||||
case BuildPlatform.Ubuntu:
|
||||
return IsUbuntu;
|
||||
case BuildPlatform.OSX:
|
||||
return IsOSX;
|
||||
case BuildPlatform.CentOS:
|
||||
return IsCentOS;
|
||||
case BuildPlatform.RHEL:
|
||||
return IsRHEL;
|
||||
case BuildPlatform.Debian:
|
||||
return IsDebian;
|
||||
case BuildPlatform.Unix:
|
||||
return IsUnix;
|
||||
case BuildPlatform.Linux:
|
||||
return IsLinux;
|
||||
default:
|
||||
throw new Exception("Unrecognized Platform.");
|
||||
}
|
||||
}
|
||||
|
||||
private static BuildPlatform DetermineCurrentPlatform()
|
||||
{
|
||||
if (IsWindows)
|
||||
|
@ -66,10 +125,18 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
{
|
||||
return BuildPlatform.CentOS;
|
||||
}
|
||||
else if (IsRHEL)
|
||||
{
|
||||
return BuildPlatform.RHEL;
|
||||
}
|
||||
else if (IsDebian)
|
||||
{
|
||||
return BuildPlatform.Debian;
|
||||
}
|
||||
else
|
||||
{
|
||||
return default(BuildPlatform);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,12 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
public enum BuildPlatform
|
||||
{
|
||||
Windows = 1,
|
||||
OSX = 2,
|
||||
Ubuntu = 3,
|
||||
CentOS = 4
|
||||
Unix = 2,
|
||||
Linux = 3,
|
||||
OSX = 4,
|
||||
Ubuntu = 5,
|
||||
CentOS = 6,
|
||||
RHEL = 7,
|
||||
Debian = 8
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,10 +11,11 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
{
|
||||
return self.UseTargets(new[]
|
||||
{
|
||||
new BuildTarget("Default", "Standard Goals", new [] { "Prepare", "Compile", "Test", "Publish" }),
|
||||
new BuildTarget("Default", "Standard Goals", new [] { "Prepare", "Compile", "Test", "Package", "Publish" }),
|
||||
new BuildTarget("Prepare", "Standard Goals"),
|
||||
new BuildTarget("Compile", "Standard Goals"),
|
||||
new BuildTarget("Test", "Standard Goals"),
|
||||
new BuildTarget("Package", "Standard Goals"),
|
||||
new BuildTarget("Publish", "Standard Goals")
|
||||
});
|
||||
}
|
||||
|
|
|
@ -20,16 +20,9 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
|
||||
public override bool EvaluateCondition()
|
||||
{
|
||||
var currentPlatform = CurrentPlatform.Current;
|
||||
|
||||
if (currentPlatform == default(BuildPlatform))
|
||||
{
|
||||
throw new Exception("Unrecognized Platform.");
|
||||
}
|
||||
|
||||
foreach (var platform in _buildPlatforms)
|
||||
{
|
||||
if (platform == currentPlatform)
|
||||
if (CurrentPlatform.IsPlatform(platform))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build.Framework
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
|
||||
public class EnvironmentAttribute : TargetConditionAttribute
|
||||
{
|
||||
private string _envVar;
|
||||
private string[] _expectedVals;
|
||||
|
||||
public EnvironmentAttribute(string envVar, params string[] expectedVals)
|
||||
{
|
||||
if (string.IsNullOrEmpty(envVar))
|
||||
{
|
||||
throw new ArgumentNullException("envVar");
|
||||
}
|
||||
|
||||
_envVar = envVar;
|
||||
_expectedVals = expectedVals;
|
||||
}
|
||||
|
||||
public override bool EvaluateCondition()
|
||||
{
|
||||
var actualVal = Environment.GetEnvironmentVariable(_envVar);
|
||||
|
||||
foreach (var expectedVal in _expectedVals)
|
||||
{
|
||||
if (string.Equals(actualVal, expectedVal, StringComparison.Ordinal))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,11 +6,16 @@
|
|||
$oldPath = $env:PATH
|
||||
try {
|
||||
# Put the stage2 output on the front of the path
|
||||
$stage2 = "$PSScriptRoot\..\artifacts\win7-x64\stage2\bin"
|
||||
if(!(Get-Command dotnet -ErrorAction SilentlyContinue)) {
|
||||
throw "You need to have a version of 'dotnet' on your path so we can determine the RID"
|
||||
}
|
||||
|
||||
$rid = dotnet --version | where { $_ -match "^ Runtime Id:\s*(.*)$" } | foreach { $matches[1] }
|
||||
$stage2 = "$PSScriptRoot\..\artifacts\$rid\stage2\bin"
|
||||
if (Test-Path $stage2) {
|
||||
$env:PATH="$stage2;$env:PATH"
|
||||
} else {
|
||||
Write-Host "You don't have a dev build in the 'artifacts\win7-x64\stage2' folder!"
|
||||
Write-Host "You don't have a dev build in the 'artifacts\$rid\stage2' folder!"
|
||||
}
|
||||
|
||||
dotnet @args
|
||||
|
|
|
@ -18,18 +18,23 @@ RUN yum -q -y install unzip libunwind gettext libcurl-devel openssl-devel zlib l
|
|||
# apt-get -qqy install unzip curl libicu-dev libunwind8 gettext libssl-dev libcurl3-gnutls zlib1g liblttng-ust-dev lldb-3.6-dev lldb-3.6
|
||||
|
||||
# Install Build Prereqs
|
||||
RUN yum -q -y install tar git cmake clang make
|
||||
# CMake 3.3.2 from GhettoForge; LLVM 3.6.2 built from source ourselves;
|
||||
RUN yum install -y http://mirror.symnds.com/distributions/gf/el/7/plus/x86_64/cmake-3.3.2-1.gf.el7.x86_64.rpm \
|
||||
https://matell.blob.core.windows.net/rpms/clang-3.6.2-1.el7.centos.x86_64.rpm \
|
||||
https://matell.blob.core.windows.net/rpms/clang-libs-3.6.2-1.el7.centos.x86_64.rpm \
|
||||
https://matell.blob.core.windows.net/rpms/lldb-3.6.2-1.el7.centos.x86_64.rpm \
|
||||
https://matell.blob.core.windows.net/rpms/lldb-devel-3.6.2-1.el7.centos.x86_64.rpm \
|
||||
https://matell.blob.core.windows.net/rpms/llvm-3.6.2-1.el7.centos.x86_64.rpm \
|
||||
https://matell.blob.core.windows.net/rpms/llvm-libs-3.6.2-1.el7.centos.x86_64.rpm \
|
||||
which \
|
||||
make
|
||||
|
||||
RUN yum -q -y install tar git
|
||||
|
||||
# Use clang as c++ compiler
|
||||
RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
|
||||
RUN update-alternatives --set c++ /usr/bin/clang++
|
||||
|
||||
# Install azure cli. We need this to publish artifacts.
|
||||
RUN yum -y install nodejs && \
|
||||
yum -y install npm && \
|
||||
npm install -g azure-cli
|
||||
|
||||
|
||||
RUN yum -q -y install sudo
|
||||
|
||||
# Setup User to match Host User, and give superuser permissions
|
||||
|
|
|
@ -55,6 +55,7 @@ RUN echo "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.6 main" | tee
|
|||
libsasl2-2 \
|
||||
libsqlite3-0 \
|
||||
libssl1.0.0 \
|
||||
libssl-dev \
|
||||
libtasn1-6 \
|
||||
libwind0-heimdal
|
||||
|
||||
|
@ -69,11 +70,6 @@ RUN apt-get -qq install -y debhelper build-essential devscripts git cmake
|
|||
RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-3.5 100
|
||||
RUN update-alternatives --set c++ /usr/bin/clang++-3.5
|
||||
|
||||
# Install azure cli. We need this to publish artifacts.
|
||||
RUN apt-get -qqy install nodejs-legacy && \
|
||||
apt-get -qqy install npm && \
|
||||
npm install -g azure-cli
|
||||
|
||||
# Setup User to match Host User, and give superuser permissions
|
||||
ARG USER_ID=0
|
||||
RUN useradd -m code_executor -u ${USER_ID} -g sudo
|
||||
|
|
|
@ -94,9 +94,6 @@ echo "Using code from: $DOCKER_HOST_SHARE_DIR"
|
|||
docker run $INTERACTIVE -t --rm --sig-proxy=true \
|
||||
--name $DOTNET_BUILD_CONTAINER_NAME \
|
||||
-v $DOCKER_HOST_SHARE_DIR:/opt/code \
|
||||
-e SASTOKEN \
|
||||
-e STORAGE_ACCOUNT \
|
||||
-e STORAGE_CONTAINER \
|
||||
-e CHANNEL \
|
||||
-e CONNECTION_STRING \
|
||||
-e REPO_ID \
|
||||
|
@ -104,5 +101,6 @@ docker run $INTERACTIVE -t --rm --sig-proxy=true \
|
|||
-e REPO_PASS \
|
||||
-e REPO_SERVER \
|
||||
-e DOTNET_BUILD_SKIP_CROSSGEN \
|
||||
-e PUBLISH_TO_AZURE_BLOB \
|
||||
$DOTNET_BUILD_CONTAINER_TAG \
|
||||
$BUILD_COMMAND "$@"
|
||||
|
|
|
@ -45,6 +45,13 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
"Microsoft.Extensions.Testing.Abstractions"
|
||||
};
|
||||
|
||||
// Updates the stage 2 with recent changes.
|
||||
[Target(nameof(PrepareTargets.Init), nameof(CompileStage2))]
|
||||
public static BuildTargetResult UpdateBuild(BuildTargetContext c)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PrepareTargets.Init), nameof(CompileCoreHost), nameof(CompileStage1), nameof(CompileStage2))]
|
||||
public static BuildTargetResult Compile(BuildTargetContext c)
|
||||
{
|
||||
|
@ -238,9 +245,9 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
// Find toolchain package
|
||||
string packageId;
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
if (CurrentPlatform.IsWindows)
|
||||
{
|
||||
if (IsWinx86)
|
||||
if (CurrentArchitecture.Isx86)
|
||||
{
|
||||
// https://github.com/dotnet/cli/issues/1550
|
||||
c.Warn("Native compilation is not yet working on Windows x86");
|
||||
|
@ -249,24 +256,16 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
packageId = "toolchain.win7-x64.Microsoft.DotNet.AppDep";
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
else if (CurrentPlatform.IsUbuntu)
|
||||
{
|
||||
var osname = PlatformServices.Default.Runtime.OperatingSystem;
|
||||
if (string.Equals(osname, "ubuntu", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
packageId = "toolchain.ubuntu.14.04-x64.Microsoft.DotNet.AppDep";
|
||||
}
|
||||
else if (string.Equals(osname, "centos", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
c.Warn("Native compilation is not yet working on CentOS");
|
||||
return c.Success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return c.Failed($"Unknown Linux Distro: {osname}");
|
||||
}
|
||||
packageId = "toolchain.ubuntu.14.04-x64.Microsoft.DotNet.AppDep";
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
else if (CurrentPlatform.IsCentOS || CurrentPlatform.IsRHEL || CurrentPlatform.IsDebian)
|
||||
{
|
||||
c.Warn($"Native compilation is not yet working on {CurrentPlatform.Current}");
|
||||
return c.Success();
|
||||
}
|
||||
else if (CurrentPlatform.IsOSX)
|
||||
{
|
||||
packageId = "toolchain.osx.10.10-x64.Microsoft.DotNet.AppDep";
|
||||
}
|
||||
|
@ -296,28 +295,24 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
// Find crossgen
|
||||
string arch = PlatformServices.Default.Runtime.RuntimeArchitecture;
|
||||
string packageId;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
if (CurrentPlatform.IsWindows)
|
||||
{
|
||||
packageId = $"runtime.win7-{arch}.Microsoft.NETCore.Runtime.CoreCLR";
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
else if (CurrentPlatform.IsUbuntu)
|
||||
{
|
||||
var osname = PlatformServices.Default.Runtime.OperatingSystem;
|
||||
if (string.Equals(osname, "ubuntu", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
packageId = "runtime.ubuntu.14.04-x64.Microsoft.NETCore.Runtime.CoreCLR";
|
||||
}
|
||||
else if (string.Equals(osname, "centos", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// CentOS runtime is in the runtime.rhel.7-x64... package.
|
||||
packageId = "runtime.rhel.7-x64.Microsoft.NETCore.Runtime.CoreCLR";
|
||||
}
|
||||
else
|
||||
{
|
||||
return c.Failed($"Unknown Linux Distro: {osname}");
|
||||
}
|
||||
packageId = "runtime.ubuntu.14.04-x64.Microsoft.NETCore.Runtime.CoreCLR";
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
else if (CurrentPlatform.IsCentOS || CurrentPlatform.IsRHEL)
|
||||
{
|
||||
// CentOS runtime is in the runtime.rhel.7-x64... package.
|
||||
packageId = "runtime.rhel.7-x64.Microsoft.NETCore.Runtime.CoreCLR";
|
||||
}
|
||||
else if (CurrentPlatform.IsDebian)
|
||||
{
|
||||
packageId = "runtime.debian.8.2-x64.Microsoft.NETCore.Runtime.CoreCLR";
|
||||
}
|
||||
else if (CurrentPlatform.IsOSX)
|
||||
{
|
||||
packageId = "runtime.osx.10.10-x64.Microsoft.NETCore.Runtime.CoreCLR";
|
||||
}
|
||||
|
|
57
scripts/dotnet-cli-build/InstallerTargets.cs
Normal file
57
scripts/dotnet-cli-build/InstallerTargets.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class InstallerTargets
|
||||
{
|
||||
[Target(nameof(MsiTargets.GenerateMsis),
|
||||
nameof(MsiTargets.GenerateBundle),
|
||||
nameof(InstallerTargets.GeneratePkg),
|
||||
nameof(InstallerTargets.GenerateDeb))]
|
||||
public static BuildTargetResult GenerateInstaller(BuildTargetContext c)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.OSX)]
|
||||
public static BuildTargetResult GeneratePkg(BuildTargetContext c)
|
||||
{
|
||||
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
||||
var pkg = c.BuildContext.Get<string>("InstallerFile");
|
||||
Cmd(Path.Combine(Dirs.RepoRoot, "packaging", "osx", "package-osx.sh"),
|
||||
"-v", version, "-i", Dirs.Stage2, "-o", pkg)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
||||
public static BuildTargetResult GenerateDeb(BuildTargetContext c)
|
||||
{
|
||||
var channel = c.BuildContext.Get<string>("Channel").ToLower();
|
||||
var packageName = Monikers.GetDebianPackageName(c);
|
||||
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
||||
var debFile = c.BuildContext.Get<string>("InstallerFile");
|
||||
var manPagesDir = Path.Combine(Dirs.RepoRoot, "Documentation", "manpages");
|
||||
var previousVersionURL = $"https://dotnetcli.blob.core.windows.net/dotnet/{channel}/Installers/Latest/dotnet-ubuntu-x64.latest.deb";
|
||||
|
||||
Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "package", "package-debian.sh"),
|
||||
"-v", version, "-i", Dirs.Stage2, "-o", debFile, "-p", packageName, "-m", manPagesDir, "--previous-version-url", previousVersionURL)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
}
|
||||
}
|
146
scripts/dotnet-cli-build/MsiTargets.cs
Normal file
146
scripts/dotnet-cli-build/MsiTargets.cs
Normal file
|
@ -0,0 +1,146 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class MsiTargets
|
||||
{
|
||||
private const string ENGINE = "engine.exe";
|
||||
|
||||
private static string WixRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(Dirs.Output, "WixTools");
|
||||
}
|
||||
}
|
||||
|
||||
private static string Msi { get; set; }
|
||||
|
||||
private static string Bundle { get; set; }
|
||||
|
||||
private static string Engine { get; set; }
|
||||
|
||||
private static string MsiVersion { get; set; }
|
||||
|
||||
private static string CliVersion { get; set; }
|
||||
|
||||
private static string Arch { get; } = CurrentArchitecture.Current.ToString();
|
||||
|
||||
private static string Channel { get; set; }
|
||||
|
||||
private static void AcquireWix(BuildTargetContext c)
|
||||
{
|
||||
if (File.Exists(Path.Combine(WixRoot, "candle.exe")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(WixRoot);
|
||||
|
||||
c.Info("Downloading WixTools..");
|
||||
// Download Wix version 3.10.2 - https://wix.codeplex.com/releases/view/619491
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
$"Invoke-WebRequest -Uri https://wix.codeplex.com/downloads/get/1540241 -Method Get -OutFile {WixRoot}\\WixTools.zip")
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
|
||||
c.Info("Extracting WixTools..");
|
||||
ZipFile.ExtractToDirectory($"{WixRoot}\\WixTools.zip", WixRoot);
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult InitMsi(BuildTargetContext c)
|
||||
{
|
||||
Bundle = c.BuildContext.Get<string>("InstallerFile");
|
||||
Msi = Path.ChangeExtension(Bundle, "msi");
|
||||
Engine = Path.Combine(Path.GetDirectoryName(Bundle), ENGINE);
|
||||
|
||||
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
||||
MsiVersion = buildVersion.GenerateMsiVersion();
|
||||
CliVersion = buildVersion.SimpleVersion;
|
||||
Channel = c.BuildContext.Get<string>("Channel");
|
||||
|
||||
AcquireWix(c);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(MsiTargets.InitMsi),
|
||||
nameof(GenerateDotnetMuxerMsi),
|
||||
nameof(GenerateDotnetSharedFxMsi),
|
||||
nameof(GenerateCLISDKMsi))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateMsis(BuildTargetContext c)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateCLISDKMsi(BuildTargetContext c)
|
||||
{
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "generatemsi.ps1"),
|
||||
Dirs.Stage2, Msi, WixRoot, MsiVersion, CliVersion, Arch, Channel)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateDotnetMuxerMsi(BuildTargetContext c)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateDotnetSharedFxMsi(BuildTargetContext c)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
|
||||
[Target(nameof(MsiTargets.InitMsi))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateBundle(BuildTargetContext c)
|
||||
{
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "generatebundle.ps1"),
|
||||
Msi, Bundle, WixRoot, MsiVersion, CliVersion, Arch, Channel)
|
||||
.EnvironmentVariable("Stage2Dir", Dirs.Stage2)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(MsiTargets.InitMsi))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult ExtractEngineFromBundle(BuildTargetContext c)
|
||||
{
|
||||
Cmd($"{WixRoot}\\insignia.exe", "-ib", Bundle, "-o", Engine)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(MsiTargets.InitMsi))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult ReattachEngineToBundle(BuildTargetContext c)
|
||||
{
|
||||
Cmd($"{WixRoot}\\insignia.exe", "-ab", Engine, Bundle, "-o", Bundle)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
}
|
||||
}
|
138
scripts/dotnet-cli-build/PackageTargets.cs
Normal file
138
scripts/dotnet-cli-build/PackageTargets.cs
Normal file
|
@ -0,0 +1,138 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public static class PackageTargets
|
||||
{
|
||||
[Target]
|
||||
public static BuildTargetResult InitPackage(BuildTargetContext c)
|
||||
{
|
||||
Directory.CreateDirectory(Dirs.Packages);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PrepareTargets.Init),
|
||||
nameof(PackageTargets.InitPackage),
|
||||
nameof(PackageTargets.GenerateVersionBadge),
|
||||
nameof(PackageTargets.GenerateCompressedFile),
|
||||
nameof(InstallerTargets.GenerateInstaller),
|
||||
nameof(PackageTargets.GenerateNugetPackages))]
|
||||
[Environment("DOTNET_BUILD_SKIP_PACKAGING", null, "0", "false")]
|
||||
public static BuildTargetResult Package(BuildTargetContext c)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult GenerateVersionBadge(BuildTargetContext c)
|
||||
{
|
||||
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
||||
var versionSvg = Path.Combine(Dirs.RepoRoot, "resources", "images", "version_badge.svg");
|
||||
var outputVersionSvg = c.BuildContext.Get<string>("VersionBadge");
|
||||
|
||||
var versionSvgContent = File.ReadAllText(versionSvg);
|
||||
versionSvgContent = versionSvgContent.Replace("ver_number", buildVersion.SimpleVersion);
|
||||
File.WriteAllText(outputVersionSvg, versionSvgContent);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PackageTargets.GenerateZip), nameof(PackageTargets.GenerateTarBall))]
|
||||
public static BuildTargetResult GenerateCompressedFile(BuildTargetContext c)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PackageTargets.InitPackage))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateZip(BuildTargetContext c)
|
||||
{
|
||||
var zipFile = c.BuildContext.Get<string>("CompressedFile");
|
||||
|
||||
if (File.Exists(zipFile))
|
||||
{
|
||||
File.Delete(zipFile);
|
||||
}
|
||||
|
||||
ZipFile.CreateFromDirectory(Dirs.Stage2, zipFile, CompressionLevel.Optimal, false);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PackageTargets.InitPackage))]
|
||||
[BuildPlatforms(BuildPlatform.Unix)]
|
||||
public static BuildTargetResult GenerateTarBall(BuildTargetContext c)
|
||||
{
|
||||
var tarFile = c.BuildContext.Get<string>("CompressedFile");
|
||||
|
||||
if (File.Exists(tarFile))
|
||||
{
|
||||
File.Delete(tarFile);
|
||||
}
|
||||
|
||||
Cmd("tar", "-czf", tarFile, "-C", Dirs.Stage2, ".")
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateNugetPackages(BuildTargetContext c)
|
||||
{
|
||||
var versionSuffix = c.BuildContext.Get<BuildVersion>("BuildVersion").VersionSuffix;
|
||||
var env = GetCommonEnvVars(c);
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
Path.Combine(Dirs.RepoRoot, "packaging", "nuget", "package.ps1"), Path.Combine(Dirs.Stage2, "bin"), versionSuffix)
|
||||
.Environment(env)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
internal static Dictionary<string, string> GetCommonEnvVars(BuildTargetContext c)
|
||||
{
|
||||
// Set up the environment variables previously defined by common.sh/ps1
|
||||
// This is overkill, but I want to cover all the variables used in all OSes (including where some have the same names)
|
||||
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
||||
var configuration = c.BuildContext.Get<string>("Configuration");
|
||||
var architecture = PlatformServices.Default.Runtime.RuntimeArchitecture;
|
||||
var env = new Dictionary<string, string>()
|
||||
{
|
||||
{ "RID", PlatformServices.Default.Runtime.GetRuntimeIdentifier() },
|
||||
{ "OSNAME", PlatformServices.Default.Runtime.OperatingSystem },
|
||||
{ "TFM", "dnxcore50" },
|
||||
{ "REPOROOT", Dirs.RepoRoot },
|
||||
{ "OutputDir", Dirs.Output },
|
||||
{ "Stage1Dir", Dirs.Stage1 },
|
||||
{ "Stage1CompilationDir", Dirs.Stage1Compilation },
|
||||
{ "Stage2Dir", Dirs.Stage2 },
|
||||
{ "STAGE2_DIR", Dirs.Stage2 },
|
||||
{ "Stage2CompilationDir", Dirs.Stage2Compilation },
|
||||
{ "HostDir", Dirs.Corehost },
|
||||
{ "PackageDir", Path.Combine(Dirs.Packages) }, // Legacy name
|
||||
{ "TestBinRoot", Dirs.TestOutput },
|
||||
{ "TestPackageDir", Dirs.TestPackages },
|
||||
{ "MajorVersion", buildVersion.Major.ToString() },
|
||||
{ "MinorVersion", buildVersion.Minor.ToString() },
|
||||
{ "PatchVersion", buildVersion.Patch.ToString() },
|
||||
{ "CommitCountVersion", buildVersion.CommitCountString },
|
||||
{ "COMMIT_COUNT_VERSION", buildVersion.CommitCountString },
|
||||
{ "DOTNET_CLI_VERSION", buildVersion.SimpleVersion },
|
||||
{ "DOTNET_MSI_VERSION", buildVersion.GenerateMsiVersion() },
|
||||
{ "VersionSuffix", buildVersion.VersionSuffix },
|
||||
{ "CONFIGURATION", configuration },
|
||||
{ "ARCHITECTURE", architecture }
|
||||
};
|
||||
|
||||
return env;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,17 +21,17 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
[Target(nameof(CheckPrereqCmakePresent), nameof(CheckPlatformDependencies))]
|
||||
public static BuildTargetResult CheckPrereqs(BuildTargetContext c) => c.Success();
|
||||
|
||||
[Target(nameof(CheckCoreclrPlatformDependencies), nameof(CheckInstallerBuildPlatformDependencies))]
|
||||
[Target(nameof(CheckCoreclrPlatformDependencies), nameof(CheckInstallerBuildPlatformDependencies))]
|
||||
public static BuildTargetResult CheckPlatformDependencies(BuildTargetContext c) => c.Success();
|
||||
|
||||
[Target(nameof(CheckUbuntuCoreclrAndCoreFxDependencies), nameof(CheckCentOSCoreclrAndCoreFxDependencies))]
|
||||
[Target(nameof(CheckUbuntuCoreclrAndCoreFxDependencies), nameof(CheckCentOSCoreclrAndCoreFxDependencies))]
|
||||
public static BuildTargetResult CheckCoreclrPlatformDependencies(BuildTargetContext c) => c.Success();
|
||||
|
||||
[Target(nameof(CheckUbuntuDebianPackageBuildDependencies))]
|
||||
public static BuildTargetResult CheckInstallerBuildPlatformDependencies(BuildTargetContext c) => c.Success();
|
||||
|
||||
// All major targets will depend on this in order to ensure variables are set up right if they are run independently
|
||||
[Target(nameof(GenerateVersions), nameof(CheckPrereqs), nameof(LocateStage0))]
|
||||
[Target(nameof(GenerateVersions), nameof(CheckPrereqs), nameof(LocateStage0), nameof(ExpectedBuildArtifacts))]
|
||||
public static BuildTargetResult Init(BuildTargetContext c)
|
||||
{
|
||||
var runtimeInfo = PlatformServices.Default.Runtime;
|
||||
|
@ -44,6 +44,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
}
|
||||
|
||||
c.BuildContext["Configuration"] = configEnv;
|
||||
c.BuildContext["Channel"] = Environment.GetEnvironmentVariable("CHANNEL");
|
||||
|
||||
c.Info($"Building {c.BuildContext["Configuration"]} to: {Dirs.Output}");
|
||||
c.Info("Build Environment:");
|
||||
|
@ -104,6 +105,41 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult ExpectedBuildArtifacts(BuildTargetContext c)
|
||||
{
|
||||
var productName = Monikers.GetProductMoniker(c);
|
||||
var config = Environment.GetEnvironmentVariable("CONFIGURATION");
|
||||
var versionBadgeName = $"{CurrentPlatform.Current}_{CurrentArchitecture.Current}_{config}_version_badge.svg";
|
||||
c.BuildContext["VersionBadge"] = Path.Combine(Dirs.Output, versionBadgeName);
|
||||
|
||||
var extension = CurrentPlatform.IsWindows ? ".zip" : ".tar.gz";
|
||||
c.BuildContext["CompressedFile"] = Path.Combine(Dirs.Packages, productName + extension);
|
||||
|
||||
string installer = "";
|
||||
switch (CurrentPlatform.Current)
|
||||
{
|
||||
case BuildPlatform.Windows:
|
||||
installer = productName + ".exe";
|
||||
break;
|
||||
case BuildPlatform.OSX:
|
||||
installer = productName + ".pkg";
|
||||
break;
|
||||
case BuildPlatform.Ubuntu:
|
||||
installer = productName + ".deb";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(installer))
|
||||
{
|
||||
c.BuildContext["InstallerFile"] = Path.Combine(Dirs.Packages, installer);
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult CheckPackageCache(BuildTargetContext c)
|
||||
{
|
||||
|
@ -244,7 +280,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
public static BuildTargetResult CheckCentOSCoreclrAndCoreFxDependencies(BuildTargetContext c)
|
||||
{
|
||||
var errorMessageBuilder = new StringBuilder();
|
||||
|
||||
|
||||
foreach (var package in PackageDependencies.CentosCoreclrAndCoreFxDependencies)
|
||||
{
|
||||
if (!YumDependencyUtility.PackageIsInstalled(package))
|
||||
|
|
|
@ -4,6 +4,10 @@ using System.IO;
|
|||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Microsoft.WindowsAzure;
|
||||
using Microsoft.WindowsAzure.Storage;
|
||||
using Microsoft.WindowsAzure.Storage.Auth;
|
||||
using Microsoft.WindowsAzure.Storage.Blob;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
|
@ -11,71 +15,153 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
public static class PublishTargets
|
||||
{
|
||||
[Target(nameof(PrepareTargets.Init))]
|
||||
private static CloudBlobContainer BlobContainer { get; set; }
|
||||
|
||||
private static string Channel { get; set; }
|
||||
|
||||
private static string Version { get; set; }
|
||||
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult InitPublish(BuildTargetContext c)
|
||||
{
|
||||
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Environment.GetEnvironmentVariable("CONNECTION_STRING").Trim('"'));
|
||||
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
|
||||
BlobContainer = blobClient.GetContainerReference("dotnet");
|
||||
|
||||
Version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
||||
Channel = c.BuildContext.Get<string>("Channel");
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PrepareTargets.Init),
|
||||
nameof(PublishTargets.InitPublish),
|
||||
nameof(PublishTargets.PublishArtifacts))]
|
||||
[Environment("PUBLISH_TO_AZURE_BLOB", "1", "true")] // This is set by CI systems
|
||||
public static BuildTargetResult Publish(BuildTargetContext c)
|
||||
{
|
||||
if (string.Equals(Environment.GetEnvironmentVariable("DOTNET_BUILD_SKIP_PACKAGING"), "1", StringComparison.Ordinal))
|
||||
{
|
||||
c.Info("Skipping packaging because DOTNET_BUILD_SKIP_PACKAGING is set");
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
// NOTE(anurse): Currently, this just invokes the remaining build scripts as-is. We should port those to C# as well, but
|
||||
// I want to get the merged in.
|
||||
|
||||
// Set up the environment variables previously defined by common.sh/ps1
|
||||
// This is overkill, but I want to cover all the variables used in all OSes (including where some have the same names)
|
||||
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
||||
var configuration = c.BuildContext.Get<string>("Configuration");
|
||||
var architecture = PlatformServices.Default.Runtime.RuntimeArchitecture;
|
||||
var env = new Dictionary<string, string>()
|
||||
{
|
||||
{ "RID", PlatformServices.Default.Runtime.GetRuntimeIdentifier() },
|
||||
{ "OSNAME", PlatformServices.Default.Runtime.OperatingSystem },
|
||||
{ "TFM", "netstandardapp1.5" },
|
||||
{ "OutputDir", Dirs.Output },
|
||||
{ "Stage1Dir", Dirs.Stage1 },
|
||||
{ "Stage1CompilationDir", Dirs.Stage1Compilation },
|
||||
{ "Stage2Dir", Dirs.Stage2 },
|
||||
{ "STAGE2_DIR", Dirs.Stage2 },
|
||||
{ "Stage2CompilationDir", Dirs.Stage2Compilation },
|
||||
{ "HostDir", Dirs.Corehost },
|
||||
{ "PackageDir", Path.Combine(Dirs.Packages, "dnvm") }, // Legacy name
|
||||
{ "TestBinRoot", Dirs.TestOutput },
|
||||
{ "TestPackageDir", Dirs.TestPackages },
|
||||
{ "MajorVersion", buildVersion.Major.ToString() },
|
||||
{ "MinorVersion", buildVersion.Minor.ToString() },
|
||||
{ "PatchVersion", buildVersion.Patch.ToString() },
|
||||
{ "CommitCountVersion", buildVersion.CommitCountString },
|
||||
{ "COMMIT_COUNT_VERSION", buildVersion.CommitCountString },
|
||||
{ "DOTNET_CLI_VERSION", buildVersion.SimpleVersion },
|
||||
{ "DOTNET_MSI_VERSION", buildVersion.GenerateMsiVersion() },
|
||||
{ "VersionSuffix", buildVersion.VersionSuffix },
|
||||
{ "CONFIGURATION", configuration },
|
||||
{ "ARCHITECTURE", architecture }
|
||||
};
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
env["OSNAME"] = "osx";
|
||||
}
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo", Path.Combine(c.BuildContext.BuildDirectory, "scripts", "package", "package.ps1"))
|
||||
.Environment(env)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Can directly execute scripts on Unix :). Thank you shebangs!
|
||||
Cmd(Path.Combine(c.BuildContext.BuildDirectory, "scripts", "package", "package.sh"))
|
||||
.Environment(env)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
}
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PublishTargets.PublishVersionBadge),
|
||||
nameof(PublishTargets.PublishCompressedFile),
|
||||
nameof(PublishTargets.PublishInstallerFile),
|
||||
nameof(PublishTargets.PublishLatestVersionTextFile))]
|
||||
public static BuildTargetResult PublishArtifacts(BuildTargetContext c)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult PublishVersionBadge(BuildTargetContext c)
|
||||
{
|
||||
var versionBadge = c.BuildContext.Get<string>("VersionBadge");
|
||||
var latestVersionBadgeBlob = $"{Channel}/Binaries/Latest/{Path.GetFileName(versionBadge)}";
|
||||
var versionBadgeBlob = $"{Channel}/Binaries/{Version}/{Path.GetFileName(versionBadge)}";
|
||||
|
||||
PublishFileAzure(versionBadgeBlob, versionBadge);
|
||||
PublishFileAzure(latestVersionBadgeBlob, versionBadge);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult PublishCompressedFile(BuildTargetContext c)
|
||||
{
|
||||
var compressedFile = c.BuildContext.Get<string>("CompressedFile");
|
||||
var compressedFileBlob = $"{Channel}/Binaries/{Version}/{Path.GetFileName(compressedFile)}";
|
||||
var latestCompressedFile = compressedFile.Replace(Version, "latest");
|
||||
var latestCompressedFileBlob = $"{Channel}/Binaries/Latest/{Path.GetFileName(latestCompressedFile)}";
|
||||
|
||||
PublishFileAzure(compressedFileBlob, compressedFile);
|
||||
PublishFileAzure(latestCompressedFileBlob, compressedFile);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows, BuildPlatform.OSX, BuildPlatform.Ubuntu)]
|
||||
public static BuildTargetResult PublishInstallerFile(BuildTargetContext c)
|
||||
{
|
||||
var installerFile = c.BuildContext.Get<string>("InstallerFile");
|
||||
var installerFileBlob = $"{Channel}/Installers/{Version}/{Path.GetFileName(installerFile)}";
|
||||
var latestInstallerFile = installerFile.Replace(Version, "latest");
|
||||
var latestInstallerFileBlob = $"{Channel}/Installers/Latest/{Path.GetFileName(latestInstallerFile)}";
|
||||
|
||||
PublishFileAzure(installerFileBlob, installerFile);
|
||||
PublishFileAzure(latestInstallerFileBlob, installerFile);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult PublishLatestVersionTextFile(BuildTargetContext c)
|
||||
{
|
||||
var osname = Monikers.GetOSShortName();
|
||||
var latestVersionBlob = $"{Channel}/dnvm/latest.{osname}.{CurrentArchitecture.Current}.version";
|
||||
var latestVersionFile = Path.Combine(Dirs.Stage2, ".version");
|
||||
|
||||
PublishFileAzure(latestVersionBlob, latestVersionFile);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PublishInstallerFile))]
|
||||
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
||||
public static BuildTargetResult PublishDebFileToDebianRepo(BuildTargetContext c)
|
||||
{
|
||||
var packageName = Monikers.GetDebianPackageName(c);
|
||||
var installerFile = c.BuildContext.Get<string>("InstallerFile");
|
||||
var uploadUrl = $"https://dotnetcli.blob.core.windows.net/dotnet/{Channel}/Installers/{Version}/{Path.GetFileName(installerFile)}";
|
||||
var uploadJson = GenerateUploadJsonFile(packageName, Version, uploadUrl);
|
||||
|
||||
Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "publish", "repoapi_client.sh"), "-addpkg", uploadJson)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
private static string GenerateUploadJsonFile(string packageName, string version, string uploadUrl)
|
||||
{
|
||||
var repoID = Environment.GetEnvironmentVariable("REPO_ID");
|
||||
var uploadJson = Path.Combine(Dirs.Packages, "package_upload.json");
|
||||
File.Delete(uploadJson);
|
||||
|
||||
using (var fileStream = File.Create(uploadJson))
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(fileStream))
|
||||
{
|
||||
sw.WriteLine("{");
|
||||
sw.WriteLine($" \"name\":\"{packageName}\",");
|
||||
sw.WriteLine($" \"version\":\"{version}\",");
|
||||
sw.WriteLine($" \"repositoryId\":\"{repoID}\",");
|
||||
sw.WriteLine($" \"sourceUrl\":\"{uploadUrl}\"");
|
||||
sw.WriteLine("}");
|
||||
}
|
||||
}
|
||||
|
||||
return uploadJson;
|
||||
}
|
||||
|
||||
private static BuildTargetResult PublishFile(BuildTargetContext c, string file)
|
||||
{
|
||||
var env = PackageTargets.GetCommonEnvVars(c);
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
Path.Combine(Dirs.RepoRoot, "scripts", "publish", "publish.ps1"), file)
|
||||
.Environment(env)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
private static void PublishFileAzure(string blob, string file)
|
||||
{
|
||||
CloudBlockBlob blockBlob = BlobContainer.GetBlockBlobReference(blob);
|
||||
blockBlob.UploadFromFileAsync(file, FileMode.Open).Wait();
|
||||
|
||||
if (Path.GetExtension(blockBlob.Uri.AbsolutePath.ToLower()) == ".svg")
|
||||
{
|
||||
blockBlob.Properties.ContentType = "image/svg+xml";
|
||||
blockBlob.Properties.CacheControl = "no-cache";
|
||||
blockBlob.SetPropertiesAsync().Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,9 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
public static class Dirs
|
||||
{
|
||||
public static readonly string RepoRoot = Directory.GetCurrentDirectory();
|
||||
public static readonly string Output = Path.Combine(
|
||||
Directory.GetCurrentDirectory(),
|
||||
RepoRoot,
|
||||
"artifacts",
|
||||
PlatformServices.Default.Runtime.GetRuntimeIdentifier());
|
||||
public static readonly string Packages = Path.Combine(Output, "packages");
|
||||
|
|
57
scripts/dotnet-cli-build/Utils/Monikers.cs
Normal file
57
scripts/dotnet-cli-build/Utils/Monikers.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class Monikers
|
||||
{
|
||||
public static string GetProductMoniker(BuildTargetContext c)
|
||||
{
|
||||
string osname = GetOSShortName();
|
||||
var arch = CurrentArchitecture.Current.ToString();
|
||||
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
||||
return $"dotnet-{osname}-{arch}.{version}";
|
||||
}
|
||||
|
||||
public static string GetDebianPackageName(BuildTargetContext c)
|
||||
{
|
||||
var channel = c.BuildContext.Get<string>("Channel").ToLower();
|
||||
var packageName = "";
|
||||
switch (channel)
|
||||
{
|
||||
case "dev":
|
||||
packageName = "dotnet-nightly";
|
||||
break;
|
||||
case "beta":
|
||||
case "rc1":
|
||||
case "rc2":
|
||||
case "rtm":
|
||||
packageName = "dotnet";
|
||||
break;
|
||||
default:
|
||||
throw new Exception($"Unknown channel - {channel}");
|
||||
}
|
||||
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public static string GetOSShortName()
|
||||
{
|
||||
string osname = "";
|
||||
switch (CurrentPlatform.Current)
|
||||
{
|
||||
case BuildPlatform.Windows:
|
||||
osname = "win";
|
||||
break;
|
||||
default:
|
||||
osname = CurrentPlatform.Current.ToString().ToLower();
|
||||
break;
|
||||
}
|
||||
|
||||
return osname;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,12 +9,13 @@
|
|||
"NETStandard.Library": "1.0.0-rc2-23901",
|
||||
"System.IO.Compression.ZipFile": "4.0.1-rc2-23901",
|
||||
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16537",
|
||||
"Microsoft.DotNet.Cli.Build.Framework": "1.0.0-*"
|
||||
"Microsoft.DotNet.Cli.Build.Framework": "1.0.0-*",
|
||||
"WindowsAzure.Storage" : "6.2.2-preview"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"netstandardapp1.5": {
|
||||
"imports": "dnxcore50"
|
||||
"imports": ["dnxcore50", "portable-net45+win8"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,6 +83,10 @@ current_os()
|
|||
echo "ubuntu"
|
||||
elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then
|
||||
echo "centos"
|
||||
elif [ "$(cat /etc/*-release | grep -cim1 rhel)" -eq 1 ]; then
|
||||
echo "rhel.7"
|
||||
elif [ "$(cat /etc/*-release | grep -cim1 debian)" -eq 1 ]; then
|
||||
echo "debian"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -104,11 +108,19 @@ check_pre_reqs() {
|
|||
fi
|
||||
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
[ -z "$(ldconfig -p | grep libunwind)" ] && say_err "Unable to locate libunwind. Install libunwind to continue" && _failing=true
|
||||
[ -z "$(ldconfig -p | grep libssl)" ] && say_err "Unable to locate libssl. Install libssl to continue" && _failing=true
|
||||
[ -z "$(ldconfig -p | grep libcurl)" ] && say_err "Unable to locate libcurl. Install libcurl to continue" && _failing=true
|
||||
[ -z "$(ldconfig -p | grep libicu)" ] && say_err "Unable to locate libicu. Install libicu to continue" && _failing=true
|
||||
[ -z "$(ldconfig -p | grep gettext)" ] && say_err "Unable to locate gettext. Install gettext to continue" && _failing=true
|
||||
|
||||
if ! [ -x "$(command -v ldconfig)" ]; then
|
||||
echo "ldconfig is not in PATH, trying /sbin/ldconfig."
|
||||
LDCONFIG_COMMAND="/sbin/ldconfig"
|
||||
else
|
||||
LDCONFIG_COMMAND="ldconfig"
|
||||
fi
|
||||
|
||||
[ -z "$($LDCONFIG_COMMAND -p | grep libunwind)" ] && say_err "Unable to locate libunwind. Install libunwind to continue" && _failing=true
|
||||
[ -z "$($LDCONFIG_COMMAND -p | grep libssl)" ] && say_err "Unable to locate libssl. Install libssl to continue" && _failing=true
|
||||
[ -z "$($LDCONFIG_COMMAND -p | grep libcurl)" ] && say_err "Unable to locate libcurl. Install libcurl to continue" && _failing=true
|
||||
[ -z "$($LDCONFIG_COMMAND -p | grep libicu)" ] && say_err "Unable to locate libicu. Install libicu to continue" && _failing=true
|
||||
[ -z "$($LDCONFIG_COMMAND -p | grep gettext)" ] && say_err "Unable to locate gettext. Install gettext to continue" && _failing=true
|
||||
fi
|
||||
|
||||
if [ "$_failing" = true ]; then
|
||||
|
|
|
@ -17,46 +17,105 @@ done
|
|||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source "$DIR/../common/_common.sh"
|
||||
REPOROOT="$DIR/../.."
|
||||
|
||||
if [ "$OSNAME" != "ubuntu" ]; then
|
||||
error "Debian Package build only supported on Ubuntu"
|
||||
help(){
|
||||
echo "Usage: $0"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --version <version> Specify a version for the package."
|
||||
echo " --input <input directory> Package the entire contents of the directory tree."
|
||||
echo " --manpages <man pages directory> Directory containing man pages for the package (Optional)."
|
||||
echo " --output <output debfile> The full path to which the package will be written."
|
||||
echo " --package-name <package name> Package to identify during installation. Example - 'dotnet-nightly', 'dotnet'"
|
||||
echo " --previous-version-url <url> Url to the previous version of the debian packge against which to run the upgrade tests."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
parseargs(){
|
||||
|
||||
while [[ $# > 0 ]]; do
|
||||
lowerI="$(echo $1 | awk '{print tolower($0)}')"
|
||||
case $lowerI in
|
||||
-m|--manpages)
|
||||
MANPAGE_DIR=$2
|
||||
shift
|
||||
;;
|
||||
-o|--output)
|
||||
OUTPUT_DEBIAN_FILE=$2
|
||||
shift
|
||||
;;
|
||||
-i|--input)
|
||||
REPO_BINARIES_DIR=$2
|
||||
shift
|
||||
;;
|
||||
-p|--package-name)
|
||||
DOTNET_DEB_PACKAGE_NAME=$2
|
||||
shift
|
||||
;;
|
||||
-v|--version)
|
||||
DOTNET_CLI_VERSION=$2
|
||||
shift
|
||||
;;
|
||||
--previous-version-url)
|
||||
PREVIOUS_VERSION_URL=$2
|
||||
shift
|
||||
;;
|
||||
--help)
|
||||
help
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "$DOTNET_CLI_VERSION" ]; then
|
||||
echo "Provide a version number. Missing option '--version'" && help
|
||||
fi
|
||||
|
||||
if [ -z "$OUTPUT_DEBIAN_FILE" ]; then
|
||||
echo "Provide an output deb. Missing option '--output'" && help
|
||||
fi
|
||||
|
||||
if [ -z "$REPO_BINARIES_DIR" ]; then
|
||||
echo "Provide an input directory. Missing option '--input'" && help
|
||||
fi
|
||||
|
||||
if [ -z "$DOTNET_DEB_PACKAGE_NAME" ]; then
|
||||
echo "Provide an the name for the debian package. Missing option '--package-name'" && help
|
||||
fi
|
||||
|
||||
if [ -z "$PREVIOUS_VERSION_URL" ]; then
|
||||
echo "Provide a URL to the previous debian pacakge (Required for running upgrade tests). Missing option '--previous-version-url'" && help
|
||||
fi
|
||||
|
||||
if [ ! -d "$REPO_BINARIES_DIR" ]; then
|
||||
echo "'$REPO_BINARIES_DIR' - is either missing or not a directory" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
parseargs $@
|
||||
|
||||
PACKAGING_ROOT="$REPOROOT/packaging/debian"
|
||||
PACKAGING_TOOL_DIR="$REPOROOT/tools/DebianPackageTool"
|
||||
|
||||
OUTPUT_DIR="$REPOROOT/artifacts"
|
||||
PACKAGE_LAYOUT_DIR="$OUTPUT_DIR/deb_intermediate"
|
||||
PACKAGE_OUTPUT_DIR="$OUTPUT_DIR/packages/debian"
|
||||
TEST_STAGE_DIR="$PACKAGE_OUTPUT_DIR/test"
|
||||
REPO_BINARIES_DIR="$REPOROOT/artifacts/ubuntu.14.04-x64/stage2"
|
||||
MANPAGE_DIR="$REPOROOT/Documentation/manpages"
|
||||
PACKAGE_OUTPUT_DIR=$(dirname "${OUTPUT_DEBIAN_FILE}")
|
||||
PACKAGE_LAYOUT_DIR="$PACKAGE_OUTPUT_DIR/deb_intermediate"
|
||||
TEST_STAGE_DIR="$PACKAGE_OUTPUT_DIR/debian_tests"
|
||||
|
||||
NIGHTLY_PACKAGE_NAME="dotnet-nightly"
|
||||
RELEASE_PACKAGE_NAME="dotnet"
|
||||
|
||||
[ -z "$CHANNEL" ] && CHANNEL="dev"
|
||||
# remove any residual deb files from earlier builds
|
||||
rm -f "$PACKAGE_OUTPUT_DIR/*.deb"
|
||||
|
||||
execute_build(){
|
||||
determine_package_name
|
||||
create_empty_debian_layout
|
||||
copy_files_to_debian_layout
|
||||
create_debian_package
|
||||
}
|
||||
|
||||
determine_package_name(){
|
||||
if [[ "$RELEASE_SUFFIX" == "dev" ]]; then
|
||||
DOTNET_DEB_PACKAGE_NAME=$NIGHTLY_PACKAGE_NAME
|
||||
elif [[ "beta rc1 rc2 rtm" =~ (^| )"$RELEASE_SUFFIX"($| ) ]]; then
|
||||
DOTNET_DEB_PACKAGE_NAME=$RELEASE_PACKAGE_NAME
|
||||
elif [[ "$RELEASE_SUFFIX" == "" ]]; then
|
||||
DOTNET_DEB_PACKAGE_NAME=$RELEASE_PACKAGE_NAME
|
||||
else
|
||||
DOTNET_DEB_PACKAGE_NAME=$NIGHTLY_PACKAGE_NAME
|
||||
fi
|
||||
}
|
||||
|
||||
execute_test(){
|
||||
test_debian_package
|
||||
}
|
||||
|
@ -120,7 +179,7 @@ remove_debian_package() {
|
|||
|
||||
run_package_integrity_tests() {
|
||||
# Set LAST_VERSION_URL to enable upgrade tests
|
||||
export LAST_VERSION_URL="https://dotnetcli.blob.core.windows.net/dotnet/$CHANNEL/Installers/Latest/dotnet-ubuntu-x64.latest.deb"
|
||||
export LAST_VERSION_URL="$PREVIOUS_VERSION_URL"
|
||||
|
||||
$TEST_STAGE_DIR/bin/bats $PACKAGE_OUTPUT_DIR/test_package.bats
|
||||
}
|
||||
|
@ -142,5 +201,4 @@ DEBIAN_FILE=$(find $PACKAGE_OUTPUT_DIR -iname "*.deb")
|
|||
|
||||
execute_test
|
||||
|
||||
# Publish
|
||||
$REPOROOT/scripts/publish/publish.sh $DEBIAN_FILE
|
||||
mv -f "$DEBIAN_FILE" "$OUTPUT_DEBIAN_FILE"
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source "$DIR/../common/_common.sh"
|
||||
|
||||
if [ ! -d "$STAGE2_DIR" ]; then
|
||||
error "missing stage2 output in $STAGE2_DIR" 1>&2
|
||||
exit
|
||||
fi
|
||||
|
||||
PACKAGE_DIR=$REPOROOT/artifacts/packages/dnvm
|
||||
[ -d "$PACKAGE_DIR" ] || mkdir -p $PACKAGE_DIR
|
||||
|
||||
PACKAGE_SHORT_NAME=dotnet-${OSNAME}-x64.${DOTNET_CLI_VERSION}
|
||||
PACKAGE_NAME=$PACKAGE_DIR/${PACKAGE_SHORT_NAME}.tar.gz
|
||||
|
||||
cd $STAGE2_DIR
|
||||
|
||||
header "Packaging $PACKAGE_SHORT_NAME"
|
||||
|
||||
# Tar up the stage2 artifacts
|
||||
# We need both "*" and ".version" to ensure we pick up that file
|
||||
tar -czf $PACKAGE_NAME * .version
|
||||
|
||||
info "Packaged stage2 from '$STAGE2_DIR' to '$PACKAGE_NAME'"
|
||||
|
||||
$REPOROOT/scripts/publish/publish.sh $PACKAGE_NAME
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source "$DIR/../common/_common.sh"
|
||||
|
||||
if [[ "$OSNAME" == "ubuntu" ]]; then
|
||||
# Create Debian package
|
||||
$REPOROOT/scripts/package/package-debian.sh
|
||||
elif [[ "$OSNAME" == "osx" ]]; then
|
||||
# Create OSX PKG
|
||||
$REPOROOT/packaging/osx/package-osx.sh
|
||||
fi
|
|
@ -1,44 +0,0 @@
|
|||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
. "$PSScriptRoot\..\common\_common.ps1"
|
||||
|
||||
if(!(Test-Path $PackageDir)) {
|
||||
mkdir $PackageDir | Out-Null
|
||||
}
|
||||
|
||||
if(![string]::IsNullOrEmpty($env:DOTNET_CLI_VERSION)) {
|
||||
$PackageVersion = $env:DOTNET_CLI_VERSION
|
||||
} else {
|
||||
$Timestamp = [DateTime]::Now.ToString("yyyyMMddHHmmss")
|
||||
$PackageVersion = "0.0.1-dev-t$Timestamp"
|
||||
}
|
||||
|
||||
# Stamp the output with the commit metadata and version number
|
||||
$Commit = git rev-parse HEAD
|
||||
|
||||
$VersionContent = @"
|
||||
$Commit
|
||||
$PackageVersion
|
||||
"@
|
||||
|
||||
$VersionContent | Out-File -Encoding UTF8 "$Stage2Dir\.version"
|
||||
|
||||
$PackageName = Join-Path $PackageDir "dotnet-win-$env:ARCHITECTURE.$PackageVersion.zip"
|
||||
|
||||
if (Test-Path $PackageName)
|
||||
{
|
||||
del $PackageName
|
||||
}
|
||||
|
||||
Add-Type -Assembly System.IO.Compression.FileSystem
|
||||
[System.IO.Compression.ZipFile]::CreateFromDirectory($Stage2Dir, $PackageName, "Optimal", $false)
|
||||
|
||||
Write-Host "Packaged stage2 to $PackageName"
|
||||
|
||||
$PublishScript = Join-Path $PSScriptRoot "..\publish\publish.ps1"
|
||||
& $PublishScript -file $PackageName
|
||||
|
||||
exit $LastExitCode
|
|
@ -1,6 +0,0 @@
|
|||
@echo off
|
||||
|
||||
REM Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
REM Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
powershell -NoProfile -NoLogo -Command "%~dp0package.ps1 %*; exit $LastExitCode;"
|
|
@ -1,24 +0,0 @@
|
|||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
. "$PSScriptRoot\..\common\_common.ps1"
|
||||
|
||||
$RepoRoot = Convert-Path "$PSScriptRoot\..\.."
|
||||
|
||||
header "Generating zip package"
|
||||
_ "$RepoRoot\scripts\package\package-zip.ps1"
|
||||
|
||||
header "Generating dotnet MSI"
|
||||
_ "$RepoRoot\packaging\windows\generatemsi.ps1" @("$Stage2Dir")
|
||||
|
||||
header "Generating NuGet packages"
|
||||
_ "$RepoRoot\packaging\nuget\package.ps1" @("$Stage2Dir\bin", "$env:VersionSuffix")
|
||||
|
||||
header "Generating version badge"
|
||||
$VersionBadge = "$RepoRoot\resources\images\version_badge.svg"
|
||||
$BadgeDestination = "$RepoRoot\artifacts\version_badge.svg"
|
||||
(get-content $VersionBadge).replace("ver_number", "$env:DOTNET_CLI_VERSION") | set-content $BadgeDestination
|
||||
|
||||
& "$RepoRoot\scripts\publish\publish.ps1" -file $BadgeDestination
|
|
@ -1,40 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
export REPOROOT="$(cd -P "$DIR/../.." && pwd)"
|
||||
|
||||
set -e
|
||||
|
||||
source "$DIR/../common/_common.sh"
|
||||
|
||||
if [ -z "$DOTNET_CLI_VERSION" ]; then
|
||||
TIMESTAMP=$(date "+%Y%m%d%H%M%S")
|
||||
DOTNET_CLI_VERSION=0.0.1-dev-t$TIMESTAMP
|
||||
fi
|
||||
|
||||
VERSION_BADGE="$REPOROOT/resources/images/version_badge.svg"
|
||||
BADGE_DESTINATION="$REPOROOT/artifacts/version_badge.svg"
|
||||
|
||||
header "Generating tarball"
|
||||
$DIR/package-dnvm.sh
|
||||
|
||||
header "Generating Native Installer"
|
||||
$DIR/package-native.sh
|
||||
|
||||
header "Generating version badge"
|
||||
sed "s/ver_number/$DOTNET_CLI_VERSION/g" $VERSION_BADGE > $BADGE_DESTINATION
|
||||
|
||||
header "Publishing version badge"
|
||||
$DIR/../publish/publish.sh $BADGE_DESTINATION
|
||||
|
|
@ -1,186 +0,0 @@
|
|||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$file
|
||||
)
|
||||
|
||||
. "$PSScriptRoot\..\common\_common.ps1"
|
||||
|
||||
function CheckRequiredVariables
|
||||
{
|
||||
if([string]::IsNullOrEmpty($env:DOTNET_CLI_VERSION))
|
||||
{
|
||||
return $false
|
||||
}
|
||||
|
||||
# this variable is set by the CI system
|
||||
if([string]::IsNullOrEmpty($env:SASTOKEN))
|
||||
{
|
||||
return $false
|
||||
}
|
||||
|
||||
# this variable is set by the CI system
|
||||
if([string]::IsNullOrEmpty($env:STORAGE_ACCOUNT))
|
||||
{
|
||||
return $false
|
||||
}
|
||||
|
||||
# this variable is set by the CI system
|
||||
if([string]::IsNullOrEmpty($env:STORAGE_CONTAINER))
|
||||
{
|
||||
return $false
|
||||
}
|
||||
|
||||
# this variable is set by the CI system
|
||||
if([string]::IsNullOrEmpty($env:CHANNEL))
|
||||
{
|
||||
return $false
|
||||
}
|
||||
|
||||
# this variable is set by the CI system
|
||||
if([string]::IsNullOrEmpty($env:CONNECTION_STRING))
|
||||
{
|
||||
return $false
|
||||
}
|
||||
|
||||
return $true
|
||||
}
|
||||
|
||||
function UploadFile($Blob, $Uploadfile, $PreventCaching = $false)
|
||||
{
|
||||
Write-Host "Uploading $Uploadfile to dotnet feed."
|
||||
|
||||
if([string]::IsNullOrEmpty($env:HOME))
|
||||
{
|
||||
$env:HOME=Get-Location
|
||||
}
|
||||
|
||||
$properties = ""
|
||||
|
||||
if($PreventCaching)
|
||||
{
|
||||
# use azure cli to upload to blob storage. We cannot use Invoke-WebRequest to do this becuase azure has a max limit of 64mb that can be uploaded using REST
|
||||
#$statusCode = (Invoke-WebRequest -URI "$Upload_URI" -Method PUT -Headers @{"x-ms-blob-type"="BlockBlob"; "x-ms-date"="2015-10-23";"x-ms-version"="2013-08-15"} -InFile $Uploadfile).StatusCode
|
||||
azure storage blob upload --quiet --properties cacheControl=no-cache --container $env:STORAGE_CONTAINER --blob $Blob --blobtype block --connection-string "$env:CONNECTION_STRING" --file $Uploadfile | Out-Host
|
||||
}
|
||||
else
|
||||
{
|
||||
# use azure cli to upload to blob storage. We cannot use Invoke-WebRequest to do this becuase azure has a max limit of 64mb that can be uploaded using REST
|
||||
#$statusCode = (Invoke-WebRequest -URI "$Upload_URI" -Method PUT -Headers @{"x-ms-blob-type"="BlockBlob"; "x-ms-date"="2015-10-23";"x-ms-version"="2013-08-15"} -InFile $Uploadfile).StatusCode
|
||||
azure storage blob upload --quiet $properties --container $env:STORAGE_CONTAINER --blob $Blob --blobtype block --connection-string "$env:CONNECTION_STRING" --file $Uploadfile | Out-Host
|
||||
}
|
||||
|
||||
|
||||
if($?)
|
||||
{
|
||||
Write-Host "Successfully uploaded $Uploadfile to dotnet feed."
|
||||
return $true
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Failed to upload $Uploadfile to dotnet feed."
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
function UploadBinaries($zipFile)
|
||||
{
|
||||
$result = -1
|
||||
$fileName = [System.IO.Path]::GetFileName($zipFile)
|
||||
$zipBlob = "$env:CHANNEL/Binaries/$env:DOTNET_CLI_VERSION/$fileName"
|
||||
|
||||
if(-Not (UploadFile $zipBlob $zipFile))
|
||||
{
|
||||
return -1
|
||||
}
|
||||
|
||||
Write-Host "Updating the latest dotnet binaries for windows.."
|
||||
$zipBlobLatest = "$env:CHANNEL/Binaries/Latest/dotnet-win-$env:ARCHITECTURE.latest.zip"
|
||||
|
||||
if(-Not (UploadFile $zipBlobLatest $zipFile $true))
|
||||
{
|
||||
return -1
|
||||
}
|
||||
|
||||
# update the version file
|
||||
$versionFile = Convert-Path $PSScriptRoot\..\..\artifacts\$env:RID\stage2\.version
|
||||
$versionBlob = "$env:CHANNEL/dnvm/latest.win.$env:ARCHITECTURE.version"
|
||||
|
||||
if(-Not (UploadFile $versionBlob $versionFile $true))
|
||||
{
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function UploadInstallers($installerFile)
|
||||
{
|
||||
$fileName = [System.IO.Path]::GetFileName($installerFile)
|
||||
$installerBlob = "$env:CHANNEL/Installers/$env:DOTNET_CLI_VERSION/$fileName"
|
||||
|
||||
if(-Not (UploadFile $installerBlob $installerFile))
|
||||
{
|
||||
return -1
|
||||
}
|
||||
|
||||
Write-Host "Updating the latest dotnet installer for windows.."
|
||||
$installerBlobLatest = "$env:CHANNEL/Installers/Latest/dotnet-win-$env:ARCHITECTURE.latest.exe"
|
||||
|
||||
if(-Not (UploadFile $installerBlobLatest $installerFile $true))
|
||||
{
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function UploadVersionBadge($badgeFile)
|
||||
{
|
||||
$fileName = "windows_$($env:CONFIGURATION)_$([System.IO.Path]::GetFileName($badgeFile))"
|
||||
|
||||
Write-Host "Uploading the version badge to Latest"
|
||||
if(-Not (UploadFile "$env:CHANNEL/Binaries/Latest/$fileName" $badgeFile $true))
|
||||
{
|
||||
return -1
|
||||
}
|
||||
|
||||
Write-Host "Uploading the version badge to $env:DOTNET_CLI_VERSION"
|
||||
if(-Not (UploadFile "$env:CHANNEL/Binaries/$env:DOTNET_CLI_VERSION/$fileName" $badgeFile))
|
||||
{
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
if(!(CheckRequiredVariables))
|
||||
{
|
||||
# fail silently if the required variables are not available for publishing the file
|
||||
exit 0
|
||||
}
|
||||
|
||||
if(![System.IO.File]::Exists($file))
|
||||
{
|
||||
throw "$file not found"
|
||||
}
|
||||
|
||||
$result = $false
|
||||
|
||||
if([System.IO.Path]::GetExtension($file).ToLower() -eq ".zip")
|
||||
{
|
||||
$result = UploadBinaries $file
|
||||
}
|
||||
elseif([System.IO.Path]::GetExtension($file).ToLower() -eq ".exe")
|
||||
{
|
||||
$result = UploadInstallers $file
|
||||
}
|
||||
elseif ([System.IO.Path]::GetExtension($file).ToLower() -eq ".svg")
|
||||
{
|
||||
$result = UploadVersionBadge $file
|
||||
}
|
||||
|
||||
exit $result
|
|
@ -1,246 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
# Usage: publish.sh [file to be uploaded]
|
||||
#
|
||||
# Environment Dependencies:
|
||||
# $STORAGE_CONTAINER
|
||||
# $STORAGE_ACCOUNT
|
||||
# $SASTOKEN
|
||||
# $REPO_ID
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source "$DIR/../common/_common.sh"
|
||||
|
||||
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
UPLOAD_FILE=$1
|
||||
UPLOAD_JSON_FILE="package_upload.json"
|
||||
|
||||
header "Publishing package"
|
||||
|
||||
execute(){
|
||||
if ! validate_env_variables; then
|
||||
# fail silently if the required variables are not available for publishing the file.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ! -f "$UPLOAD_FILE" ]]; then
|
||||
error "\"$UPLOAD_FILE\" file does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $UPLOAD_FILE == *.deb || $UPLOAD_FILE == *.pkg ]]; then
|
||||
upload_installers_to_blob_storage $UPLOAD_FILE
|
||||
result=$?
|
||||
elif [[ $UPLOAD_FILE == *.tar.gz ]]; then
|
||||
upload_binaries_to_blob_storage $UPLOAD_FILE
|
||||
result=$?
|
||||
elif [[ $UPLOAD_FILE == *.svg ]]; then
|
||||
upload_version_badge $UPLOAD_FILE
|
||||
result=$?
|
||||
fi
|
||||
|
||||
exit $result
|
||||
}
|
||||
|
||||
validate_env_variables(){
|
||||
local ret=0
|
||||
|
||||
if [[ -z "$DOTNET_CLI_VERSION" ]]; then
|
||||
warning "DOTNET_CLI_VERSION environment variable not set"
|
||||
ret=1
|
||||
fi
|
||||
|
||||
if [[ -z "$SASTOKEN" ]]; then
|
||||
warning "SASTOKEN environment variable not set"
|
||||
ret=1
|
||||
fi
|
||||
|
||||
if [[ -z "$STORAGE_ACCOUNT" ]]; then
|
||||
warning "STORAGE_ACCOUNT environment variable not set"
|
||||
ret=1
|
||||
fi
|
||||
|
||||
if [[ -z "$STORAGE_CONTAINER" ]]; then
|
||||
warning "STORAGE_CONTAINER environment variable not set"
|
||||
ret=1
|
||||
fi
|
||||
|
||||
if [[ -z "$CHANNEL" ]]; then
|
||||
warning "CHANNEL environment variable not set"
|
||||
ret=1
|
||||
fi
|
||||
|
||||
if [[ -z "$CONNECTION_STRING" ]]; then
|
||||
warning "CONNECTION_STRING environment variable not set"
|
||||
ret=1
|
||||
fi
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
upload_file_to_blob_storage_azure_cli(){
|
||||
local blob=$1
|
||||
local file=$2
|
||||
local preventCaching=${3:false}
|
||||
|
||||
header "Uploading $file to blob storage"
|
||||
|
||||
local properties=""
|
||||
|
||||
if $preventCaching ; then
|
||||
properties="--properties cacheControl=no-cache"
|
||||
fi
|
||||
|
||||
# use azure cli to upload to blob storage. We cannot use curl to do this becuase azure has a max limit of 64mb that can be uploaded using REST
|
||||
# statusCode=$(curl -s -w "%{http_code}" -L -H "x-ms-blob-type: BlockBlob" -H "x-ms-date: 2015-10-21" -H "x-ms-version: 2013-08-15" $upload_URL -T $file)
|
||||
azure storage blob upload --quiet $properties --container $STORAGE_CONTAINER --blob $blob --blobtype block --connection-string "$CONNECTION_STRING" --file $file
|
||||
result=$?
|
||||
|
||||
if [ "$result" -eq "0" ]; then
|
||||
info "successfully uploaded $filename to blob storage."
|
||||
return 0
|
||||
else
|
||||
error "uploading the $filename to blob storage - $statusCode"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
update_file_in_blob_storage(){
|
||||
local update_URL=$1
|
||||
local file=$2
|
||||
local filecontent=$3
|
||||
|
||||
header "Updating $file in blob storage"
|
||||
|
||||
statusCode=$(curl -s -w "%{http_code}" -L -H "x-ms-blob-type: BlockBlob" -H "x-ms-date: 2015-10-21" -H "x-ms-version: 2013-08-15" -H "Content-Type: text/plain" $update_URL --data-binary $filecontent --request PUT )
|
||||
|
||||
if [ "$statusCode" -eq "201" ]; then
|
||||
info "successfully updated $file in blob storage."
|
||||
return 0
|
||||
else
|
||||
error "updating the $file in blob storage - $statusCode"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
upload_binaries_to_blob_storage(){
|
||||
local tarfile=$1
|
||||
local filename=$(basename $tarfile)
|
||||
local blob="$CHANNEL/Binaries/$DOTNET_CLI_VERSION/$filename"
|
||||
|
||||
if ! upload_file_to_blob_storage_azure_cli $blob $tarfile; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# create the latest blob
|
||||
echo "Updating the latest dotnet binaries.."
|
||||
local latestblob="$CHANNEL/Binaries/Latest/dotnet-$OSNAME-x64.latest.tar.gz"
|
||||
|
||||
if ! upload_file_to_blob_storage_azure_cli $latestblob $tarfile true; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# update the index file
|
||||
local indexContent="Binaries/$DOTNET_CLI_VERSION/$filename"
|
||||
local indexfile="latest.$OSNAME.index"
|
||||
local index_URL="https://$STORAGE_ACCOUNT.blob.core.windows.net/$STORAGE_CONTAINER/$CHANNEL/dnvm/$indexfile$SASTOKEN"
|
||||
update_file_in_blob_storage $index_URL $indexfile $indexContent true
|
||||
|
||||
# update the version file
|
||||
# the "@" prefix tells curl to upload the content of the file
|
||||
local versionContent="@$REPOROOT/artifacts/$RID/stage2/.version"
|
||||
local versionfile="latest.$OSNAME.version"
|
||||
local version_URL="https://$STORAGE_ACCOUNT.blob.core.windows.net/$STORAGE_CONTAINER/$CHANNEL/dnvm/$versionfile$SASTOKEN"
|
||||
update_file_in_blob_storage $version_URL $versionfile $versionContent true
|
||||
|
||||
return $?
|
||||
}
|
||||
|
||||
upload_installers_to_blob_storage(){
|
||||
local installfile=$1
|
||||
local filename=$(basename $installfile)
|
||||
local blob="$CHANNEL/Installers/$DOTNET_CLI_VERSION/$filename"
|
||||
|
||||
if ! upload_file_to_blob_storage_azure_cli $blob $installfile; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# create the latest blob
|
||||
echo "Updating the latest dotnet installer.."
|
||||
local extension="${filename##*.}"
|
||||
local latestblob="$CHANNEL/Installers/Latest/dotnet-$OSNAME-x64.latest.$extension"
|
||||
|
||||
if ! upload_file_to_blob_storage_azure_cli $latestblob $installfile true; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# debain packages need to be uploaded to the PPA feed too
|
||||
if [[ $installfile == *.deb ]]; then
|
||||
DEB_FILE=$installfile
|
||||
UPLOAD_URL="https://$STORAGE_ACCOUNT.blob.core.windows.net/$STORAGE_CONTAINER/$blob"
|
||||
generate_repoclient_json
|
||||
call_repo_client
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
upload_version_badge(){
|
||||
local badgefile=$1
|
||||
local filename="${OSNAME}_${CONFIGURATION}_$(basename $badgefile)"
|
||||
echo "Uploading the version badge to Latest"
|
||||
upload_file_to_blob_storage_azure_cli "$CHANNEL/Binaries/Latest/$filename" $badgefile true
|
||||
|
||||
echo "Uploading the version badge to $DOTNET_CLI_VERSION"
|
||||
upload_file_to_blob_storage_azure_cli "$CHANNEL/Binaries/$DOTNET_CLI_VERSION/$filename" $badgefile
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
generate_repoclient_json(){
|
||||
# Clean any existing json file
|
||||
rm -f $SCRIPT_DIR/$UPLOAD_JSON_FILE
|
||||
|
||||
echo "{" >> "$SCRIPT_DIR/$UPLOAD_JSON_FILE"
|
||||
echo " \"name\":\"$(_get_package_name)\"," >> "$SCRIPT_DIR/$UPLOAD_JSON_FILE"
|
||||
echo " \"version\":\"$(_get_package_version)\"," >> "$SCRIPT_DIR/$UPLOAD_JSON_FILE"
|
||||
echo " \"repositoryId\":\"$REPO_ID\"," >> "$SCRIPT_DIR/$UPLOAD_JSON_FILE"
|
||||
echo " \"sourceUrl\":\"$UPLOAD_URL\"" >> "$SCRIPT_DIR/$UPLOAD_JSON_FILE"
|
||||
echo "}" >> "$SCRIPT_DIR/$UPLOAD_JSON_FILE"
|
||||
}
|
||||
|
||||
call_repo_client(){
|
||||
$SCRIPT_DIR/repoapi_client.sh -addpkg $SCRIPT_DIR/$UPLOAD_JSON_FILE
|
||||
}
|
||||
|
||||
# Extract the package name from the .deb filename
|
||||
_get_package_name(){
|
||||
local deb_filename=$(basename $DEB_FILE)
|
||||
local package_name=${deb_filename%%_*}
|
||||
|
||||
echo $package_name
|
||||
}
|
||||
|
||||
# Extract the package version from the .deb filename
|
||||
_get_package_version(){
|
||||
local deb_filename=$(basename $DEB_FILE)
|
||||
local package_version=${deb_filename#*_}
|
||||
package_version=${package_version%-*}
|
||||
|
||||
echo $package_version
|
||||
}
|
||||
|
||||
execute
|
|
@ -84,7 +84,8 @@ done < "$DIR/../branchinfo.txt"
|
|||
[ -d $DOTNET_INSTALL_DIR ] || mkdir -p $DOTNET_INSTALL_DIR
|
||||
|
||||
# Ensure the latest stage0 is installed
|
||||
$DIR/obtain/install.sh --channel $RELEASE_SUFFIX
|
||||
export CHANNEL=$RELEASE_SUFFIX
|
||||
$DIR/obtain/install.sh --channel $CHANNEL
|
||||
|
||||
# Put stage 0 on the PATH (for this shell only)
|
||||
PATH="$DOTNET_INSTALL_DIR/bin:$PATH"
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
"netstandard1.3": {
|
||||
"imports": "dnxcore50",
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23901"
|
||||
"NETStandard.Library": "1.0.0-rc2-23901",
|
||||
"System.Diagnostics.Process": "4.1.0-rc2-23901"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ using Microsoft.DotNet.Files;
|
|||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.ProjectModel.Compilation;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
using Microsoft.Extensions.DependencyModel;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace Microsoft.Dotnet.Cli.Compiler.Common
|
||||
|
@ -22,28 +23,26 @@ namespace Microsoft.Dotnet.Cli.Compiler.Common
|
|||
|
||||
private readonly LibraryExporter _exporter;
|
||||
|
||||
private readonly string _configuration;
|
||||
|
||||
private readonly OutputPaths _outputPaths;
|
||||
|
||||
private readonly string _runtimeOutputPath;
|
||||
|
||||
private readonly string _intermediateOutputPath;
|
||||
|
||||
public Executable(ProjectContext context, OutputPaths outputPaths, LibraryExporter exporter)
|
||||
public Executable(ProjectContext context, OutputPaths outputPaths, LibraryExporter exporter, string configuration)
|
||||
{
|
||||
_context = context;
|
||||
_outputPaths = outputPaths;
|
||||
_runtimeOutputPath = outputPaths.RuntimeOutputPath;
|
||||
_intermediateOutputPath = outputPaths.IntermediateOutputDirectoryPath;
|
||||
_exporter = exporter;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public void MakeCompilationOutputRunnable()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_context.RuntimeIdentifier))
|
||||
{
|
||||
throw new InvalidOperationException($"Can not make output runnable for framework {_context.TargetFramework}, because it doesn't have runtime target");
|
||||
}
|
||||
|
||||
CopyContentFiles();
|
||||
ExportRuntimeAssets();
|
||||
}
|
||||
|
@ -72,8 +71,11 @@ namespace Microsoft.Dotnet.Cli.Compiler.Common
|
|||
{
|
||||
WriteDepsFileAndCopyProjectDependencies(_exporter);
|
||||
|
||||
// TODO: Pick a host based on the RID
|
||||
CoreHost.CopyTo(_runtimeOutputPath, _context.ProjectFile.Name + Constants.ExeSuffix);
|
||||
if (!string.IsNullOrEmpty(_context.RuntimeIdentifier))
|
||||
{
|
||||
// TODO: Pick a host based on the RID
|
||||
CoreHost.CopyTo(_runtimeOutputPath, _context.ProjectFile.Name + Constants.ExeSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyContentFiles()
|
||||
|
@ -103,9 +105,7 @@ namespace Microsoft.Dotnet.Cli.Compiler.Common
|
|||
|
||||
private void WriteDepsFileAndCopyProjectDependencies(LibraryExporter exporter)
|
||||
{
|
||||
exporter
|
||||
.GetDependencies(LibraryType.Package)
|
||||
.WriteDepsTo(Path.Combine(_runtimeOutputPath, _context.ProjectFile.Name + FileNameSuffixes.Deps));
|
||||
WriteDeps(exporter);
|
||||
|
||||
var projectExports = exporter.GetDependencies(LibraryType.Project);
|
||||
CopyAssemblies(projectExports);
|
||||
|
@ -115,6 +115,36 @@ namespace Microsoft.Dotnet.Cli.Compiler.Common
|
|||
CopyAssets(packageExports);
|
||||
}
|
||||
|
||||
public void WriteDeps(LibraryExporter exporter)
|
||||
{
|
||||
var path = Path.Combine(_runtimeOutputPath, _context.ProjectFile.Name + FileNameSuffixes.Deps);
|
||||
CreateDirectoryIfNotExists(path);
|
||||
File.WriteAllLines(path, exporter
|
||||
.GetDependencies(LibraryType.Package)
|
||||
.SelectMany(GenerateLines));
|
||||
|
||||
var compilerOptions = _context.ResolveCompilationOptions(_configuration);
|
||||
var includeCompile = compilerOptions.PreserveCompilationContext == true;
|
||||
|
||||
var exports = exporter.GetAllExports().ToArray();
|
||||
var dependencyContext = new DependencyContextBuilder().Build(
|
||||
compilerOptions: includeCompile? compilerOptions: null,
|
||||
compilationExports: includeCompile ? exports : null,
|
||||
runtimeExports: exports,
|
||||
portable: string.IsNullOrEmpty(_context.RuntimeIdentifier),
|
||||
target: _context.TargetFramework,
|
||||
runtime: _context.RuntimeIdentifier ?? string.Empty);
|
||||
|
||||
var writer = new DependencyContextWriter();
|
||||
var depsJsonFile = Path.Combine(_runtimeOutputPath, _context.ProjectFile.Name + FileNameSuffixes.DepsJson);
|
||||
using (var fileStream = File.Create(depsJsonFile))
|
||||
{
|
||||
writer.Write(dependencyContext, fileStream);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void GenerateBindingRedirects(LibraryExporter exporter)
|
||||
{
|
||||
var outputName = _outputPaths.RuntimeFiles.Assembly;
|
||||
|
@ -143,5 +173,32 @@ namespace Microsoft.Dotnet.Cli.Compiler.Common
|
|||
appConfig.Save(stream);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void CreateDirectoryIfNotExists(string path)
|
||||
{
|
||||
var depsFile = new FileInfo(path);
|
||||
depsFile.Directory.Create();
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GenerateLines(LibraryExport export)
|
||||
{
|
||||
return GenerateLines(export, export.RuntimeAssemblies, "runtime")
|
||||
.Union(GenerateLines(export, export.NativeLibraries, "native"));
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GenerateLines(LibraryExport export, IEnumerable<LibraryAsset> items, string type)
|
||||
{
|
||||
return items.Select(i => DepsFormatter.EscapeRow(new[]
|
||||
{
|
||||
export.Library.Identity.Type.Value,
|
||||
export.Library.Identity.Name,
|
||||
export.Library.Identity.Version.ToNormalizedString(),
|
||||
export.Library.Hash,
|
||||
type,
|
||||
i.Name,
|
||||
i.RelativePath
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,45 +1,15 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.ProjectModel.Compilation;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
using Microsoft.Extensions.DependencyModel;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Compiler.Common
|
||||
{
|
||||
public static class LibraryExporterExtensions
|
||||
{
|
||||
public static void WriteDepsTo(this IEnumerable<LibraryExport> exports, string path)
|
||||
{
|
||||
CreateDirectoryIfNotExists(path);
|
||||
|
||||
File.WriteAllLines(path, exports.SelectMany(GenerateLines));
|
||||
}
|
||||
|
||||
private static void CreateDirectoryIfNotExists(string path)
|
||||
{
|
||||
var depsFile = new FileInfo(path);
|
||||
depsFile.Directory.Create();
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GenerateLines(LibraryExport export)
|
||||
{
|
||||
return GenerateLines(export, export.RuntimeAssemblies, "runtime")
|
||||
.Union(GenerateLines(export, export.NativeLibraries, "native"));
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GenerateLines(LibraryExport export, IEnumerable<LibraryAsset> items, string type)
|
||||
{
|
||||
return items.Select(i => DepsFormatter.EscapeRow(new[]
|
||||
{
|
||||
export.Library.Identity.Type.Value,
|
||||
export.Library.Identity.Name,
|
||||
export.Library.Identity.Version.ToNormalizedString(),
|
||||
export.Library.Hash,
|
||||
type,
|
||||
i.Name,
|
||||
i.RelativePath
|
||||
}));
|
||||
}
|
||||
|
||||
public static void CopyTo(this IEnumerable<LibraryAsset> assets, string destinationPath)
|
||||
{
|
||||
if (!Directory.Exists(destinationPath))
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using NuGet.Frameworks;
|
||||
|
@ -28,5 +30,27 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
|||
|
||||
return baseOption;
|
||||
}
|
||||
|
||||
|
||||
// used in incremental compilation for the key file
|
||||
public static CommonCompilerOptions ResolveCompilationOptions(this ProjectContext context, string configuration)
|
||||
{
|
||||
var compilationOptions = context.GetLanguageSpecificCompilerOptions(context.TargetFramework, configuration);
|
||||
|
||||
// Path to strong naming key in environment variable overrides path in project.json
|
||||
var environmentKeyFile = Environment.GetEnvironmentVariable(EnvironmentNames.StrongNameKeyFile);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(environmentKeyFile))
|
||||
{
|
||||
compilationOptions.KeyFile = environmentKeyFile;
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(compilationOptions.KeyFile))
|
||||
{
|
||||
// Resolve full path to key file
|
||||
compilationOptions.KeyFile =
|
||||
Path.GetFullPath(Path.Combine(context.ProjectFile.ProjectDirectory, compilationOptions.KeyFile));
|
||||
}
|
||||
return compilationOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,16 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
/// </summary>
|
||||
public IEnumerable<AnalyzerReference> AnalyzerReferences { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of runtime targets provided by this export.
|
||||
/// </summary>
|
||||
public IEnumerable<LibraryRuntimeTarget> RuntimeTargets { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of resource assemblies provided by this export.
|
||||
/// </summary>
|
||||
public IEnumerable<LibraryResourceAssembly> ResourceAssemblies { get; }
|
||||
|
||||
public LibraryExport(LibraryDescription library,
|
||||
IEnumerable<LibraryAsset> compileAssemblies,
|
||||
IEnumerable<LibraryAsset> sourceReferences,
|
||||
|
@ -56,7 +66,9 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
IEnumerable<LibraryAsset> runtimeAssets,
|
||||
IEnumerable<LibraryAsset> nativeLibraries,
|
||||
IEnumerable<LibraryAsset> embeddedResources,
|
||||
IEnumerable<AnalyzerReference> analyzers)
|
||||
IEnumerable<AnalyzerReference> analyzers,
|
||||
IEnumerable<LibraryRuntimeTarget> runtimeTargets,
|
||||
IEnumerable<LibraryResourceAssembly> resourceAssemblies)
|
||||
{
|
||||
Library = library;
|
||||
CompilationAssemblies = compileAssemblies;
|
||||
|
@ -66,6 +78,8 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
NativeLibraries = nativeLibraries;
|
||||
EmbeddedResources = embeddedResources;
|
||||
AnalyzerReferences = analyzers;
|
||||
RuntimeTargets = runtimeTargets;
|
||||
ResourceAssemblies = resourceAssemblies;
|
||||
}
|
||||
|
||||
private string DebuggerDisplay => Library.Identity.ToString();
|
||||
|
|
|
@ -16,8 +16,6 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
|
||||
private IList<LibraryAsset> _compilationAssets;
|
||||
|
||||
private IList<LibraryAsset> _debugAssets;
|
||||
|
||||
private IList<LibraryAsset> _sourceReferences;
|
||||
|
||||
private IList<LibraryAsset> _nativeLibraries;
|
||||
|
@ -26,6 +24,10 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
|
||||
private IList<AnalyzerReference> _analyzerReferences;
|
||||
|
||||
private IList<LibraryRuntimeTarget> _runtimeTargets;
|
||||
|
||||
private IList<LibraryResourceAssembly> _resourceAssemblies;
|
||||
|
||||
public LibraryDescription Library { get; set; }
|
||||
|
||||
public IEnumerable<LibraryAsset> RuntimeAssemblies => _runtimeAssemblies;
|
||||
|
@ -44,6 +46,10 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
|
||||
public IEnumerable<AnalyzerReference> AnalyzerReferences => _analyzerReferences;
|
||||
|
||||
public IEnumerable<LibraryRuntimeTarget> RuntimeTargets => _runtimeTargets;
|
||||
|
||||
public IEnumerable<LibraryResourceAssembly> ResourceAssemblies => _resourceAssemblies;
|
||||
|
||||
public static LibraryExportBuilder Create(LibraryDescription library = null)
|
||||
{
|
||||
return new LibraryExportBuilder().WithLibrary(library);
|
||||
|
@ -63,7 +69,9 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
RuntimeAssets ?? EmptyArray<LibraryAsset>.Value,
|
||||
NativeLibraries ?? EmptyArray<LibraryAsset>.Value,
|
||||
EmbeddedResources ?? EmptyArray<LibraryAsset>.Value,
|
||||
AnalyzerReferences ?? EmptyArray<AnalyzerReference>.Value);
|
||||
AnalyzerReferences ?? EmptyArray<AnalyzerReference>.Value,
|
||||
RuntimeTargets ?? EmptyArray<LibraryRuntimeTarget>.Value,
|
||||
ResourceAssemblies ?? EmptyArray<LibraryResourceAssembly>.Value);
|
||||
}
|
||||
|
||||
public LibraryExportBuilder WithLibrary(LibraryDescription libraryDescription)
|
||||
|
@ -89,7 +97,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
Replace(ref _compilationAssemblies, assets);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public LibraryExportBuilder WithSourceReferences(IEnumerable<LibraryAsset> assets)
|
||||
{
|
||||
Replace(ref _sourceReferences, assets);
|
||||
|
@ -114,6 +122,18 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
return this;
|
||||
}
|
||||
|
||||
public LibraryExportBuilder WithRuntimeTargets(IEnumerable<LibraryRuntimeTarget> targets)
|
||||
{
|
||||
Replace(ref _runtimeTargets, targets);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LibraryExportBuilder WithResourceAssemblies(IEnumerable<LibraryResourceAssembly> assemblies)
|
||||
{
|
||||
Replace(ref _resourceAssemblies, assemblies);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LibraryExportBuilder AddRuntimeAssembly(LibraryAsset asset)
|
||||
{
|
||||
Add(ref _runtimeAssemblies, asset);
|
||||
|
@ -156,9 +176,28 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
return this;
|
||||
}
|
||||
|
||||
public LibraryExportBuilder AddRuntimeTarget(LibraryRuntimeTarget target)
|
||||
{
|
||||
Add(ref _runtimeTargets, target);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LibraryExportBuilder AddResourceAssembly(LibraryResourceAssembly assembly)
|
||||
{
|
||||
Add(ref _resourceAssemblies, assembly);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void Replace<T>(ref IList<T> list, IEnumerable<T> enumerable)
|
||||
{
|
||||
list = new List<T>(enumerable);
|
||||
if (enumerable == null)
|
||||
{
|
||||
list = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
list = new List<T>(enumerable);
|
||||
}
|
||||
}
|
||||
|
||||
private void Add<T>(ref IList<T> list, T item)
|
||||
|
|
|
@ -122,6 +122,8 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
.WithNativeLibraries(libraryExport.NativeLibraries)
|
||||
.WithEmbedddedResources(libraryExport.EmbeddedResources)
|
||||
.WithAnalyzerReference(analyzerReferences)
|
||||
.WithResourceAssemblies(libraryExport.ResourceAssemblies)
|
||||
.WithRuntimeTargets(libraryExport.RuntimeTargets)
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
|
@ -199,6 +201,28 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
}
|
||||
}
|
||||
}
|
||||
if (package.RuntimeTargets.Any())
|
||||
{
|
||||
foreach (var targetGroup in package.RuntimeTargets.GroupBy(t => t.Runtime))
|
||||
{
|
||||
var runtime = new List<LibraryAsset>();
|
||||
var native = new List<LibraryAsset>();
|
||||
|
||||
foreach (var lockFileRuntimeTarget in targetGroup)
|
||||
{
|
||||
if (string.Equals(lockFileRuntimeTarget.AssetType, "native", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
native.Add(LibraryAsset.CreateFromRelativePath(package.Path, lockFileRuntimeTarget.Path));
|
||||
}
|
||||
else if (string.Equals(lockFileRuntimeTarget.AssetType, "runtime", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
runtime.Add(LibraryAsset.CreateFromRelativePath(package.Path, lockFileRuntimeTarget.Path));
|
||||
}
|
||||
}
|
||||
|
||||
builder.AddRuntimeTarget(new LibraryRuntimeTarget(targetGroup.Key, runtime, native));
|
||||
}
|
||||
}
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Compilation
|
||||
{
|
||||
public class LibraryResourceAssembly
|
||||
{
|
||||
public LibraryResourceAssembly(LibraryAsset asset, string locale)
|
||||
{
|
||||
Asset = asset;
|
||||
Locale = locale;
|
||||
}
|
||||
|
||||
public LibraryAsset Asset { get; }
|
||||
|
||||
public string Locale { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Compilation
|
||||
{
|
||||
public class LibraryRuntimeTarget
|
||||
{
|
||||
public LibraryRuntimeTarget(string runtime,
|
||||
IEnumerable<LibraryAsset> runtimeAssemblies,
|
||||
IEnumerable<LibraryAsset> nativeLibraries)
|
||||
{
|
||||
Runtime = runtime;
|
||||
RuntimeAssemblies = runtimeAssemblies.ToArray();
|
||||
NativeLibraries = nativeLibraries.ToArray();
|
||||
}
|
||||
|
||||
public string Runtime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of fully-qualified paths to MSIL binaries required to run
|
||||
/// </summary>
|
||||
public IReadOnlyList<LibraryAsset> RuntimeAssemblies { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of fully-qualified paths to native binaries required to run
|
||||
/// </summary>
|
||||
public IReadOnlyList<LibraryAsset> NativeLibraries { get; }
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
public DependencyContext Build(CommonCompilerOptions compilerOptions,
|
||||
IEnumerable<LibraryExport> compilationExports,
|
||||
IEnumerable<LibraryExport> runtimeExports,
|
||||
bool portable,
|
||||
NuGetFramework target,
|
||||
string runtime)
|
||||
{
|
||||
|
@ -44,13 +45,16 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
.Select(identity => new Dependency(identity.Name, identity.Version.ToString()))
|
||||
.ToDictionary(dependency => dependency.Name);
|
||||
|
||||
var compilationOptions = compilerOptions != null
|
||||
? GetCompilationOptions(compilerOptions)
|
||||
: CompilationOptions.Default;
|
||||
return new DependencyContext(
|
||||
target.DotNetFrameworkName,
|
||||
runtime,
|
||||
false,
|
||||
GetCompilationOptions(compilerOptions),
|
||||
GetLibraries(compilationExports, dependencyLookup, runtime: false).Cast<CompilationLibrary>().ToArray(),
|
||||
GetLibraries(runtimeExports, dependencyLookup, runtime: true).Cast<RuntimeLibrary>().ToArray(),
|
||||
portable,
|
||||
compilationOptions,
|
||||
GetLibraries(compilationExports, dependencyLookup, runtime: false).Cast<CompilationLibrary>(),
|
||||
GetLibraries(runtimeExports, dependencyLookup, runtime: true).Cast<RuntimeLibrary>(),
|
||||
new KeyValuePair<string, string[]>[0]);
|
||||
}
|
||||
|
||||
|
@ -84,7 +88,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
var type = export.Library.Identity.Type;
|
||||
|
||||
var serviceable = (export.Library as PackageDescription)?.Library.IsServiceable ?? false;
|
||||
var libraryDependencies = new List<Dependency>();
|
||||
var libraryDependencies = new HashSet<Dependency>();
|
||||
|
||||
var libraryAssets = runtime ? export.RuntimeAssemblies : export.CompilationAssemblies;
|
||||
|
||||
|
@ -107,14 +111,14 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
}
|
||||
}
|
||||
|
||||
string[] assemblies;
|
||||
IEnumerable<string> assemblies;
|
||||
if (type == LibraryType.ReferenceAssembly)
|
||||
{
|
||||
assemblies = ResolveReferenceAssembliesPath(libraryAssets);
|
||||
}
|
||||
else
|
||||
{
|
||||
assemblies = libraryAssets.Select(libraryAsset => libraryAsset.RelativePath).ToArray();
|
||||
assemblies = libraryAssets.Select(libraryAsset => libraryAsset.RelativePath);
|
||||
}
|
||||
|
||||
if (runtime)
|
||||
|
@ -124,9 +128,10 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
export.Library.Identity.Name,
|
||||
export.Library.Identity.Version.ToString(),
|
||||
export.Library.Hash,
|
||||
assemblies.Select(RuntimeAssembly.Create).ToArray(),
|
||||
new RuntimeTarget[0],
|
||||
libraryDependencies.ToArray(),
|
||||
assemblies.Select(RuntimeAssembly.Create),
|
||||
export.ResourceAssemblies.Select(CreateResourceAssembly),
|
||||
export.RuntimeTargets.Select(CreateRuntimeTarget),
|
||||
libraryDependencies,
|
||||
serviceable
|
||||
);
|
||||
}
|
||||
|
@ -138,15 +143,31 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
export.Library.Identity.Version.ToString(),
|
||||
export.Library.Hash,
|
||||
assemblies,
|
||||
libraryDependencies.ToArray(),
|
||||
libraryDependencies,
|
||||
serviceable
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private string[] ResolveReferenceAssembliesPath(IEnumerable<LibraryAsset> libraryAssets)
|
||||
private ResourceAssembly CreateResourceAssembly(LibraryResourceAssembly resourceAssembly)
|
||||
{
|
||||
return new ResourceAssembly(
|
||||
path: resourceAssembly.Asset.RelativePath,
|
||||
locale: resourceAssembly.Locale
|
||||
);
|
||||
}
|
||||
|
||||
private RuntimeTarget CreateRuntimeTarget(LibraryRuntimeTarget runtimeTarget)
|
||||
{
|
||||
return new RuntimeTarget(
|
||||
runtime: runtimeTarget.Runtime,
|
||||
assemblies: runtimeTarget.RuntimeAssemblies.Select(a => RuntimeAssembly.Create(a.RelativePath)),
|
||||
nativeLibraries: runtimeTarget.NativeLibraries.Select(l => l.RelativePath)
|
||||
);
|
||||
}
|
||||
|
||||
private IEnumerable<string> ResolveReferenceAssembliesPath(IEnumerable<LibraryAsset> libraryAssets)
|
||||
{
|
||||
var resolvedPaths = new List<string>();
|
||||
var referenceAssembliesPath =
|
||||
PathUtility.EnsureTrailingSlash(_referenceAssembliesPath);
|
||||
foreach (var libraryAsset in libraryAssets)
|
||||
|
@ -155,14 +176,13 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
// if not, save only assembly name and try to find it somehow later
|
||||
if (libraryAsset.ResolvedPath.StartsWith(referenceAssembliesPath))
|
||||
{
|
||||
resolvedPaths.Add(libraryAsset.ResolvedPath.Substring(referenceAssembliesPath.Length));
|
||||
yield return libraryAsset.ResolvedPath.Substring(referenceAssembliesPath.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
resolvedPaths.Add(Path.GetFileName(libraryAsset.ResolvedPath));
|
||||
yield return Path.GetFileName(libraryAsset.ResolvedPath);
|
||||
}
|
||||
}
|
||||
return resolvedPaths.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
public static class FileNameSuffixes
|
||||
{
|
||||
public const string Deps = ".deps";
|
||||
public const string DepsJson = ".deps.json";
|
||||
|
||||
public static PlatformFileNameSuffixes CurrentPlatform
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Microsoft.DotNet.ProjectModel.Graph
|
|||
{
|
||||
public static LockFile Read(string lockFilePath)
|
||||
{
|
||||
using (var stream = new FileStream(lockFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
using (var stream = ResilientFileStreamOpener.OpenFile(lockFilePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ namespace Microsoft.DotNet.ProjectModel.Graph
|
|||
}
|
||||
}
|
||||
|
||||
internal static LockFile Read(string lockFilePath, Stream stream)
|
||||
public static LockFile Read(string lockFilePath, Stream stream)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -167,9 +167,25 @@ namespace Microsoft.DotNet.ProjectModel.Graph
|
|||
library.ResourceAssemblies = ReadObject(jobject.ValueAsJsonObject("resource"), ReadFileItem);
|
||||
library.NativeLibraries = ReadObject(jobject.ValueAsJsonObject("native"), ReadFileItem);
|
||||
library.ContentFiles = ReadObject(jobject.ValueAsJsonObject("contentFiles"), ReadContentFile);
|
||||
library.RuntimeTargets = ReadObject(jobject.ValueAsJsonObject("runtimeTargets"), ReadRuntimeTarget);
|
||||
return library;
|
||||
}
|
||||
|
||||
private static LockFileRuntimeTarget ReadRuntimeTarget(string property, JsonValue json)
|
||||
{
|
||||
var jsonObject = json as JsonObject;
|
||||
if (jsonObject == null)
|
||||
{
|
||||
throw FileFormatException.Create("The value type is not an object.", json);
|
||||
}
|
||||
|
||||
return new LockFileRuntimeTarget(
|
||||
path: property,
|
||||
runtime: jsonObject.ValueAsString("rid"),
|
||||
assetType: jsonObject.ValueAsString("assetType")
|
||||
);
|
||||
}
|
||||
|
||||
private static LockFileContentFile ReadContentFile(string property, JsonValue json)
|
||||
{
|
||||
var contentFile = new LockFileContentFile()
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Graph
|
||||
{
|
||||
public class LockFileRuntimeTarget
|
||||
{
|
||||
public LockFileRuntimeTarget(string path, string runtime, string assetType)
|
||||
{
|
||||
Path = path;
|
||||
Runtime = runtime;
|
||||
AssetType = assetType;
|
||||
}
|
||||
|
||||
public string Path { get; }
|
||||
|
||||
public string Runtime { get; }
|
||||
|
||||
public string AssetType { get; }
|
||||
}
|
||||
}
|
|
@ -32,5 +32,7 @@ namespace Microsoft.DotNet.ProjectModel.Graph
|
|||
public IList<LockFileItem> NativeLibraries { get; set; } = new List<LockFileItem>();
|
||||
|
||||
public IList<LockFileContentFile> ContentFiles { get; set; } = new List<LockFileContentFile>();
|
||||
|
||||
public IList<LockFileRuntimeTarget> RuntimeTargets { get; set; } = new List<LockFileRuntimeTarget>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,12 +48,18 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
{
|
||||
if (!string.IsNullOrEmpty(runtimeIdentifier))
|
||||
{
|
||||
runtimeOutputPath= PathUtility.EnsureTrailingSlash(Path.Combine(compilationOutputPath, runtimeIdentifier));
|
||||
runtimeOutputPath = PathUtility.EnsureTrailingSlash(Path.Combine(compilationOutputPath, runtimeIdentifier));
|
||||
}
|
||||
else
|
||||
{
|
||||
// "Runtime" assets (i.e. the deps file) will be dropped to the compilation output path, because
|
||||
// we are building a RID-less target.
|
||||
runtimeOutputPath = compilationOutputPath;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
runtimeOutputPath= PathUtility.EnsureTrailingSlash(Path.GetFullPath(outputPath));
|
||||
runtimeOutputPath = PathUtility.EnsureTrailingSlash(Path.GetFullPath(outputPath));
|
||||
}
|
||||
|
||||
var intermediateOutputPath = PathUtility.EnsureTrailingSlash(Path.Combine(
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
}
|
||||
|
||||
private LockFileTargetLibrary Target { get; }
|
||||
|
||||
|
||||
public LockFilePackageLibrary Library { get; }
|
||||
|
||||
public IEnumerable<LockFileItem> RuntimeAssemblies => FilterPlaceholders(Target.RuntimeAssemblies);
|
||||
|
@ -45,6 +45,8 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
|
||||
public IEnumerable<LockFileContentFile> ContentFiles => Target.ContentFiles;
|
||||
|
||||
public IEnumerable<LockFileRuntimeTarget> RuntimeTargets => Target.RuntimeTargets;
|
||||
|
||||
private IEnumerable<LockFileItem> FilterPlaceholders(IList<LockFileItem> items)
|
||||
{
|
||||
return items.Where(a => !PackageDependencyProvider.IsPlaceholderFile(a));
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
return Path.GetDirectoryName(ProjectFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public AnalyzerOptions AnalyzerOptions { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
@ -124,12 +124,12 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
|
||||
public bool HasRuntimeOutput(string configuration)
|
||||
{
|
||||
|
||||
var compilationOptions = GetCompilerOptions(targetFramework: null, configurationName: configuration);
|
||||
|
||||
// TODO: Make this opt in via another mechanism
|
||||
return compilationOptions.EmitEntryPoint.GetValueOrDefault() || IsTestProject;
|
||||
}
|
||||
|
||||
private CommonCompilerOptions GetCompilerOptions()
|
||||
{
|
||||
return _defaultCompilerOptions;
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
.WithRuntimeIdentifiers(runtimeIdentifiers)
|
||||
.Build();
|
||||
}
|
||||
|
||||
|
||||
public static ProjectContextBuilder CreateBuilder(string projectPath, NuGetFramework framework)
|
||||
{
|
||||
if (projectPath.EndsWith(Project.FileName))
|
||||
|
@ -120,15 +120,12 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
/// <summary>
|
||||
/// Creates a project context for each target located in the project at <paramref name="projectPath"/>
|
||||
/// </summary>
|
||||
public static IEnumerable<ProjectContext> CreateContextForEachTarget(string projectPath)
|
||||
public static IEnumerable<ProjectContext> CreateContextForEachTarget(string projectPath, ProjectReaderSettings settings = null)
|
||||
{
|
||||
if (!projectPath.EndsWith(Project.FileName))
|
||||
{
|
||||
projectPath = Path.Combine(projectPath, Project.FileName);
|
||||
}
|
||||
var project = ProjectReader.GetProject(projectPath);
|
||||
|
||||
return new ProjectContextBuilder()
|
||||
.WithReaderSettings(settings)
|
||||
.WithProject(project)
|
||||
.BuildAllTargets();
|
||||
}
|
||||
|
@ -143,15 +140,20 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
|
||||
public ProjectContext CreateRuntimeContext(IEnumerable<string> runtimeIdentifiers)
|
||||
{
|
||||
var context = Create(ProjectFile.ProjectFilePath, TargetFramework, runtimeIdentifiers);
|
||||
if (context.RuntimeIdentifier == null)
|
||||
// Check if there are any runtime targets (i.e. are we portable)
|
||||
var standalone = LockFile.Targets
|
||||
.Where(t => t.TargetFramework.Equals(TargetFramework))
|
||||
.Any(t => !string.IsNullOrEmpty(t.RuntimeIdentifier));
|
||||
|
||||
var context = Create(ProjectFile.ProjectFilePath, TargetFramework, standalone ? runtimeIdentifiers : Enumerable.Empty<string>());
|
||||
if (standalone && context.RuntimeIdentifier == null)
|
||||
{
|
||||
// We are standalone, but don't support this runtime
|
||||
var rids = string.Join(", ", runtimeIdentifiers);
|
||||
throw new InvalidOperationException($"Can not find runtime target for framework '{TargetFramework}' and RID's '{rids}'. " +
|
||||
throw new InvalidOperationException($"Can not find runtime target for framework '{TargetFramework}' compatible with one of the target runtimes: '{rids}'. " +
|
||||
"Possible causes:" + Environment.NewLine +
|
||||
"1. Project is not restored or restore failed - run `dotnet restore`" + Environment.NewLine +
|
||||
"2. Project is not targeting `runable` framework (`netstandardapp*` or `net*`)"
|
||||
);
|
||||
"1. The project has not been restored or restore failed - run `dotnet restore`" + Environment.NewLine +
|
||||
$"2. The project does not list one of '{rids}' in the 'runtimes' section.");
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
|
|
@ -61,18 +61,20 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
return true;
|
||||
}
|
||||
|
||||
public static Project GetProject(string projectFile, ProjectReaderSettings settings = null)
|
||||
{
|
||||
return GetProject(projectFile, new List<DiagnosticMessage>(), settings);
|
||||
}
|
||||
public static Project GetProject(string projectPath, ProjectReaderSettings settings = null) => GetProject(projectPath, new List<DiagnosticMessage>(), settings);
|
||||
|
||||
public static Project GetProject(string projectFile, ICollection<DiagnosticMessage> diagnostics, ProjectReaderSettings settings = null)
|
||||
public static Project GetProject(string projectPath, ICollection<DiagnosticMessage> diagnostics, ProjectReaderSettings settings = null)
|
||||
{
|
||||
var name = Path.GetFileName(Path.GetDirectoryName(projectFile));
|
||||
|
||||
using (var stream = new FileStream(projectFile, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
if (!projectPath.EndsWith(Project.FileName))
|
||||
{
|
||||
return new ProjectReader().ReadProject(stream, name, projectFile, diagnostics, settings);
|
||||
projectPath = Path.Combine(projectPath, Project.FileName);
|
||||
}
|
||||
|
||||
var name = Path.GetFileName(Path.GetDirectoryName(projectPath));
|
||||
|
||||
using (var stream = new FileStream(projectPath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
return new ProjectReader().ReadProject(stream, name, projectPath, diagnostics, settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -546,7 +548,8 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
analyzerOptions.LanguageId = languageId;
|
||||
break;
|
||||
|
||||
default:;
|
||||
default:
|
||||
;
|
||||
throw FileFormatException.Create(
|
||||
$"Unrecognized analyzerOption key: {key}",
|
||||
project.ProjectFilePath);
|
||||
|
|
|
@ -39,6 +39,13 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
return Path.ChangeExtension(Assembly, FileNameSuffixes.Deps);
|
||||
}
|
||||
}
|
||||
public string DepsJson
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.ChangeExtension(Assembly, FileNameSuffixes.DepsJson);
|
||||
}
|
||||
}
|
||||
|
||||
public string Config
|
||||
{
|
||||
|
@ -61,6 +68,11 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
{
|
||||
yield return Deps;
|
||||
}
|
||||
|
||||
if (File.Exists(DepsJson))
|
||||
{
|
||||
yield return DepsJson;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Utilities
|
||||
{
|
||||
public class ResilientFileStreamOpener
|
||||
{
|
||||
public static FileStream OpenFile(string filepath)
|
||||
{
|
||||
return OpenFile(filepath, 0);
|
||||
}
|
||||
|
||||
public static FileStream OpenFile(string filepath, int retry)
|
||||
{
|
||||
if (retry < 0)
|
||||
{
|
||||
throw new ArgumentException("Retry can't be fewer than 0", nameof(retry));
|
||||
}
|
||||
|
||||
var count = 0;
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (++count > retry)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
using Microsoft.DotNet.ProjectModel.Utilities;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel
|
||||
{
|
||||
|
@ -205,8 +206,23 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
else
|
||||
{
|
||||
currentEntry.FilePath = Path.Combine(projectDirectory, LockFile.FileName);
|
||||
currentEntry.Model = LockFileReader.Read(currentEntry.FilePath);
|
||||
currentEntry.UpdateLastWriteTimeUtc();
|
||||
|
||||
using (var fs = ResilientFileStreamOpener.OpenFile(currentEntry.FilePath, retry: 2))
|
||||
{
|
||||
try
|
||||
{
|
||||
currentEntry.Model = LockFileReader.Read(currentEntry.FilePath, fs);
|
||||
currentEntry.UpdateLastWriteTimeUtc();
|
||||
}
|
||||
catch (FileFormatException ex)
|
||||
{
|
||||
throw ex.WithFilePath(currentEntry.FilePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw FileFormatException.Create(ex, currentEntry.FilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"description": "Types to model a .NET Project",
|
||||
"dependencies": {
|
||||
"System.Reflection.Metadata": "1.2.0-rc2-23901",
|
||||
"NuGet.Packaging": "3.4.0-beta-632",
|
||||
"NuGet.Packaging": "3.4.0-rtm-0733",
|
||||
"Microsoft.Extensions.FileSystemGlobbing": "1.0.0-rc2-15996",
|
||||
"Microsoft.Extensions.JsonParser.Sources": {
|
||||
"type": "build",
|
||||
|
|
|
@ -3,16 +3,23 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.DependencyModel.Resolution;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyModel
|
||||
{
|
||||
public class CompilationLibrary : Library
|
||||
{
|
||||
public CompilationLibrary(string type, string name, string version, string hash, string[] assemblies, Dependency[] dependencies, bool serviceable)
|
||||
public CompilationLibrary(string type,
|
||||
string name,
|
||||
string version,
|
||||
string hash,
|
||||
IEnumerable<string> assemblies,
|
||||
IEnumerable<Dependency> dependencies,
|
||||
bool serviceable)
|
||||
: base(type, name, version, hash, dependencies, serviceable)
|
||||
{
|
||||
Assemblies = assemblies;
|
||||
Assemblies = assemblies.ToArray();
|
||||
}
|
||||
|
||||
public IReadOnlyList<string> Assemblies { get; }
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
{
|
||||
public class DependencyContext
|
||||
{
|
||||
private const string DepsResourceSufix = ".deps.json";
|
||||
private const string DepsJsonExtension = ".deps.json";
|
||||
private const string DepsFileExtension = ".deps";
|
||||
|
||||
private static readonly Lazy<DependencyContext> _defaultContext = new Lazy<DependencyContext>(LoadDefault);
|
||||
|
@ -32,10 +32,6 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
{
|
||||
throw new ArgumentNullException(nameof(runtime));
|
||||
}
|
||||
if (compilationOptions == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(compilationOptions));
|
||||
}
|
||||
if (compileLibraries == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(compileLibraries));
|
||||
|
@ -87,7 +83,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
throw new ArgumentNullException(nameof(assembly));
|
||||
}
|
||||
|
||||
using (var stream = assembly.GetManifestResourceStream(assembly.GetName().Name + DepsResourceSufix))
|
||||
using (var stream = assembly.GetManifestResourceStream(assembly.GetName().Name + DepsJsonExtension))
|
||||
{
|
||||
if (stream != null)
|
||||
{
|
||||
|
@ -95,6 +91,15 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
}
|
||||
}
|
||||
|
||||
var depsJsonFile = Path.ChangeExtension(assembly.Location, DepsJsonExtension);
|
||||
if (File.Exists(depsJsonFile))
|
||||
{
|
||||
using (var stream = File.OpenRead(depsJsonFile))
|
||||
{
|
||||
return new DependencyContextJsonReader().Read(stream);
|
||||
}
|
||||
}
|
||||
|
||||
var depsFile = Path.ChangeExtension(assembly.Location, DepsFileExtension);
|
||||
if (File.Exists(depsFile))
|
||||
{
|
||||
|
|
|
@ -46,9 +46,10 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
name: identity.Item2,
|
||||
version: identity.Item3,
|
||||
hash: identity.Item4,
|
||||
assemblies: packageGroup.Select(l => RuntimeAssembly.Create(l.AssetPath)).ToArray(),
|
||||
subTargets: new RuntimeTarget[0],
|
||||
dependencies: new Dependency[] { },
|
||||
assemblies: packageGroup.Select(l => RuntimeAssembly.Create(l.AssetPath)),
|
||||
resourceAssemblies: Enumerable.Empty<ResourceAssembly>(),
|
||||
subTargets: Enumerable.Empty<RuntimeTarget>(),
|
||||
dependencies: Enumerable.Empty<Dependency>(),
|
||||
serviceable: false
|
||||
));
|
||||
}
|
||||
|
@ -58,9 +59,9 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
runtime: string.Empty,
|
||||
isPortable: false,
|
||||
compilationOptions: CompilationOptions.Default,
|
||||
compileLibraries: new CompilationLibrary[] {},
|
||||
compileLibraries: Enumerable.Empty<CompilationLibrary>(),
|
||||
runtimeLibraries: runtimeLibraries.ToArray(),
|
||||
runtimeGraph: new KeyValuePair<string, string[]>[0]);
|
||||
runtimeGraph: Enumerable.Empty<KeyValuePair<string, string[]>>());
|
||||
}
|
||||
|
||||
private Tuple<string, string, string, string> PackageIdentity(DepsFileLine line)
|
||||
|
|
|
@ -173,7 +173,18 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
.Select(RuntimeAssembly.Create)
|
||||
.ToArray();
|
||||
|
||||
return new RuntimeLibrary(stub.Type, name, version, stub.Hash, assemblies, runtimeTargets.ToArray(), dependencies, stub.Serviceable);
|
||||
var resourceAssemblies = ReadResourceAssemblies((JObject)libraryObject[DependencyContextStrings.ResourceAssembliesPropertyName]);
|
||||
|
||||
return new RuntimeLibrary(
|
||||
type: stub.Type,
|
||||
name: name,
|
||||
version: version,
|
||||
hash: stub.Hash,
|
||||
assemblies: assemblies,
|
||||
resourceAssemblies: resourceAssemblies,
|
||||
subTargets: runtimeTargets.ToArray(),
|
||||
dependencies: dependencies,
|
||||
serviceable: stub.Serviceable);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -182,6 +193,21 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
}
|
||||
}
|
||||
|
||||
private IEnumerable<ResourceAssembly> ReadResourceAssemblies(JObject resourcesObject)
|
||||
{
|
||||
if (resourcesObject == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
foreach (var resourceProperty in resourcesObject)
|
||||
{
|
||||
yield return new ResourceAssembly(
|
||||
locale: resourceProperty.Value[DependencyContextStrings.LocalePropertyName]?.Value<string>(),
|
||||
path: resourceProperty.Key
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<RuntimeTargetEntryStub> ReadRuntimeTargetEntries(JObject runtimeTargetObject)
|
||||
{
|
||||
if (runtimeTargetObject == null)
|
||||
|
|
|
@ -66,5 +66,9 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
internal const string RuntimeAssetType = "runtime";
|
||||
|
||||
internal const string NativeAssetType = "native";
|
||||
|
||||
internal const string ResourceAssembliesPropertyName = "resources";
|
||||
|
||||
internal const string LocalePropertyName = "locale";
|
||||
}
|
||||
}
|
|
@ -27,13 +27,17 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
|
||||
private JObject Write(DependencyContext context)
|
||||
{
|
||||
return new JObject(
|
||||
var contextObject = new JObject(
|
||||
new JProperty(DependencyContextStrings.RuntimeTargetPropertyName, WriteRuntimeTargetInfo(context)),
|
||||
new JProperty(DependencyContextStrings.CompilationOptionsPropertName, WriteCompilationOptions(context.CompilationOptions)),
|
||||
new JProperty(DependencyContextStrings.TargetsPropertyName, WriteTargets(context)),
|
||||
new JProperty(DependencyContextStrings.LibrariesPropertyName, WriteLibraries(context)),
|
||||
new JProperty(DependencyContextStrings.RuntimesPropertyName, WriteRuntimeGraph(context))
|
||||
new JProperty(DependencyContextStrings.LibrariesPropertyName, WriteLibraries(context))
|
||||
);
|
||||
if (context.RuntimeGraph.Any())
|
||||
{
|
||||
contextObject.Add(new JProperty(DependencyContextStrings.RuntimesPropertyName, WriteRuntimeGraph(context)));
|
||||
}
|
||||
return contextObject;
|
||||
}
|
||||
|
||||
private string WriteRuntimeTargetInfo(DependencyContext context)
|
||||
|
@ -46,18 +50,14 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
private JObject WriteRuntimeGraph(DependencyContext context)
|
||||
{
|
||||
return new JObject(
|
||||
new JProperty(context.TargetFramework,
|
||||
new JObject(
|
||||
context.RuntimeGraph.Select(g => new JProperty(g.Key, new JArray(g.Value)))
|
||||
)
|
||||
)
|
||||
context.RuntimeGraph.Select(g => new JProperty(g.Key, new JArray(g.Value)))
|
||||
);
|
||||
}
|
||||
|
||||
private JObject WriteCompilationOptions(CompilationOptions compilationOptions)
|
||||
{
|
||||
var o = new JObject();
|
||||
if (compilationOptions.Defines != null)
|
||||
if (compilationOptions.Defines?.Any() == true)
|
||||
{
|
||||
o[DependencyContextStrings.DefinesPropertyName] = new JArray(compilationOptions.Defines);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
AddPropertyIfNotNull(o, DependencyContextStrings.GenerateXmlDocumentationPropertyName, compilationOptions.GenerateXmlDocumentation);
|
||||
AddPropertyIfNotNull(o, DependencyContextStrings.DebugTypePropertyName, compilationOptions.DebugType);
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddPropertyIfNotNull<T>(JObject o, string name, T value)
|
||||
{
|
||||
|
@ -140,49 +140,86 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
return targetObject;
|
||||
}
|
||||
|
||||
private void AddCompilationAssemblies(JObject libraryObject, IEnumerable<string> compilationAssemblies)
|
||||
{
|
||||
if (!compilationAssemblies.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
libraryObject.Add(new JProperty(DependencyContextStrings.CompileTimeAssembliesKey,
|
||||
WriteAssemblies(compilationAssemblies))
|
||||
);
|
||||
}
|
||||
|
||||
private void AddRuntimeAssemblies(JObject libraryObject, IEnumerable<RuntimeAssembly> runtimeAssemblies)
|
||||
{
|
||||
if (!runtimeAssemblies.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
libraryObject.Add(new JProperty(DependencyContextStrings.RuntimeAssembliesKey,
|
||||
WriteAssemblies(runtimeAssemblies.Select(a => a.Path)))
|
||||
);
|
||||
}
|
||||
|
||||
private void AddDependencies(JObject libraryObject, IEnumerable<Dependency> dependencies)
|
||||
{
|
||||
if (!dependencies.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
libraryObject.Add(
|
||||
new JProperty(DependencyContextStrings.DependenciesPropertyName,
|
||||
new JObject(
|
||||
dependencies.Select(dependency => new JProperty(dependency.Name, dependency.Version))))
|
||||
);
|
||||
}
|
||||
|
||||
private void AddResourceAssemblies(JObject libraryObject, IEnumerable<ResourceAssembly> resourceAssemblies)
|
||||
{
|
||||
if (!resourceAssemblies.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
libraryObject.Add(DependencyContextStrings.ResourceAssembliesPropertyName,
|
||||
new JObject(resourceAssemblies.Select(a =>
|
||||
new JProperty(NormalizePath(a.Path), new JObject(new JProperty(DependencyContextStrings.LocalePropertyName, a.Locale))))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private JObject WriteTargetLibrary(Library library)
|
||||
{
|
||||
string propertyName;
|
||||
string[] assemblies;
|
||||
|
||||
var runtimeLibrary = library as RuntimeLibrary;
|
||||
if (runtimeLibrary != null)
|
||||
{
|
||||
propertyName = DependencyContextStrings.RuntimeAssembliesKey;
|
||||
assemblies = runtimeLibrary.Assemblies.Select(assembly => assembly.Path).ToArray();
|
||||
var libraryObject = new JObject();
|
||||
AddDependencies(libraryObject, runtimeLibrary.Dependencies);
|
||||
AddRuntimeAssemblies(libraryObject, runtimeLibrary.Assemblies);
|
||||
AddResourceAssemblies(libraryObject, runtimeLibrary.ResourceAssemblies);
|
||||
return libraryObject;
|
||||
}
|
||||
else
|
||||
|
||||
var compilationLibrary = library as CompilationLibrary;
|
||||
if (compilationLibrary != null)
|
||||
{
|
||||
var compilationLibrary = library as CompilationLibrary;
|
||||
if (compilationLibrary != null)
|
||||
{
|
||||
propertyName = DependencyContextStrings.CompileTimeAssembliesKey;
|
||||
assemblies = compilationLibrary.Assemblies.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
var libraryObject = new JObject();
|
||||
AddDependencies(libraryObject, compilationLibrary.Dependencies);
|
||||
AddCompilationAssemblies(libraryObject, compilationLibrary.Assemblies);
|
||||
return libraryObject;
|
||||
}
|
||||
|
||||
|
||||
return new JObject(
|
||||
new JProperty(DependencyContextStrings.DependenciesPropertyName, WriteDependencies(library.Dependencies)),
|
||||
new JProperty(propertyName,
|
||||
WriteAssemblies(assemblies))
|
||||
);
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
private JObject WritePortableTargetLibrary(RuntimeLibrary runtimeLibrary, CompilationLibrary compilationLibrary)
|
||||
{
|
||||
var libraryObject = new JObject();
|
||||
var dependencies = new HashSet<Dependency>();
|
||||
|
||||
var libraryObject = new JObject();
|
||||
|
||||
var dependencies = new HashSet<Dependency>();
|
||||
if (runtimeLibrary != null)
|
||||
{
|
||||
libraryObject.Add(new JProperty(DependencyContextStrings.RuntimeAssembliesKey,
|
||||
WriteAssemblies(runtimeLibrary.Assemblies.Select(a => a.Path)))
|
||||
);
|
||||
|
||||
if (runtimeLibrary.RuntimeTargets.Any())
|
||||
{
|
||||
libraryObject.Add(new JProperty(
|
||||
|
@ -190,21 +227,20 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
new JObject(runtimeLibrary.RuntimeTargets.SelectMany(WriteRuntimeTarget)))
|
||||
);
|
||||
}
|
||||
AddResourceAssemblies(libraryObject, runtimeLibrary.ResourceAssemblies);
|
||||
AddRuntimeAssemblies(libraryObject, runtimeLibrary.Assemblies);
|
||||
|
||||
dependencies.UnionWith(runtimeLibrary.Dependencies);
|
||||
}
|
||||
|
||||
if (compilationLibrary != null)
|
||||
{
|
||||
libraryObject.Add(new JProperty(DependencyContextStrings.CompileTimeAssembliesKey,
|
||||
WriteAssemblies(compilationLibrary.Assemblies))
|
||||
);
|
||||
AddCompilationAssemblies(libraryObject, compilationLibrary.Assemblies);
|
||||
|
||||
dependencies.UnionWith(compilationLibrary.Dependencies);
|
||||
}
|
||||
|
||||
libraryObject.Add(
|
||||
new JProperty(DependencyContextStrings.DependenciesPropertyName, WriteDependencies(dependencies)));
|
||||
|
||||
AddDependencies(libraryObject, dependencies);
|
||||
return libraryObject;
|
||||
}
|
||||
|
||||
|
@ -227,7 +263,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
{
|
||||
foreach (var assembly in assemblies)
|
||||
{
|
||||
yield return new JProperty(assembly,
|
||||
yield return new JProperty(NormalizePath(assembly),
|
||||
new JObject(
|
||||
new JProperty(DependencyContextStrings.RidPropertyName, runtime),
|
||||
new JProperty(DependencyContextStrings.AssetTypePropertyName, assetType)
|
||||
|
@ -238,14 +274,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
|
||||
private JObject WriteAssemblies(IEnumerable<string> assemblies)
|
||||
{
|
||||
return new JObject(assemblies.Select(assembly => new JProperty(assembly, new JObject())));
|
||||
}
|
||||
|
||||
private JObject WriteDependencies(IEnumerable<Dependency> dependencies)
|
||||
{
|
||||
return new JObject(
|
||||
dependencies.Select(dependency => new JProperty(dependency.Name, dependency.Version))
|
||||
);
|
||||
return new JObject(assemblies.Select(assembly => new JProperty(NormalizePath(assembly), new JObject())));
|
||||
}
|
||||
|
||||
private JObject WriteLibraries(DependencyContext context)
|
||||
|
@ -265,5 +294,10 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
new JProperty(DependencyContextStrings.Sha512PropertyName, library.Hash)
|
||||
);
|
||||
}
|
||||
|
||||
private string NormalizePath(string path)
|
||||
{
|
||||
return path.Replace('\\', '/');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyModel
|
||||
{
|
||||
public class Library
|
||||
{
|
||||
public Library(string type, string name, string version, string hash, Dependency[] dependencies, bool serviceable)
|
||||
public Library(string type, string name, string version, string hash, IEnumerable<Dependency> dependencies, bool serviceable)
|
||||
{
|
||||
Type = type;
|
||||
Name = name;
|
||||
Version = version;
|
||||
Hash = hash;
|
||||
Dependencies = dependencies;
|
||||
Dependencies = dependencies.ToArray();
|
||||
Serviceable = serviceable;
|
||||
}
|
||||
|
||||
|
|
19
src/Microsoft.Extensions.DependencyModel/ResourceAssembly.cs
Normal file
19
src/Microsoft.Extensions.DependencyModel/ResourceAssembly.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.Extensions.DependencyModel
|
||||
{
|
||||
public class ResourceAssembly
|
||||
{
|
||||
public ResourceAssembly(string path, string locale)
|
||||
{
|
||||
Locale = locale;
|
||||
Path = path;
|
||||
}
|
||||
|
||||
public string Locale { get; set; }
|
||||
|
||||
public string Path { get; set; }
|
||||
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
|
@ -8,6 +10,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
{
|
||||
public class RuntimeAssembly
|
||||
{
|
||||
private const string NativeImageSufix = ".ni";
|
||||
private readonly string _assemblyName;
|
||||
|
||||
public RuntimeAssembly(string assemblyName, string path)
|
||||
|
@ -22,7 +25,17 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
|
||||
public static RuntimeAssembly Create(string path)
|
||||
{
|
||||
return new RuntimeAssembly(System.IO.Path.GetFileNameWithoutExtension(path), path);
|
||||
var assemblyName = System.IO.Path.GetFileNameWithoutExtension(path);
|
||||
if (assemblyName == null)
|
||||
{
|
||||
throw new ArgumentException($"Provided path has empty file name '{path}'", nameof(path));
|
||||
}
|
||||
|
||||
if (assemblyName.EndsWith(NativeImageSufix))
|
||||
{
|
||||
assemblyName = assemblyName.Substring(0, assemblyName.Length - NativeImageSufix.Length);
|
||||
}
|
||||
return new RuntimeAssembly(assemblyName, path);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,18 +13,22 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
string name,
|
||||
string version,
|
||||
string hash,
|
||||
RuntimeAssembly[] assemblies,
|
||||
RuntimeTarget[] subTargets,
|
||||
Dependency[] dependencies,
|
||||
IEnumerable<RuntimeAssembly> assemblies,
|
||||
IEnumerable<ResourceAssembly> resourceAssemblies,
|
||||
IEnumerable<RuntimeTarget> subTargets,
|
||||
IEnumerable<Dependency> dependencies,
|
||||
bool serviceable)
|
||||
: base(type, name, version, hash, dependencies, serviceable)
|
||||
{
|
||||
Assemblies = assemblies;
|
||||
RuntimeTargets = subTargets;
|
||||
Assemblies = assemblies.ToArray();
|
||||
ResourceAssemblies = resourceAssemblies.ToArray();
|
||||
RuntimeTargets = subTargets.ToArray();
|
||||
}
|
||||
|
||||
public IReadOnlyList<RuntimeAssembly> Assemblies { get; }
|
||||
|
||||
public IReadOnlyList<ResourceAssembly> ResourceAssemblies { get; }
|
||||
|
||||
public IReadOnlyList<RuntimeTarget> RuntimeTargets { get; }
|
||||
}
|
||||
}
|
|
@ -1,14 +1,15 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyModel
|
||||
{
|
||||
public class RuntimeTarget
|
||||
{
|
||||
public RuntimeTarget(string runtime, IReadOnlyList<RuntimeAssembly> assemblies, IReadOnlyList<string> nativeLibraries)
|
||||
public RuntimeTarget(string runtime, IEnumerable<RuntimeAssembly> assemblies, IEnumerable<string> nativeLibraries)
|
||||
{
|
||||
Runtime = runtime;
|
||||
Assemblies = assemblies;
|
||||
NativeLibraries = nativeLibraries;
|
||||
Assemblies = assemblies.ToArray();
|
||||
NativeLibraries = nativeLibraries.ToArray();
|
||||
}
|
||||
|
||||
public string Runtime { get; }
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
{
|
||||
CreateOutputDirectories();
|
||||
|
||||
return CompileDendencies(incremental) && CompileRootProject(incremental);
|
||||
return CompileDependencies(incremental) && CompileRootProject(incremental);
|
||||
}
|
||||
|
||||
private bool CompileRootProject(bool incremental)
|
||||
|
@ -66,7 +66,7 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
return success;
|
||||
}
|
||||
|
||||
private bool CompileDendencies(bool incremental)
|
||||
private bool CompileDependencies(bool incremental)
|
||||
{
|
||||
if (_args.ShouldSkipDependencies)
|
||||
{
|
||||
|
@ -395,15 +395,7 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
|
||||
if (succeeded)
|
||||
{
|
||||
if (_rootProject.ProjectFile.HasRuntimeOutput(_args.ConfigValue))
|
||||
{
|
||||
MakeRunnable();
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(_args.OutputValue))
|
||||
{
|
||||
var outputPaths = _rootProject.GetOutputPaths(_args.ConfigValue, _args.BuildBasePathValue, _args.OutputValue);
|
||||
CopyCompilationOutput(outputPaths);
|
||||
}
|
||||
MakeRunnable();
|
||||
}
|
||||
|
||||
return succeeded;
|
||||
|
@ -428,10 +420,23 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
private void MakeRunnable()
|
||||
{
|
||||
var runtimeContext = _rootProject.CreateRuntimeContext(_args.GetRuntimes());
|
||||
if(_args.PortableMode)
|
||||
{
|
||||
// HACK: Force the use of the portable target
|
||||
runtimeContext = _rootProject;
|
||||
}
|
||||
|
||||
var outputPaths = runtimeContext.GetOutputPaths(_args.ConfigValue, _args.BuildBasePathValue, _args.OutputValue);
|
||||
var libraryExporter = runtimeContext.CreateExporter(_args.ConfigValue, _args.BuildBasePathValue);
|
||||
CopyCompilationOutput(outputPaths);
|
||||
var executable = new Executable(runtimeContext, outputPaths, libraryExporter);
|
||||
|
||||
// If we're building for a specific RID, we need to copy the RID-less compilation output into
|
||||
// the RID-specific output dir
|
||||
if (!string.IsNullOrEmpty(runtimeContext.RuntimeIdentifier))
|
||||
{
|
||||
CopyCompilationOutput(outputPaths);
|
||||
}
|
||||
|
||||
var executable = new Executable(runtimeContext, outputPaths, libraryExporter, _args.ConfigValue);
|
||||
executable.MakeCompilationOutputRunnable();
|
||||
|
||||
PatchMscorlibNextToCoreClr(runtimeContext, _args.ConfigValue);
|
||||
|
@ -574,7 +579,7 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
|
||||
private static void AddCompilationOptions(ProjectContext project, string config, CompilerIO compilerIO)
|
||||
{
|
||||
var compilerOptions = CompilerUtil.ResolveCompilationOptions(project, config);
|
||||
var compilerOptions = project.ResolveCompilationOptions(config);
|
||||
|
||||
// input: key file
|
||||
if (compilerOptions.KeyFile != null)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.Dnx.Runtime.Common.CommandLine;
|
||||
|
@ -28,6 +29,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
private CommandOption _runtimeOption;
|
||||
private CommandOption _versionSuffixOption;
|
||||
private CommandOption _configurationOption;
|
||||
private CommandOption _portableOption;
|
||||
private CommandArgument _projectArgument;
|
||||
private CommandOption _nativeOption;
|
||||
private CommandOption _archOption;
|
||||
|
@ -41,8 +43,8 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
// resolved values for the options and arguments
|
||||
public string ProjectPathValue { get; set; }
|
||||
public string BuildBasePathValue { get; set; }
|
||||
public string OutputValue { get; set; }
|
||||
public string RuntimeValue { get; set; }
|
||||
public string OutputValue { get; set; }
|
||||
public string VersionSuffixValue { get; set; }
|
||||
public string ConfigValue { get; set; }
|
||||
public bool IsNativeValue { get; set; }
|
||||
|
@ -53,6 +55,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
public bool IsCppModeValue { get; set; }
|
||||
public string AppDepSdkPathValue { get; set; }
|
||||
public string CppCompilerFlagsValue { get; set; }
|
||||
public bool PortableMode { get; set; }
|
||||
|
||||
// workaround: CommandLineApplication is internal therefore I cannot make _app protected so baseclasses can add their own params
|
||||
private readonly Dictionary<string, CommandOption> baseClassOptions;
|
||||
|
@ -77,12 +80,15 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
|
||||
_outputOption = _app.Option("-o|--output <OUTPUT_DIR>", "Directory in which to place outputs", CommandOptionType.SingleValue);
|
||||
_buildBasePath = _app.Option("-b|--build-base-path <OUTPUT_DIR>", "Directory in which to place temporary outputs", CommandOptionType.SingleValue);
|
||||
_frameworkOption = _app.Option("-f|--framework <FRAMEWORK>", "Compile a specific framework", CommandOptionType.MultipleValue);
|
||||
_frameworkOption = _app.Option("-f|--framework <FRAMEWORK>", "Compile a specific framework", CommandOptionType.SingleValue);
|
||||
_runtimeOption = _app.Option("-r|--runtime <RUNTIME_IDENTIFIER>", "Produce runtime-specific assets for the specified runtime", CommandOptionType.SingleValue);
|
||||
_configurationOption = _app.Option("-c|--configuration <CONFIGURATION>", "Configuration under which to build", CommandOptionType.SingleValue);
|
||||
_runtimeOption = _app.Option("-r|--runtime <RUNTIME_IDENTIFIER>", "Target runtime to publish for", CommandOptionType.SingleValue);
|
||||
_versionSuffixOption = _app.Option("--version-suffix <VERSION_SUFFIX>", "Defines what `*` should be replaced with in version field in project.json", CommandOptionType.SingleValue);
|
||||
_projectArgument = _app.Argument("<PROJECT>", "The project to compile, defaults to the current directory. Can be a path to a project.json or a project directory");
|
||||
|
||||
// HACK: Allow us to treat a project as though it was portable by ignoring the runtime-specific targets. This is temporary until RID inference is removed from NuGet
|
||||
_portableOption = _app.Option("--portable", "TEMPORARY: Enforces portable build/publish mode", CommandOptionType.NoValue);
|
||||
|
||||
// Native Args
|
||||
_nativeOption = _app.Option("-n|--native", "Compiles source to native machine code.", CommandOptionType.NoValue);
|
||||
_archOption = _app.Option("-a|--arch <ARCH>", "The architecture for which to compile. x64 only currently supported.", CommandOptionType.SingleValue);
|
||||
|
@ -98,6 +104,12 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
{
|
||||
_app.OnExecute(() =>
|
||||
{
|
||||
if (_outputOption.HasValue() && !_frameworkOption.HasValue())
|
||||
{
|
||||
Reporter.Error.WriteLine("When the '--output' option is provided, the '--framework' option must also be provided.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Locate the project and get the name and full path
|
||||
ProjectPathValue = _projectArgument.Value;
|
||||
if (string.IsNullOrEmpty(ProjectPathValue))
|
||||
|
@ -110,6 +122,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
ConfigValue = _configurationOption.Value() ?? Constants.DefaultConfiguration;
|
||||
RuntimeValue = _runtimeOption.Value();
|
||||
VersionSuffixValue = _versionSuffixOption.Value();
|
||||
PortableMode = _portableOption.HasValue();
|
||||
|
||||
IsNativeValue = _nativeOption.HasValue();
|
||||
ArchValue = _archOption.Value();
|
||||
|
@ -120,8 +133,6 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
IsCppModeValue = _cppModeOption.HasValue();
|
||||
CppCompilerFlagsValue = _cppCompilerFlagsOption.Value();
|
||||
|
||||
IEnumerable<ProjectContext> contexts;
|
||||
|
||||
// Set defaults based on the environment
|
||||
var settings = ProjectReaderSettings.ReadFromEnvironment();
|
||||
|
||||
|
@ -130,29 +141,35 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
settings.VersionSuffix = VersionSuffixValue;
|
||||
}
|
||||
|
||||
if (_frameworkOption.HasValue())
|
||||
// Load the project file and construct all the targets
|
||||
var targets = ProjectContext.CreateContextForEachFramework(ProjectPathValue, settings).ToList();
|
||||
|
||||
if (targets.Count == 0)
|
||||
{
|
||||
contexts = _frameworkOption.Values
|
||||
.Select(f =>
|
||||
{
|
||||
return ProjectContext.CreateBuilder(ProjectPathValue, NuGetFramework.Parse(f))
|
||||
.WithReaderSettings(settings)
|
||||
.Build();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(OutputValue))
|
||||
{
|
||||
throw new InvalidOperationException($"'{_frameworkOption.LongName}' is required when '{_outputOption.LongName}' is specified");
|
||||
}
|
||||
else
|
||||
{
|
||||
contexts = ProjectContext.CreateContextForEachFramework(ProjectPathValue, settings);
|
||||
}
|
||||
// Project is missing 'frameworks' section
|
||||
Reporter.Error.WriteLine("Project does not have any frameworks listed in the 'frameworks' section.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
var success = execute(contexts.ToList(), this);
|
||||
// Filter the targets down based on the inputs
|
||||
if (_frameworkOption.HasValue())
|
||||
{
|
||||
var fx = NuGetFramework.Parse(_frameworkOption.Value());
|
||||
targets = targets.Where(t => fx.Equals(t.TargetFramework)).ToList();
|
||||
|
||||
if (targets.Count == 0)
|
||||
{
|
||||
// We filtered everything out
|
||||
Reporter.Error.WriteLine($"Project does not support framework: {fx.DotNetFrameworkName}.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Debug.Assert(targets.Count == 1);
|
||||
}
|
||||
|
||||
Debug.Assert(targets.All(t => string.IsNullOrEmpty(t.RuntimeIdentifier)));
|
||||
|
||||
var success = execute(targets, this);
|
||||
|
||||
return success ? 0 : 1;
|
||||
});
|
||||
|
|
|
@ -119,27 +119,6 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
// used in incremental compilation
|
||||
public static IEnumerable<string> GetCompilationSources(ProjectContext project) => project.ProjectFile.Files.SourceFiles;
|
||||
|
||||
// used in incremental compilation for the key file
|
||||
public static CommonCompilerOptions ResolveCompilationOptions(ProjectContext context, string configuration)
|
||||
{
|
||||
var compilationOptions = context.GetLanguageSpecificCompilerOptions(context.TargetFramework, configuration);
|
||||
|
||||
// Path to strong naming key in environment variable overrides path in project.json
|
||||
var environmentKeyFile = Environment.GetEnvironmentVariable(EnvironmentNames.StrongNameKeyFile);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(environmentKeyFile))
|
||||
{
|
||||
compilationOptions.KeyFile = environmentKeyFile;
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(compilationOptions.KeyFile))
|
||||
{
|
||||
// Resolve full path to key file
|
||||
compilationOptions.KeyFile =
|
||||
Path.GetFullPath(Path.Combine(context.ProjectFile.ProjectDirectory, compilationOptions.KeyFile));
|
||||
}
|
||||
return compilationOptions;
|
||||
}
|
||||
|
||||
//used in incremental precondition checks
|
||||
public static IEnumerable<string> GetCommandsInvokedByCompile(ProjectContext project)
|
||||
{
|
||||
|
|
|
@ -9,7 +9,6 @@ using Microsoft.DotNet.Cli.Compiler.Common;
|
|||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.ProjectModel.Compilation;
|
||||
using Microsoft.DotNet.ProjectModel.Utilities;
|
||||
using Microsoft.Extensions.DependencyModel;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Compiler
|
||||
|
@ -77,7 +76,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
$"--out:{outputName}"
|
||||
};
|
||||
|
||||
var compilationOptions = CompilerUtil.ResolveCompilationOptions(context, args.ConfigValue);
|
||||
var compilationOptions = context.ResolveCompilationOptions(args.ConfigValue);
|
||||
var languageId = CompilerUtil.ResolveLanguageId(context);
|
||||
|
||||
var references = new List<string>();
|
||||
|
@ -115,6 +114,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
var dependencyContext = new DependencyContextBuilder().Build(compilationOptions,
|
||||
allExports,
|
||||
allExports,
|
||||
args.PortableMode,
|
||||
context.TargetFramework,
|
||||
context.RuntimeIdentifier ?? string.Empty);
|
||||
|
||||
|
@ -161,6 +161,10 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
contextVariables.Add(
|
||||
"compile:RuntimeOutputDir",
|
||||
runtimeOutputPath.RuntimeOutputPath.TrimEnd('\\', '/'));
|
||||
|
||||
contextVariables.Add(
|
||||
"compile:RuntimeIdentifier",
|
||||
runtimeContext.RuntimeIdentifier);
|
||||
}
|
||||
|
||||
_scriptRunner.RunScripts(context, ScriptNames.PreCompile, contextVariables);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Server.Messengers
|
||||
{
|
||||
|
@ -22,6 +23,16 @@ namespace Microsoft.DotNet.ProjectModel.Server.Messengers
|
|||
{
|
||||
send(local.GlobalErrorMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
send(new ErrorMessage
|
||||
{
|
||||
Message = null,
|
||||
Path = null,
|
||||
Line = -1,
|
||||
Column = -1
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetValue(ProjectSnapshot local, ProjectSnapshot remote)
|
||||
|
|
|
@ -163,7 +163,7 @@ namespace Microsoft.DotNet.Tools.Restore
|
|||
toolDescription.Identity.Name + FileNameSuffixes.Deps);
|
||||
|
||||
var calculator = context.GetOutputPaths(Constants.DefaultConfiguration, buidBasePath: null, outputPath: context.ProjectDirectory);
|
||||
var executable = new Executable(context, calculator, context.CreateExporter(Constants.DefaultConfiguration));
|
||||
var executable = new Executable(context, calculator, context.CreateExporter(Constants.DefaultConfiguration), null);
|
||||
|
||||
executable.MakeCompilationOutputRunnable();
|
||||
|
||||
|
@ -180,7 +180,7 @@ namespace Microsoft.DotNet.Tools.Restore
|
|||
Console.WriteLine($"Restoring Tool '{tooldep.Name}' for '{projectPath}' in '{tempPath}'");
|
||||
|
||||
File.WriteAllText(projectPath, GenerateProjectJsonContents(new[] {"netstandardapp1.5"}, tooldep));
|
||||
return NuGet3.Restore(new [] { $"{projectPath}", "--runtime", $"{DefaultRid}"}.Concat(args), quiet) == 0;
|
||||
return NuGet3.Restore(new[] { $"{projectPath}" }.Concat(args), quiet) == 0;
|
||||
}
|
||||
|
||||
private static string GenerateProjectJsonContents(IEnumerable<string> frameworks, LibraryRange tooldep)
|
||||
|
@ -194,9 +194,11 @@ namespace Microsoft.DotNet.Tools.Restore
|
|||
foreach (var framework in frameworks)
|
||||
{
|
||||
var importsStatement = "\"imports\": [ \"dnxcore50\", \"portable-net452+win81\" ]";
|
||||
|
||||
sb.AppendLine($" \"{framework}\": {{ {importsStatement} }}");
|
||||
}
|
||||
sb.AppendLine(" },");
|
||||
sb.AppendLine(" \"runtimes\": { ");
|
||||
sb.AppendLine($" \"{DefaultRid}\": {{}}");
|
||||
sb.AppendLine(" }");
|
||||
sb.AppendLine("}");
|
||||
var pjContents = sb.ToString();
|
||||
|
|
|
@ -3,16 +3,16 @@
|
|||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"compileExclude": [
|
||||
"commands/dotnet-new/CSharp_Console/**",
|
||||
"commands/dotnet-new/FSharp_Console/**"
|
||||
"compileExclude": [
|
||||
"commands/dotnet-new/CSharp_Console/**",
|
||||
"commands/dotnet-new/FSharp_Console/**"
|
||||
],
|
||||
"resource": [
|
||||
"commands/dotnet-new/CSharp_Console/NuGet.Config",
|
||||
"commands/dotnet-new/CSharp_Console/Program.cs",
|
||||
"commands/dotnet-new/CSharp_Console/project.json.template",
|
||||
"commands/dotnet-new/FSharp_Console/NuGet.config",
|
||||
"commands/dotnet-new/FSharp_Console/Program.fs",
|
||||
"resource": [
|
||||
"commands/dotnet-new/CSharp_Console/NuGet.Config",
|
||||
"commands/dotnet-new/CSharp_Console/Program.cs",
|
||||
"commands/dotnet-new/CSharp_Console/project.json.template",
|
||||
"commands/dotnet-new/FSharp_Console/NuGet.config",
|
||||
"commands/dotnet-new/FSharp_Console/Program.fs",
|
||||
"commands/dotnet-new/FSharp_Console/project.json.template"
|
||||
],
|
||||
"dependencies": {
|
||||
|
@ -24,7 +24,7 @@
|
|||
"Microsoft.CodeAnalysis.CSharp": "1.3.0-beta1-20160225-02",
|
||||
"Microsoft.DiaSymReader.Native": "1.3.3",
|
||||
|
||||
"NuGet.CommandLine.XPlat": "3.4.0-beta-632",
|
||||
"NuGet.CommandLine.XPlat": "3.4.0-rtm-0733",
|
||||
"System.CommandLine": "0.1.0-e160119-1",
|
||||
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
|
|
|
@ -27,5 +27,5 @@
|
|||
|
||||
"testRunner": "xunit",
|
||||
|
||||
"scripts": { "precompile": "dotnet build ../ArgumentsReflector/project.json --framework netstandardapp1.5 --output %compile:RuntimeOutputDir%" }
|
||||
"scripts": { "precompile": "dotnet build ../ArgumentsReflector/project.json --framework netstandardapp1.5 --runtime %compile:RuntimeIdentifier% --output %compile:RuntimeOutputDir%" }
|
||||
}
|
||||
|
|
|
@ -83,15 +83,8 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
[Fact]
|
||||
public void TestDotnetBuildNativeRyuJit()
|
||||
{
|
||||
if(IsCentOS())
|
||||
if (!IsNativeCompilationSupported())
|
||||
{
|
||||
Console.WriteLine("Skipping native compilation tests on CentOS - https://github.com/dotnet/cli/issues/453");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsWinX86())
|
||||
{
|
||||
Console.WriteLine("Skipping native compilation tests on Windows x86 - https://github.com/dotnet/cli/issues/1550");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -105,15 +98,8 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
[Fact]
|
||||
public void TestDotnetBuildNativeCpp()
|
||||
{
|
||||
if(IsCentOS())
|
||||
if (!IsNativeCompilationSupported())
|
||||
{
|
||||
Console.WriteLine("Skipping native compilation tests on CentOS - https://github.com/dotnet/cli/issues/453");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsWinX86())
|
||||
{
|
||||
Console.WriteLine("Skipping native compilation tests on Windows x86 - https://github.com/dotnet/cli/issues/1550");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -127,15 +113,8 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
[Fact]
|
||||
public void TestDotnetCompileNativeCppIncremental()
|
||||
{
|
||||
if (IsCentOS())
|
||||
if (!IsNativeCompilationSupported())
|
||||
{
|
||||
Console.WriteLine("Skipping native compilation tests on CentOS - https://github.com/dotnet/cli/issues/453");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsWinX86())
|
||||
{
|
||||
Console.WriteLine("Skipping native compilation tests on Windows x86 - https://github.com/dotnet/cli/issues/1550");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -236,25 +215,30 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
Directory.SetCurrentDirectory(currentDirectory);
|
||||
}
|
||||
|
||||
private bool IsCentOS()
|
||||
private bool IsNativeCompilationSupported()
|
||||
{
|
||||
if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
bool isSupported = true;
|
||||
var platform = PlatformServices.Default.Runtime.OperatingSystem.ToLower();
|
||||
switch (platform)
|
||||
{
|
||||
const string OSIDFILE = "/etc/os-release";
|
||||
|
||||
if(File.Exists(OSIDFILE))
|
||||
{
|
||||
return File.ReadAllText(OSIDFILE).ToLower().Contains("centos");
|
||||
}
|
||||
case "centos":
|
||||
case "rhel":
|
||||
Console.WriteLine("Skipping native compilation tests on CentOS/RHEL - https://github.com/dotnet/cli/issues/453");
|
||||
isSupported = false;
|
||||
break;
|
||||
case "debian":
|
||||
Console.WriteLine("Skipping native compilation tests on Debian - https://github.com/dotnet/cli/issues/1666");
|
||||
isSupported = false;
|
||||
break;
|
||||
case "windows":
|
||||
Console.WriteLine("Skipping native compilation tests on Windows x86 - https://github.com/dotnet/cli/issues/1550");
|
||||
isSupported = RuntimeInformation.ProcessArchitecture != Architecture.X86;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool IsWinX86()
|
||||
{
|
||||
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
|
||||
RuntimeInformation.ProcessArchitecture == Architecture.X86;
|
||||
return isSupported;
|
||||
}
|
||||
|
||||
private static DateTime GetLastWriteTimeUtcOfDirectoryFiles(string outputDirectory)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
"xunit": "2.1.0",
|
||||
"xunit.netcore.extensions": "1.0.0-prerelease-*",
|
||||
"dotnet-test-xunit": "1.0.0-dev-79755-47"
|
||||
"dotnet-test-xunit": "1.0.0-dev-91790-12"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
|
|
|
@ -14,7 +14,7 @@ function CopyInstaller([string]$destination)
|
|||
# Copy both the .msi and the .exe to the testBin directory so
|
||||
# the tests running in the docker container have access to them.
|
||||
Copy-Item $inputMsi -Destination:$destination
|
||||
|
||||
|
||||
$BundlePath = [System.IO.Path]::ChangeExtension($inputMsi, "exe")
|
||||
Copy-Item $BundlePath -Destination:$destination
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ function CopyInstaller([string]$destination)
|
|||
function CopyTestXUnitRunner([string]$destination)
|
||||
{
|
||||
$XUnitRunnerDir = Join-Path $env:NUGET_PACKAGES xunit.runner.console\2.1.0\tools
|
||||
|
||||
|
||||
Copy-Item $XUnitRunnerDir\xunit.console.exe -Destination:$destination
|
||||
Copy-Item $XUnitRunnerDir\xunit.runner.utility.desktop.dll -Destination:$destination
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ pushd "$Stage2Dir\bin"
|
|||
|
||||
try {
|
||||
.\dotnet restore `
|
||||
--runtime win-anycpu `
|
||||
$testDir `
|
||||
-f https://www.myget.org/F/dotnet-buildtools/api/v3/index.json | Out-Host
|
||||
|
||||
|
@ -53,7 +52,6 @@ try {
|
|||
|
||||
.\dotnet publish `
|
||||
--framework net46 `
|
||||
--runtime win-anycpu `
|
||||
--output $testBin `
|
||||
$testDir | Out-Host
|
||||
|
||||
|
@ -68,7 +66,7 @@ try {
|
|||
CopyTestXUnitRunner $testBin
|
||||
|
||||
Write-Host "Running installer tests in Windows Container"
|
||||
|
||||
|
||||
# --net="none" works around a networking issue on the containers on the CI machines.
|
||||
# Since our installer tests don't require the network, it is fine to shut it off.
|
||||
$MsiFileName = [System.IO.Path]::GetFileName($inputMsi)
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
@ -15,36 +18,6 @@ namespace Microsoft.DotNet.ProjectModel.Tests
|
|||
{
|
||||
private const string PackagePath = "PackagePath";
|
||||
|
||||
private LibraryExport ExportSingle(LibraryDescription description = null)
|
||||
{
|
||||
var rootProject = new Project()
|
||||
{
|
||||
Name = "RootProject",
|
||||
CompilerName = "csc"
|
||||
};
|
||||
|
||||
var rootProjectDescription = new ProjectDescription(
|
||||
new LibraryRange(),
|
||||
rootProject,
|
||||
new LibraryRange[] { },
|
||||
new TargetFrameworkInformation(),
|
||||
true);
|
||||
|
||||
if (description == null)
|
||||
{
|
||||
description = rootProjectDescription;
|
||||
}
|
||||
else
|
||||
{
|
||||
description.Parents.Add(rootProjectDescription);
|
||||
}
|
||||
|
||||
var libraryManager = new LibraryManager(new[] { description }, new DiagnosticMessage[] { }, "");
|
||||
var allExports = new LibraryExporter(rootProjectDescription, libraryManager, "config", "runtime", "basepath", "solutionroot").GetAllExports();
|
||||
var export = allExports.Single();
|
||||
return export;
|
||||
}
|
||||
|
||||
private PackageDescription CreateDescription(LockFileTargetLibrary target = null, LockFilePackageLibrary package = null)
|
||||
{
|
||||
return new PackageDescription(PackagePath,
|
||||
|
@ -54,7 +27,7 @@ namespace Microsoft.DotNet.ProjectModel.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
private void ExportsPackageNativeLibraries()
|
||||
public void ExportsPackageNativeLibraries()
|
||||
{
|
||||
var description = CreateDescription(
|
||||
new LockFileTargetLibrary()
|
||||
|
@ -76,7 +49,7 @@ namespace Microsoft.DotNet.ProjectModel.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
private void ExportsPackageCompilationAssebmlies()
|
||||
public void ExportsPackageCompilationAssebmlies()
|
||||
{
|
||||
var description = CreateDescription(
|
||||
new LockFileTargetLibrary()
|
||||
|
@ -98,7 +71,7 @@ namespace Microsoft.DotNet.ProjectModel.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
private void ExportsPackageRuntimeAssebmlies()
|
||||
public void ExportsPackageRuntimeAssebmlies()
|
||||
{
|
||||
var description = CreateDescription(
|
||||
new LockFileTargetLibrary()
|
||||
|
@ -120,7 +93,7 @@ namespace Microsoft.DotNet.ProjectModel.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
private void ExportsSources()
|
||||
public void ExportsSources()
|
||||
{
|
||||
var description = CreateDescription(
|
||||
package: new LockFilePackageLibrary()
|
||||
|
@ -142,7 +115,7 @@ namespace Microsoft.DotNet.ProjectModel.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
private void ExportsCopyToOutputContentFiles()
|
||||
public void ExportsCopyToOutputContentFiles()
|
||||
{
|
||||
var description = CreateDescription(
|
||||
new LockFileTargetLibrary()
|
||||
|
@ -170,7 +143,7 @@ namespace Microsoft.DotNet.ProjectModel.Tests
|
|||
|
||||
|
||||
[Fact]
|
||||
private void ExportsResourceContentFiles()
|
||||
public void ExportsResourceContentFiles()
|
||||
{
|
||||
var description = CreateDescription(
|
||||
new LockFileTargetLibrary()
|
||||
|
@ -196,7 +169,7 @@ namespace Microsoft.DotNet.ProjectModel.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
private void ExportsCompileContentFiles()
|
||||
public void ExportsCompileContentFiles()
|
||||
{
|
||||
var description = CreateDescription(
|
||||
new LockFileTargetLibrary()
|
||||
|
@ -224,7 +197,7 @@ namespace Microsoft.DotNet.ProjectModel.Tests
|
|||
|
||||
|
||||
[Fact]
|
||||
private void SelectsContentFilesOfProjectCodeLanguage()
|
||||
public void SelectsContentFilesOfProjectCodeLanguage()
|
||||
{
|
||||
var description = CreateDescription(
|
||||
new LockFileTargetLibrary()
|
||||
|
@ -264,7 +237,7 @@ namespace Microsoft.DotNet.ProjectModel.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
private void SelectsContentFilesWithNoLanguageIfProjectLanguageNotMathed()
|
||||
public void SelectsContentFilesWithNoLanguageIfProjectLanguageNotMathed()
|
||||
{
|
||||
var description = CreateDescription(
|
||||
new LockFileTargetLibrary()
|
||||
|
@ -295,5 +268,84 @@ namespace Microsoft.DotNet.ProjectModel.Tests
|
|||
libraryAsset.RelativePath.Should().Be(Path.Combine("content", "file.any"));
|
||||
libraryAsset.ResolvedPath.Should().Be(Path.Combine(PackagePath, "content", "file.any"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ExportsRuntimeTargets()
|
||||
{
|
||||
var win8Native = Path.Combine("native", "win8-x64", "Native.dll");
|
||||
var win8Runtime = Path.Combine("runtime", "win8-x64", "Runtime.dll");
|
||||
var linuxNative = Path.Combine("native", "linux", "Native.dll");
|
||||
|
||||
var description = CreateDescription(
|
||||
new LockFileTargetLibrary()
|
||||
{
|
||||
RuntimeTargets = new List<LockFileRuntimeTarget>()
|
||||
{
|
||||
new LockFileRuntimeTarget(
|
||||
path: win8Native,
|
||||
runtime: "win8-x64",
|
||||
assetType: "native"
|
||||
),
|
||||
new LockFileRuntimeTarget(
|
||||
path: win8Runtime,
|
||||
runtime: "win8-x64",
|
||||
assetType: "runtime"
|
||||
),
|
||||
new LockFileRuntimeTarget(
|
||||
path: linuxNative,
|
||||
runtime: "linux",
|
||||
assetType: "native"
|
||||
),
|
||||
}
|
||||
});
|
||||
|
||||
var result = ExportSingle(description);
|
||||
result.RuntimeTargets.Should().HaveCount(2);
|
||||
|
||||
var runtimeTarget = result.RuntimeTargets.Should().Contain(t => t.Runtime == "win8-x64").Subject;
|
||||
var runtime = runtimeTarget.RuntimeAssemblies.Single();
|
||||
runtime.RelativePath.Should().Be(win8Runtime);
|
||||
runtime.ResolvedPath.Should().Be(Path.Combine(PackagePath, win8Runtime));
|
||||
|
||||
var native = runtimeTarget.NativeLibraries.Single();
|
||||
native.RelativePath.Should().Be(win8Native);
|
||||
native.ResolvedPath.Should().Be(Path.Combine(PackagePath, win8Native));
|
||||
|
||||
runtimeTarget = result.RuntimeTargets.Should().Contain(t => t.Runtime == "linux").Subject;
|
||||
native = runtimeTarget.NativeLibraries.Single();
|
||||
native.RelativePath.Should().Be(linuxNative);
|
||||
native.ResolvedPath.Should().Be(Path.Combine(PackagePath, linuxNative));
|
||||
}
|
||||
|
||||
private LibraryExport ExportSingle(LibraryDescription description = null)
|
||||
{
|
||||
var rootProject = new Project()
|
||||
{
|
||||
Name = "RootProject",
|
||||
CompilerName = "csc"
|
||||
};
|
||||
|
||||
var rootProjectDescription = new ProjectDescription(
|
||||
new LibraryRange(),
|
||||
rootProject,
|
||||
new LibraryRange[] { },
|
||||
new TargetFrameworkInformation(),
|
||||
true);
|
||||
|
||||
if (description == null)
|
||||
{
|
||||
description = rootProjectDescription;
|
||||
}
|
||||
else
|
||||
{
|
||||
description.Parents.Add(rootProjectDescription);
|
||||
}
|
||||
|
||||
var libraryManager = new LibraryManager(new[] { description }, new DiagnosticMessage[] { }, "");
|
||||
var allExports = new LibraryExporter(rootProjectDescription, libraryManager, "config", "runtime", "basepath", "solutionroot").GetAllExports();
|
||||
var export = allExports.Single();
|
||||
return export;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"Microsoft.DotNet.ProjectModel": { "target": "project" },
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" },
|
||||
"xunit": "2.1.0",
|
||||
"dotnet-test-xunit": "1.0.0-dev-79755-47"
|
||||
"dotnet-test-xunit": "1.0.0-dev-91790-12"
|
||||
},
|
||||
"frameworks": {
|
||||
"netstandardapp1.5": {
|
||||
|
|
|
@ -60,7 +60,14 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> StdOutMatchPattern(string pattern, RegexOptions options = RegexOptions.None)
|
||||
public AndConstraint<CommandResultAssertions> HaveStdOutContaining(string pattern)
|
||||
{
|
||||
Execute.Assertion.ForCondition(_commandResult.StdOut.Contains(pattern))
|
||||
.FailWith(AppendDiagnosticsTo($"The command output did not contain expected result: {pattern}{Environment.NewLine}"));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> HaveStdOutMatching(string pattern, RegexOptions options = RegexOptions.None)
|
||||
{
|
||||
Execute.Assertion.ForCondition(Regex.Match(_commandResult.StdOut, pattern, options).Success)
|
||||
.FailWith(AppendDiagnosticsTo($"Matching the command output failed. Pattern: {pattern}{Environment.NewLine}"));
|
||||
|
@ -74,6 +81,20 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> HaveStdErrContaining(string pattern)
|
||||
{
|
||||
Execute.Assertion.ForCondition(_commandResult.StdErr.Contains(pattern))
|
||||
.FailWith(AppendDiagnosticsTo($"The command error output did not contain expected result: {pattern}{Environment.NewLine}"));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> HaveStdErrMatching(string pattern, RegexOptions options = RegexOptions.None)
|
||||
{
|
||||
Execute.Assertion.ForCondition(Regex.Match(_commandResult.StdErr, pattern, options).Success)
|
||||
.FailWith(AppendDiagnosticsTo($"Matching the command error output failed. Pattern: {pattern}{Environment.NewLine}"));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> NotHaveStdOut()
|
||||
{
|
||||
Execute.Assertion.ForCondition(string.IsNullOrEmpty(_commandResult.StdOut))
|
||||
|
|
|
@ -11,23 +11,25 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
public sealed class BuildCommand : TestCommand
|
||||
{
|
||||
private Project _project;
|
||||
private string _projectPath;
|
||||
private string _outputDirectory;
|
||||
private string _buidBasePathDirectory;
|
||||
private string _configuration;
|
||||
private string _framework;
|
||||
private string _versionSuffix;
|
||||
private bool _noHost;
|
||||
private bool _native;
|
||||
private string _architecture;
|
||||
private string _ilcArgs;
|
||||
private string _ilcPath;
|
||||
private string _appDepSDKPath;
|
||||
private bool _nativeCppMode;
|
||||
private string _cppCompilerFlags;
|
||||
private bool _buildProfile;
|
||||
private bool _noIncremental;
|
||||
private bool _noDependencies;
|
||||
private readonly string _projectPath;
|
||||
private readonly string _outputDirectory;
|
||||
private readonly string _buidBasePathDirectory;
|
||||
private readonly string _configuration;
|
||||
private readonly string _framework;
|
||||
private readonly string _versionSuffix;
|
||||
private readonly bool _noHost;
|
||||
private readonly bool _native;
|
||||
private readonly string _architecture;
|
||||
private readonly string _ilcArgs;
|
||||
private readonly string _ilcPath;
|
||||
private readonly string _appDepSDKPath;
|
||||
private readonly bool _nativeCppMode;
|
||||
private readonly string _cppCompilerFlags;
|
||||
private readonly bool _buildProfile;
|
||||
private readonly bool _noIncremental;
|
||||
private readonly bool _noDependencies;
|
||||
private readonly string _runtime;
|
||||
private readonly bool _forcePortable;
|
||||
|
||||
private string OutputOption
|
||||
{
|
||||
|
@ -39,6 +41,16 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
}
|
||||
}
|
||||
|
||||
private string ForcePortableOption
|
||||
{
|
||||
get
|
||||
{
|
||||
return _forcePortable ?
|
||||
"--portable" :
|
||||
string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private string BuildBasePathOption
|
||||
{
|
||||
get
|
||||
|
@ -67,7 +79,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
$"--framework {_framework}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string VersionSuffixOption
|
||||
{
|
||||
get
|
||||
|
@ -98,6 +110,16 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
}
|
||||
}
|
||||
|
||||
private string RuntimeOption
|
||||
{
|
||||
get
|
||||
{
|
||||
return _runtime == string.Empty ?
|
||||
"" :
|
||||
$"--runtime {_runtime}";
|
||||
}
|
||||
}
|
||||
|
||||
private string ArchitectureOption
|
||||
{
|
||||
get
|
||||
|
@ -194,6 +216,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
string buidBasePath="",
|
||||
string configuration="",
|
||||
string framework="",
|
||||
string runtime="",
|
||||
string versionSuffix="",
|
||||
bool noHost=false,
|
||||
bool native=false,
|
||||
|
@ -205,7 +228,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
string cppCompilerFlags="",
|
||||
bool buildProfile=true,
|
||||
bool noIncremental=false,
|
||||
bool noDependencies=false
|
||||
bool noDependencies=false,
|
||||
bool forcePortable=false
|
||||
)
|
||||
: base("dotnet")
|
||||
{
|
||||
|
@ -217,6 +241,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
_configuration = configuration;
|
||||
_versionSuffix = versionSuffix;
|
||||
_framework = framework;
|
||||
_runtime = runtime;
|
||||
_noHost = noHost;
|
||||
_native = native;
|
||||
_architecture = architecture;
|
||||
|
@ -228,6 +253,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
_buildProfile = buildProfile;
|
||||
_noIncremental = noIncremental;
|
||||
_noDependencies = noDependencies;
|
||||
_forcePortable = forcePortable;
|
||||
}
|
||||
|
||||
public override CommandResult Execute(string args = "")
|
||||
|
@ -251,7 +277,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
private string BuildArgs()
|
||||
{
|
||||
return $"{BuildProfile} {NoDependencies} {NoIncremental} \"{_projectPath}\" {OutputOption} {BuildBasePathOption} {ConfigurationOption} {FrameworkOption} {VersionSuffixOption} {NoHostOption} {NativeOption} {ArchitectureOption} {IlcArgsOption} {IlcPathOption} {AppDepSDKPathOption} {NativeCppModeOption} {CppCompilerFlagsOption}";
|
||||
return $"{BuildProfile} {ForcePortableOption} {NoDependencies} {NoIncremental} \"{_projectPath}\" {OutputOption} {BuildBasePathOption} {ConfigurationOption} {FrameworkOption} {RuntimeOption} {VersionSuffixOption} {NoHostOption} {NativeOption} {ArchitectureOption} {IlcArgsOption} {IlcPathOption} {AppDepSDKPathOption} {NativeCppModeOption} {CppCompilerFlagsOption}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"System.IO.Compression": "4.1.0-rc2-23901",
|
||||
"FluentAssertions": "4.0.0",
|
||||
"xunit": "2.1.0",
|
||||
"dotnet-test-xunit": "1.0.0-dev-79755-47",
|
||||
"dotnet-test-xunit": "1.0.0-dev-91790-12",
|
||||
|
||||
"Microsoft.DotNet.TestFramework": "1.0.0-*",
|
||||
"Microsoft.DotNet.Cli.Utils": "1.0.0-*",
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.DependencyModel;
|
||||
using Microsoft.Extensions.DependencyModel.Resolution;
|
||||
using Moq;
|
||||
|
@ -54,7 +55,14 @@ namespace StreamForwarderTests
|
|||
failTwo.Object
|
||||
};
|
||||
|
||||
var library = new CompilationLibrary(string.Empty, string.Empty, string.Empty, string.Empty, null, null, false);
|
||||
var library = new CompilationLibrary(
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
Enumerable.Empty<string>(),
|
||||
Enumerable.Empty<Dependency>(),
|
||||
false);
|
||||
|
||||
var resolver = new CompositeCompilationAssemblyResolver(resolvers);
|
||||
var result = resolver.TryResolveAssemblyPaths(library, null);
|
||||
|
@ -82,7 +90,14 @@ namespace StreamForwarderTests
|
|||
};
|
||||
|
||||
var assemblies = new List<string>();
|
||||
var library = new CompilationLibrary(string.Empty, string.Empty, string.Empty, string.Empty, null, null, false);
|
||||
var library = new CompilationLibrary(
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
Enumerable.Empty<string>(),
|
||||
Enumerable.Empty<Dependency>(),
|
||||
false);
|
||||
|
||||
var resolver = new CompositeCompilationAssemblyResolver(resolvers);
|
||||
var result = resolver.TryResolveAssemblyPaths(library, assemblies);
|
||||
|
|
|
@ -24,14 +24,16 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
public DependencyContext Build(CommonCompilerOptions compilerOptions = null,
|
||||
IEnumerable<LibraryExport> compilationExports = null,
|
||||
IEnumerable<LibraryExport> runtimeExports = null,
|
||||
bool portable = false,
|
||||
NuGetFramework target = null,
|
||||
string runtime = null)
|
||||
{
|
||||
_defaultFramework = NuGetFramework.Parse("net451");
|
||||
return new DependencyContextBuilder(_referenceAssembliesPath).Build(
|
||||
compilerOptions ?? new CommonCompilerOptions(),
|
||||
compilerOptions,
|
||||
compilationExports ?? new LibraryExport[] { },
|
||||
runtimeExports ?? new LibraryExport[] {},
|
||||
portable,
|
||||
target ?? _defaultFramework,
|
||||
runtime ?? string.Empty);
|
||||
}
|
||||
|
@ -42,7 +44,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
var context = Build(new CommonCompilerOptions()
|
||||
{
|
||||
AllowUnsafe = true,
|
||||
Defines = new[] {"Define", "D"},
|
||||
Defines = new[] { "Define", "D" },
|
||||
DelaySign = true,
|
||||
EmitEntryPoint = true,
|
||||
GenerateXmlDocumentation = true,
|
||||
|
@ -68,6 +70,23 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
context.CompilationOptions.Platform.Should().Be("Platform");
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void AlowsNullCompilationOptions()
|
||||
{
|
||||
var context = Build(compilerOptions: null);
|
||||
|
||||
context.CompilationOptions.Should().Be(CompilationOptions.Default);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetsPortableFlag()
|
||||
{
|
||||
var context = Build(portable: true);
|
||||
|
||||
context.IsPortable.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FillsRuntimeAndTarget()
|
||||
{
|
||||
|
@ -104,9 +123,24 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
LibraryType.ReferenceAssembly,
|
||||
LibraryDependencyType.Default)
|
||||
}),
|
||||
resourceAssemblies: new[]
|
||||
{
|
||||
new LibraryResourceAssembly(
|
||||
new LibraryAsset("Dll", "en-US/Pack.Age.resources.dll", ""),
|
||||
"en-US"
|
||||
)
|
||||
},
|
||||
runtimeAssemblies: new[]
|
||||
{
|
||||
new LibraryAsset("Dll", "lib/Pack.Age.dll", ""),
|
||||
},
|
||||
runtimeTargets: new []
|
||||
{
|
||||
new LibraryRuntimeTarget(
|
||||
"win8-x64",
|
||||
new [] { new LibraryAsset("Dll", "win8-x64/Pack.Age.dll", "") },
|
||||
new [] { new LibraryAsset("Dll", "win8-x64/Pack.Age.native.dll", "") }
|
||||
)
|
||||
}
|
||||
),
|
||||
Export(ReferenceAssemblyDescription("System.Collections",
|
||||
|
@ -126,6 +160,11 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
lib.Version.Should().Be("1.2.3");
|
||||
lib.Dependencies.Should().OnlyContain(l => l.Name == "System.Collections" && l.Version == "3.3.3");
|
||||
lib.Assemblies.Should().OnlyContain(l => l.Path == "lib/Pack.Age.dll");
|
||||
lib.ResourceAssemblies.Should().OnlyContain(l => l.Path == "en-US/Pack.Age.resources.dll" && l.Locale == "en-US");
|
||||
|
||||
var target = lib.RuntimeTargets.Should().Contain(t => t.Runtime == "win8-x64").Subject;
|
||||
target.Assemblies.Should().OnlyContain(l => l.Path == "win8-x64/Pack.Age.dll");
|
||||
target.NativeLibraries.Should().OnlyContain(l => l == "win8-x64/Pack.Age.native.dll");
|
||||
|
||||
var asm = context.RuntimeLibraries.Should().Contain(l => l.Name == "System.Collections").Subject;
|
||||
asm.Type.Should().Be("referenceassembly");
|
||||
|
@ -135,6 +174,34 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
asm.Assemblies.Should().OnlyContain(l => l.Path == "System.Collections.dll");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FiltersDuplicatedDependencies()
|
||||
{
|
||||
var context = Build(runtimeExports: new[]
|
||||
{
|
||||
Export(PackageDescription("Pack.Age",
|
||||
dependencies: new[]
|
||||
{
|
||||
new LibraryRange("System.Collections",
|
||||
new VersionRange(new NuGetVersion(2, 0, 0)),
|
||||
LibraryType.ReferenceAssembly,
|
||||
LibraryDependencyType.Default),
|
||||
new LibraryRange("System.Collections",
|
||||
new VersionRange(new NuGetVersion(2, 1, 2)),
|
||||
LibraryType.Package,
|
||||
LibraryDependencyType.Default)
|
||||
})
|
||||
),
|
||||
Export(ReferenceAssemblyDescription("System.Collections",
|
||||
version: new NuGetVersion(2, 0, 0)))
|
||||
});
|
||||
|
||||
context.RuntimeLibraries.Should().HaveCount(2);
|
||||
|
||||
var lib = context.RuntimeLibraries.Should().Contain(l => l.Name == "Pack.Age").Subject;
|
||||
lib.Dependencies.Should().HaveCount(1);
|
||||
lib.Dependencies.Should().OnlyContain(l => l.Name == "System.Collections" && l.Version == "2.0.0");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FillsCompileLibraryProperties()
|
||||
|
@ -204,7 +271,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
public void SkipsBuildDependencies()
|
||||
{
|
||||
var context = Build(compilationExports: new[]
|
||||
{
|
||||
{
|
||||
Export(PackageDescription("Pack.Age",
|
||||
dependencies: new[]
|
||||
{
|
||||
|
@ -225,18 +292,16 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
private LibraryExport Export(
|
||||
LibraryDescription description,
|
||||
IEnumerable<LibraryAsset> compilationAssemblies = null,
|
||||
IEnumerable<LibraryAsset> runtimeAssemblies = null)
|
||||
IEnumerable<LibraryAsset> runtimeAssemblies = null,
|
||||
IEnumerable<LibraryRuntimeTarget> runtimeTargets = null,
|
||||
IEnumerable<LibraryResourceAssembly> resourceAssemblies = null)
|
||||
{
|
||||
return new LibraryExport(
|
||||
description,
|
||||
compilationAssemblies ?? Enumerable.Empty<LibraryAsset>(),
|
||||
Enumerable.Empty<LibraryAsset>(),
|
||||
runtimeAssemblies ?? Enumerable.Empty<LibraryAsset>(),
|
||||
Enumerable.Empty<LibraryAsset>(),
|
||||
Enumerable.Empty<LibraryAsset>(),
|
||||
Enumerable.Empty<LibraryAsset>(),
|
||||
Enumerable.Empty<AnalyzerReference>()
|
||||
);
|
||||
return LibraryExportBuilder.Create(description)
|
||||
.WithCompilationAssemblies(compilationAssemblies)
|
||||
.WithRuntimeAssemblies(runtimeAssemblies)
|
||||
.WithRuntimeTargets(runtimeTargets)
|
||||
.WithResourceAssemblies(resourceAssemblies)
|
||||
.Build();
|
||||
}
|
||||
|
||||
private PackageDescription PackageDescription(
|
||||
|
|
|
@ -183,6 +183,9 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
""runtimeTargets"": {
|
||||
""lib/win7/System.Banana.dll"": { ""assetType"": ""runtime"", ""rid"": ""win7-x64""},
|
||||
""lib/win7/Banana.dll"": { ""assetType"": ""native"", ""rid"": ""win7-x64""}
|
||||
},
|
||||
""resources"": {
|
||||
""System.Banana.resources.dll"": { ""locale"": ""en-US"" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -211,6 +214,8 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
package.Type.Should().Be("package");
|
||||
package.Serviceable.Should().Be(false);
|
||||
package.Assemblies.Should().Contain(a => a.Path == "lib/dotnet5.4/System.Banana.dll");
|
||||
package.ResourceAssemblies.Should().Contain(a => a.Path == "System.Banana.resources.dll")
|
||||
.Subject.Locale.Should().Be("en-US");
|
||||
|
||||
var target = package.RuntimeTargets.Should().Contain(t => t.Runtime == "win7-x64").Subject;
|
||||
target.Assemblies.Should().Contain(a => a.Path == "lib/win7/System.Banana.dll");
|
||||
|
|
|
@ -62,10 +62,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
new KeyValuePair<string, string[]>("win8-x64", new [] { "win7-x64"}),
|
||||
}));
|
||||
|
||||
var runtimes = result.Should().HaveProperty("runtimes")
|
||||
.Subject.Should().BeOfType<JObject>().Subject;
|
||||
|
||||
var rids = runtimes.Should().HaveProperty("Target")
|
||||
var rids = result.Should().HaveProperty("runtimes")
|
||||
.Subject.Should().BeOfType<JObject>().Subject;
|
||||
|
||||
rids.Should().HaveProperty("win7-x64")
|
||||
|
@ -154,11 +151,12 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
"1.2.3",
|
||||
"HASH",
|
||||
new [] { RuntimeAssembly.Create("Banana.dll")},
|
||||
new [] { new ResourceAssembly("en-US\\Banana.Resource.dll", "en-US")},
|
||||
new []
|
||||
{
|
||||
new RuntimeTarget("win7-x64",
|
||||
new [] { RuntimeAssembly.Create("Banana.Win7-x64.dll") },
|
||||
new [] { "Banana.Win7-x64.so" }
|
||||
new [] { "native\\Banana.Win7-x64.so" }
|
||||
)
|
||||
},
|
||||
new [] {
|
||||
|
@ -183,10 +181,14 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
runtimeAssembly.Should().HavePropertyValue("rid", "win7-x64");
|
||||
runtimeAssembly.Should().HavePropertyValue("assetType", "runtime");
|
||||
|
||||
var nativeLibrary = runtimeTargets.Should().HavePropertyAsObject("Banana.Win7-x64.so").Subject;
|
||||
var nativeLibrary = runtimeTargets.Should().HavePropertyAsObject("native/Banana.Win7-x64.so").Subject;
|
||||
nativeLibrary.Should().HavePropertyValue("rid", "win7-x64");
|
||||
nativeLibrary.Should().HavePropertyValue("assetType", "native");
|
||||
|
||||
var resourceAssemblies = library.Should().HavePropertyAsObject("resources").Subject;
|
||||
var resourceAssembly = resourceAssemblies.Should().HavePropertyAsObject("en-US/Banana.Resource.dll").Subject;
|
||||
resourceAssembly.Should().HavePropertyValue("locale", "en-US");
|
||||
|
||||
//libraries
|
||||
var libraries = result.Should().HavePropertyAsObject("libraries").Subject;
|
||||
library = libraries.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
|
||||
|
@ -224,6 +226,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
"1.2.3",
|
||||
"HASH",
|
||||
new [] { RuntimeAssembly.Create("Banana.dll")},
|
||||
new ResourceAssembly[] {},
|
||||
new []
|
||||
{
|
||||
new RuntimeTarget("win7-x64",
|
||||
|
@ -283,6 +286,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
"1.2.3",
|
||||
"HASH",
|
||||
new [] { RuntimeAssembly.Create("Banana.dll")},
|
||||
new ResourceAssembly[] {},
|
||||
new RuntimeTarget[] {},
|
||||
new [] {
|
||||
new Dependency("Fruits.Abstract.dll","2.0.0")
|
||||
|
@ -308,6 +312,74 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
library.Should().HavePropertyValue("serviceable", true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WritesResourceAssembliesForNonPortable()
|
||||
{
|
||||
var result = Save(Create(
|
||||
"Target",
|
||||
"runtime",
|
||||
false,
|
||||
runtimeLibraries: new[]
|
||||
{
|
||||
new RuntimeLibrary(
|
||||
"package",
|
||||
"PackageName",
|
||||
"1.2.3",
|
||||
"HASH",
|
||||
new RuntimeAssembly[] { },
|
||||
new []
|
||||
{
|
||||
new ResourceAssembly("en-US/Fruits.resources.dll", "en-US")
|
||||
},
|
||||
new RuntimeTarget[] { },
|
||||
new Dependency[] { },
|
||||
true
|
||||
),
|
||||
}));
|
||||
|
||||
var targets = result.Should().HavePropertyAsObject("targets").Subject;
|
||||
var target = targets.Should().HavePropertyAsObject("Target/runtime").Subject;
|
||||
var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
|
||||
var resources = library.Should().HavePropertyAsObject("resources").Subject;
|
||||
var resource = resources.Should().HavePropertyAsObject("en-US/Fruits.resources.dll").Subject;
|
||||
resource.Should().HavePropertyValue("locale", "en-US");
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void WritesResourceAssembliesForPortable()
|
||||
{
|
||||
var result = Save(Create(
|
||||
"Target",
|
||||
"runtime",
|
||||
true,
|
||||
runtimeLibraries: new[]
|
||||
{
|
||||
new RuntimeLibrary(
|
||||
"package",
|
||||
"PackageName",
|
||||
"1.2.3",
|
||||
"HASH",
|
||||
new RuntimeAssembly[] { },
|
||||
new []
|
||||
{
|
||||
new ResourceAssembly("en-US/Fruits.resources.dll", "en-US")
|
||||
},
|
||||
new RuntimeTarget[] { },
|
||||
new Dependency[] { },
|
||||
true
|
||||
),
|
||||
}));
|
||||
|
||||
var targets = result.Should().HavePropertyAsObject("targets").Subject;
|
||||
var target = targets.Should().HavePropertyAsObject("Target").Subject;
|
||||
var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
|
||||
var resources = library.Should().HavePropertyAsObject("resources").Subject;
|
||||
var resource = resources.Should().HavePropertyAsObject("en-US/Fruits.resources.dll").Subject;
|
||||
resource.Should().HavePropertyValue("locale", "en-US");
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void WritesCompilationOptions()
|
||||
{
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyModel.Tests
|
||||
{
|
||||
public class RuntimeAssemblyTests
|
||||
{
|
||||
[Fact]
|
||||
public void UsesFileNameAsAssemblyNameInCreate()
|
||||
{
|
||||
var assembly = RuntimeAssembly.Create("path/to/System.Collections.dll");
|
||||
assembly.Name.Name.Should().Be("System.Collections");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TrimsDotNiFromDllNames()
|
||||
{
|
||||
var assembly = RuntimeAssembly.Create("path/to/System.Collections.ni.dll");
|
||||
assembly.Name.Name.Should().Be("System.Collections");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
"FluentAssertions": "4.0.0",
|
||||
"moq.netcore": "4.4.0-beta8",
|
||||
"xunit": "2.1.0",
|
||||
"dotnet-test-xunit": "1.0.0-dev-79755-47"
|
||||
"dotnet-test-xunit": "1.0.0-dev-91790-12"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
|
@ -24,6 +24,5 @@
|
|||
}
|
||||
},
|
||||
|
||||
|
||||
"testRunner": "xunit"
|
||||
}
|
55
test/dotnet-build.Tests/BuildInvalidArgumentsTests.cs
Normal file
55
test/dotnet-build.Tests/BuildInvalidArgumentsTests.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System.IO;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Builder.Tests
|
||||
{
|
||||
public class BuildInvalidArgumentsTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void ErrorOccursWhenBuildingPortableProjectToSpecificOutputPathWithoutSpecifyingFramework()
|
||||
{
|
||||
var testInstance = TestAssetsManager.CreateTestInstance("BuildTestPortableProject")
|
||||
.WithLockFiles();
|
||||
|
||||
var result = new BuildCommand(
|
||||
projectPath: testInstance.TestRoot,
|
||||
output: Path.Combine(testInstance.TestRoot, "out"))
|
||||
.ExecuteWithCapturedOutput();
|
||||
|
||||
result.Should().Fail();
|
||||
result.Should().HaveStdErrContaining("When the '--output' option is provided, the '--framework' option must also be provided.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ErrorOccursWhenBuildingPortableProjectAndSpecifyingFrameworkThatProjectDoesNotSupport()
|
||||
{
|
||||
var testInstance = TestAssetsManager.CreateTestInstance("BuildTestPortableProject")
|
||||
.WithLockFiles();
|
||||
|
||||
var result = new BuildCommand(
|
||||
projectPath: testInstance.TestRoot,
|
||||
output: Path.Combine(testInstance.TestRoot, "out"),
|
||||
framework: "sl40")
|
||||
.ExecuteWithCapturedOutput();
|
||||
|
||||
result.Should().Fail();
|
||||
result.Should().HaveStdErrContaining("Project does not support framework: Silverlight,Version=v4.0.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ErrorOccursWhenBuildingStandaloneProjectToSpecificOutputPathWithoutSpecifyingFramework()
|
||||
{
|
||||
var testInstance = TestAssetsManager.CreateTestInstance("BuildTestStandaloneProject")
|
||||
.WithLockFiles();
|
||||
|
||||
var result = new BuildCommand(
|
||||
projectPath: testInstance.TestRoot,
|
||||
output: Path.Combine(testInstance.TestRoot, "out"))
|
||||
.ExecuteWithCapturedOutput();
|
||||
|
||||
result.Should().Fail();
|
||||
result.Should().HaveStdErrContaining("When the '--output' option is provided, the '--framework' option must also be provided.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
|||
"TestApp" + FileNameSuffixes.DotNet.ProgramDatabase,
|
||||
"TestApp" + FileNameSuffixes.CurrentPlatform.Exe,
|
||||
"TestApp" + FileNameSuffixes.Deps,
|
||||
"TestApp" + FileNameSuffixes.DepsJson,
|
||||
"TestLibrary" + FileNameSuffixes.DotNet.DynamicLib,
|
||||
"TestLibrary" + FileNameSuffixes.DotNet.ProgramDatabase
|
||||
};
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue