Merge branch 'rel/2.0.2' into dev

This commit is contained in:
Nate McMaster 2017-10-18 14:16:34 -07:00
Родитель 3bc47cc442 bccf097cd0
Коммит 3ab1a7033f
31 изменённых файлов: 402 добавлений и 90 удалений

Просмотреть файл

@ -16,9 +16,11 @@ This project is part of ASP.NET Core. You can find samples, documentation and ge
Channel | Latest Build
-------------|----------------
dev | ![badge][dev-badge]
rel/2.0.2 | ![badge][rel-2.0.2-badge]
rel/2.0.0 | ![badge][rel-2.0.0-badge]
[dev-badge]: https://aspnetcore.blob.core.windows.net/buildtools/korebuild/channels/dev/badge.svg
[rel-2.0.2-badge]: https://aspnetcore.blob.core.windows.net/buildtools/korebuild/channels/rel/2.0.2/badge.svg
[rel-2.0.0-badge]: https://aspnetcore.blob.core.windows.net/buildtools/korebuild/channels/rel/2.0.0/badge.svg
This tool contains build scripts, console tools, MSBuild targets, and other settings required to build ASP.NET Core.

Просмотреть файл

@ -18,6 +18,7 @@
<PropertyGroup>
<_KoreBuildIntermediateDir>$(IntermediateDir)korebuild\</_KoreBuildIntermediateDir>
<_KoreBuildIntermediateDir>$([MSBuild]::NormalizeDirectory($(_KoreBuildIntermediateDir)))</_KoreBuildIntermediateDir>
<_KoreBuildOutDir>$(ArtifactsDir)korebuild\artifacts\$(Version)\</_KoreBuildOutDir>
<_ChannelOutDir>$(ArtifactsDir)korebuild\channels\$(KoreBuildChannel)\</_ChannelOutDir>
</PropertyGroup>

Просмотреть файл

@ -9,8 +9,10 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\shared\Utilities\MSBuildListSplitter.cs" />
<Compile Include="..\..\modules\BuildTools.Tasks\Utilities\**" />
<Compile Include="..\..\modules\BuildTools.Tasks\GetGitCommitInfo.cs" />
<Compile Include="..\..\modules\BuildTools.Tasks\GenerateFileFromTemplate.cs" />
<Compile Include="..\..\modules\BuildTools.Tasks\ZipArchive.cs" />
</ItemGroup>

Просмотреть файл

@ -4,6 +4,7 @@
</PropertyGroup>
<UsingTask TaskName="Microsoft.AspNetCore.BuildTools.GetGitCommitInfo" AssemblyFile="$(_RepoTaskAssembly)" />
<UsingTask TaskName="Microsoft.AspNetCore.BuildTools.GenerateFileFromTemplate" AssemblyFile="$(_RepoTaskAssembly)" />
<UsingTask TaskName="Microsoft.AspNetCore.BuildTools.ZipArchive" AssemblyFile="$(_RepoTaskAssembly)" />
<UsingTask TaskName="RepoTasks.GenerateBadge" AssemblyFile="$(_RepoTaskAssembly)" />
</Project>

Просмотреть файл

@ -32,11 +32,11 @@ Default layout and configuration.
<Configuration Condition="'$(CI)' == 'true'">Release</Configuration>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<SolutionProperties>$(SolutionProperties);Configuration=$(Configuration)</SolutionProperties>
<RepositoryRoot Condition="'$(RepositoryRoot)' == ''">$(MSBuildStartupDirectory)..\..\</RepositoryRoot>
<RepositoryRoot>$([MSBuild]::EnsureTrailingSlash('$(RepositoryRoot)'))</RepositoryRoot>
<ArtifactsDir>$(RepositoryRoot)artifacts\</ArtifactsDir>
<RepositoryRoot Condition="'$(RepositoryRoot)' == ''">$(MSBuildStartupDirectory)</RepositoryRoot>
<RepositoryRoot>$([MSBuild]::NormalizeDirectory('$(RepositoryRoot)'))</RepositoryRoot>
<ArtifactsDir>$([MSBuild]::NormalizeDirectory('$(RepositoryRoot)'))artifacts\</ArtifactsDir>
<BuildDir>$(ArtifactsDir)build\</BuildDir>
<IntermediateDir>$(RepositoryRoot)obj\</IntermediateDir>
<IntermediateDir>$([MSBuild]::NormalizeDirectory('$(RepositoryRoot)'))obj\</IntermediateDir>
</PropertyGroup>
<!-- Use build number from CI if available -->

Просмотреть файл

@ -12,6 +12,24 @@ if (Get-Command 'dotnet' -ErrorAction Ignore) {
Set-Variable 'IS_WINDOWS' -Scope Script -Option Constant -Value $((Get-Variable -Name IsWindows -ValueOnly -ErrorAction Ignore) -or !(Get-Variable -Name IsCoreClr -ValueOnly -ErrorAction Ignore))
Set-Variable 'EXE_EXT' -Scope Script -Option Constant -Value $(if ($IS_WINDOWS) { '.exe' } else { '' })
### setup config
$script:config = @{
'dotnet.feed.cdn' = 'https://dotnetcli.azureedge.net/dotnet'
'dotnet.feed.uncached' = 'https://dotnetcli.blob.core.windows.net/dotnet'
'dotnet.feed.credential' = $null
}
if ($env:KOREBUILD_DOTNET_FEED_CDN) {
$script:config.'dotnet.feed.cdn' = $env:KOREBUILD_DOTNET_FEED_CDN
}
if ($env:KOREBUILD_DOTNET_FEED_UNCACHED) {
$script:config.'dotnet.feed.uncached' = $env:KOREBUILD_DOTNET_FEED_UNCACHED
}
if ($env:KOREBUILD_DOTNET_FEED_CREDENTIAL) {
$script:config.'dotnet.feed.credential' = $env:KOREBUILD_DOTNET_FEED_CREDENTIAL
}
<#
.SYNOPSIS
Builds a repository
@ -195,7 +213,10 @@ function Install-Tools(
-Channel $channel `
-Version $version `
-Architecture $arch `
-InstallDir $installDir
-InstallDir $installDir `
-AzureFeed $script:config.'dotnet.feed.cdn' `
-UncachedFeed $script:config.'dotnet.feed.uncached' `
-FeedCredential $script:config.'dotnet.feed.credential'
}
else {
Write-Host -ForegroundColor DarkGray ".NET Core SDK $version is already installed. Skipping installation."
@ -479,7 +500,10 @@ function __install_shared_runtime($installScript, $installDir, [string]$arch, [s
-SharedRuntime `
-Version $version `
-Architecture $arch `
-InstallDir $installDir
-InstallDir $installDir `
-AzureFeed $script:config.'dotnet.feed.cdn' `
-UncachedFeed $script:config.'dotnet.feed.uncached' `
-FeedCredential $script:config.'dotnet.feed.credential'
}
else {
Write-Host -ForegroundColor DarkGray ".NET Core runtime $version is already installed. Skipping installation."

12
files/KoreBuild/scripts/dotnet-install.ps1 поставляемый
Просмотреть файл

@ -49,10 +49,13 @@
.PARAMETER AzureFeed
Default: https://dotnetcli.azureedge.net/dotnet
This parameter typically is not changed by the user.
It allows to change URL for the Azure feed used by this installer.
It allows changing the URL for the Azure feed used by this installer.
.PARAMETER UncachedFeed
This parameter typically is not changed by the user.
It allows to change URL for the Uncached feed used by this installer.
It allows changing the URL for the Uncached feed used by this installer.
.PARAMETER FeedCredential
Used as a query string to append to the Azure feed.
It allows changing the URL to use non-public blob storage accounts.
.PARAMETER ProxyAddress
If set, the installer will use the proxy when making web requests
.PARAMETER ProxyUseDefaultCredentials
@ -73,6 +76,7 @@ param(
[switch]$NoPath,
[string]$AzureFeed="https://dotnetcli.azureedge.net/dotnet",
[string]$UncachedFeed="https://dotnetcli.blob.core.windows.net/dotnet",
[string]$FeedCredential,
[string]$ProxyAddress,
[switch]$ProxyUseDefaultCredentials,
[switch]$SkipNonVersionedFiles
@ -193,9 +197,11 @@ function GetHTTPResponse([Uri] $Uri)
# Default timeout for HttpClient is 100s. For a 50 MB download this assumes 500 KB/s average, any less will time out
# 10 minutes allows it to work over much slower connections.
$HttpClient.Timeout = New-TimeSpan -Minutes 10
$Response = $HttpClient.GetAsync($Uri).Result
$ActualUri = if (($Uri -like "$AzureFeed*") -or ($Uri -like "$UncachedFeed*")) { "${Uri}${FeedCredential}" } else { $Uri }
$Response = $HttpClient.GetAsync($ActualUri).Result
if (($Response -eq $null) -or (-not ($Response.IsSuccessStatusCode)))
{
# The feed credential is potential sensitive info. Do not log it to console output.
$ErrorMsg = "Failed to download $Uri."
if ($Response -ne $null)
{

39
files/KoreBuild/scripts/dotnet-install.sh поставляемый
Просмотреть файл

@ -580,6 +580,11 @@ downloadcurl() {
local remote_path=$1
local out_path=${2:-}
# Append feed_credential as late as possible before calling curl to avoid logging feed_credential
if [[ "$remote_path" == "$azure_feed"* ]] || [[ "$remote_path" == "$uncached_feed"* ]]; then
remote_path="${remote_path}${feed_credential}"
fi
local failed=false
if [ -z "$out_path" ]; then
curl --retry 10 -sSL -f --create-dirs $remote_path || failed=true
@ -598,6 +603,11 @@ downloadwget() {
local remote_path=$1
local out_path=${2:-}
# Append feed_credential as late as possible before calling wget to avoid logging feed_credential
if [[ "$remote_path" == "$azure_feed"* ]] || [[ "$remote_path" == "$uncached_feed"* ]]; then
remote_path="${remote_path}${feed_credential}"
fi
local failed=false
if [ -z "$out_path" ]; then
wget -q --tries 10 $remote_path || failed=true
@ -684,6 +694,7 @@ dry_run=false
no_path=false
azure_feed="https://dotnetcli.azureedge.net/dotnet"
uncached_feed="https://dotnetcli.blob.core.windows.net/dotnet"
feed_credential=""
verbose=false
shared_runtime=false
runtime_id=""
@ -729,6 +740,10 @@ do
shift
uncached_feed="$1"
;;
--feed-credential|-[Ff]eed[Cc]redential)
shift
feed_credential="$1"
;;
--runtime-id|-[Rr]untime[Ii]d)
shift
runtime_id="$1"
@ -763,22 +778,24 @@ do
echo " coherent applies only to SDK downloads"
echo " - 3-part version in a format A.B.C - represents specific version of build"
echo " examples: 2.0.0-preview2-006120; 1.1.0"
echo " -i,--install-dir <DIR> Install under specified location (see Install Location below)"
echo " -i,--install-dir <DIR> Install under specified location (see Install Location below)"
echo " -InstallDir"
echo " --architecture <ARCHITECTURE> Architecture of .NET Tools. Currently only x64 is supported."
echo " --architecture <ARCHITECTURE> Architecture of .NET Tools. Currently only x64 is supported."
echo " --arch,-Architecture,-Arch"
echo " --shared-runtime Installs just the shared runtime bits, not the entire SDK."
echo " --shared-runtime Installs just the shared runtime bits, not the entire SDK."
echo " -SharedRuntime"
echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable."
echo " --debug-symbols,-DebugSymbols Specifies if symbols should be included in the installation."
echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable."
echo " -SkipNonVersionedFiles"
echo " --dry-run,-DryRun Do not perform installation. Display download link."
echo " --no-path, -NoPath Do not set PATH for the current process."
echo " --verbose,-Verbose Display diagnostics information."
echo " --azure-feed,-AzureFeed Azure feed location. Defaults to $azure_feed, This parameter typically is not changed by the user."
echo " --uncached-feed,-UncachedFeed Uncached feed location. This parameter typically is not changed by the user."
echo " --runtime-id Installs the .NET Tools for the given platform (use linux-x64 for portable linux)."
echo " --dry-run,-DryRun Do not perform installation. Display download link."
echo " --no-path, -NoPath Do not set PATH for the current process."
echo " --verbose,-Verbose Display diagnostics information."
echo " --azure-feed,-AzureFeed Azure feed location. Defaults to $azure_feed, This parameter typically is not changed by the user."
echo " --uncached-feed,-UncachedFeed Uncached feed location. This parameter typically is not changed by the user."
echo " --feed-credential,-FeedCredential Azure feed shared access token. This parameter typically is not specified."
echo " --runtime-id Installs the .NET Tools for the given platform (use linux-x64 for portable linux)."
echo " -RuntimeId"
echo " -?,--?,-h,--help,-Help Shows this help message"
echo " -?,--?,-h,--help,-Help Shows this help message"
echo ""
echo "Install Location:"
echo " Location is chosen in following order:"

Просмотреть файл

@ -9,6 +9,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\shared\Utilities\MSBuildListSplitter.cs" />
<Compile Include="..\..\shared\Microsoft.Extensions.CommandLineUtils.Sources\**\*.cs" />
<None Include="module.props" CopyToPublishDirectory="PreserveNewest" />
<None Include="BuildTools.Tasks.props" CopyToPublishDirectory="PreserveNewest" />

Просмотреть файл

@ -1,6 +1,7 @@
<Project>
<UsingTask TaskName="Microsoft.AspNetCore.BuildTools.$(_BuildTasksPrefix)GenerateResxDesignerFiles" AssemblyFile="$(_BuildToolsAssembly)" />
<UsingTask TaskName="Microsoft.AspNetCore.BuildTools.$(_BuildTasksPrefix)GenerateFileFromTemplate" AssemblyFile="$(_BuildToolsAssembly)" />
<UsingTask TaskName="Microsoft.AspNetCore.BuildTools.$(_BuildTasksPrefix)GetAssemblyFileVersion" AssemblyFile="$(_BuildToolsAssembly)" />
<UsingTask TaskName="Microsoft.AspNetCore.BuildTools.$(_BuildTasksPrefix)GetGitCommitInfo" AssemblyFile="$(_BuildToolsAssembly)" />
<UsingTask TaskName="Microsoft.AspNetCore.BuildTools.$(_BuildTasksPrefix)GetDotNetHost" AssemblyFile="$(_BuildToolsAssembly)"

Просмотреть файл

@ -0,0 +1,153 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.IO;
using System.Text;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.AspNetCore.BuildTools
{
/// <summary>
/// <para>
/// Generates a new file at <see cref="OutputPath"/>.
/// </para>
/// <para>
/// The <see cref="TemplateFile"/> can define variables for substitution using <see cref="Properties"/>.
/// </para>
/// <example>
/// The input file might look like this:
/// <code>
/// 2 + 2 = ${Sum}
/// </code>
/// When the task is invoked like this, it will produce "2 + 2 = 4"
/// <code>
/// &lt;GenerateFileFromTemplate Properties="Sum=4;OtherValue=123;" ... &gt;
/// </code>
/// </example>
/// </summary>
#if SDK
public class Sdk_GenerateFileFromTemplate : Task
#elif BuildTools
public class GenerateFileFromTemplate : Task
#else
#error This must be built either for an SDK or for BuildTools
#endif
{
/// <summary>
/// The template file.
/// Variable syntax: ${VarName}
/// If your template file needs to output this format, you can escape the dollar sign with a backtick, e.g. `${NotReplaced}
/// </summary>
[Required]
public string TemplateFile { get; set; }
/// <summary>
/// The destination for the generated file.
/// </summary>
[Required]
[Output]
public string OutputPath { get; set; }
/// <summary>
/// Key=value pairs of values
/// </summary>
[Required]
public string[] Properties { get; set; }
public override bool Execute()
{
var outputPath = Path.GetFullPath(OutputPath.Replace('\\', '/'));
if (!File.Exists(TemplateFile))
{
Log.LogError($"File {TemplateFile} does not exist");
return false;
}
var values = MSBuildListSplitter.GetNamedProperties(Properties);
var template = File.ReadAllText(TemplateFile);
var result = Replace(template, values);
Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
File.WriteAllText(outputPath, result);
return true;
}
internal string Replace(string template, IDictionary<string, string> values)
{
var sb = new StringBuilder();
var varNameSb = new StringBuilder();
var line = 1;
for (var i = 0; i < template.Length; i++)
{
var ch = template[i];
var nextCh = i + 1 >= template.Length
? '\0'
: template[i + 1];
// count lines in the template file
if (ch == '\n')
{
line++;
}
if (ch == '`' && (nextCh == '$' || nextCh == '`'))
{
// skip the backtick for known escape characters
i++;
sb.Append(nextCh);
continue;
}
if (ch != '$' || nextCh != '{')
{
// variables begin with ${. Moving on.
sb.Append(ch);
continue;
}
varNameSb.Clear();
i += 2;
for (; i < template.Length; i++)
{
ch = template[i];
if (ch != '}')
{
varNameSb.Append(ch);
}
else
{
// Found the end of the variable substitution
var varName = varNameSb.ToString();
if (values.TryGetValue(varName, out var value))
{
sb.Append(value);
}
else
{
Log.LogWarning(null, null, null, TemplateFile,
line, 0, 0, 0,
message: $"No property value is available for '{varName}'");
}
varNameSb.Clear();
break;
}
}
if (varNameSb.Length > 0)
{
Log.LogWarning(null, null, null, TemplateFile,
line, 0, 0, 0,
message: "Expected closing bracket for variable placeholder. No substitution will be made.");
sb.Append("${").Append(varNameSb.ToString());
}
}
return sb.ToString();
}
}
}

Просмотреть файл

@ -0,0 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("BuildTools.Tasks.Tests")]

Просмотреть файл

@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.BuildTools
public override bool Execute()
{
var workDir = FileHelpers.EnsureTrailingSlash(WorkingDirectory);
var workDir = FileHelpers.EnsureTrailingSlash(WorkingDirectory).Replace('\\', '/');
foreach (var file in SourceFiles)
{
@ -54,15 +54,16 @@ namespace Microsoft.AspNetCore.BuildTools
continue;
}
if (!file.ItemSpec.StartsWith(workDir))
var filePath = file.ItemSpec.Replace('\\', '/');
if (!filePath.StartsWith(workDir))
{
Log.LogError("Item {0} is not inside the working directory {1}. Set the metadata 'Link' to file path that should be used within the zip archive",
file.ItemSpec,
filePath,
workDir);
return false;
}
file.SetMetadata("Link", file.ItemSpec.Substring(workDir.Length));
file.SetMetadata("Link", filePath.Substring(workDir.Length));
}
var fileMode = Overwrite

Просмотреть файл

@ -9,11 +9,11 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Build.Framework;
using Newtonsoft.Json;
using KoreBuild.Tasks.Policies;
using KoreBuild.Tasks.ProjectModel;
using KoreBuild.Tasks.Utilties;
using Microsoft.AspNetCore.BuildTools;
using Microsoft.Build.Framework;
using Newtonsoft.Json;
namespace KoreBuild.Tasks
{
@ -51,18 +51,18 @@ namespace KoreBuild.Tasks
/// Key-value base list of properties to be applied to <see cref="Projects" /> during project evaluation.
/// e.g. "Configuration=Debug;BuildNumber=1234"
/// </summary>
public string ProjectProperties { get; set; }
public string[] ProjectProperties { get; set; }
/// <summary>
/// NuGet sources, ; delimited. When set, they override sources from NuGet.config.
/// NuGet sources. When set, they override sources from NuGet.config.
/// </summary>
public string RestoreSources { get; set; }
public string[] RestoreSources { get; set; }
/// <summary>
/// NuGet sources, ; delimited.
/// NuGet sources.
/// When set they are in addition to source from NuGet.config and/or <see cref="RestoreSources"/>.
/// </summary>
public string RestoreAdditionalSources { get; set; }
public string[] RestoreAdditionalSources { get; set; }
/// <summary>
/// User packages folder
@ -124,8 +124,8 @@ namespace KoreBuild.Tasks
SolutionDirectory = SolutionDirectory,
Projects = projects,
Log = Log,
RestoreSources = MSBuildListSplitter.SplitItemList(RestoreSources).ToList(),
RestoreAdditionalSources = MSBuildListSplitter.SplitItemList(RestoreAdditionalSources).ToList(),
RestoreSources = RestoreSources?.ToList() ?? new List<string>(),
RestoreAdditionalSources = RestoreAdditionalSources?.ToList() ?? new List<string>(),
RestorePackagesPath = RestorePackagesPath,
RestoreDisableParallel = RestoreDisableParallel,
RestoreConfigFile = RestoreConfigFile,

Просмотреть файл

@ -8,9 +8,8 @@ using System.Linq;
using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Execution;
using NuGet.Frameworks;
using KoreBuild.Tasks.Utilties;
using Microsoft.Build.Utilities;
using NuGet.Frameworks;
namespace KoreBuild.Tasks.ProjectModel
{
@ -81,7 +80,7 @@ namespace KoreBuild.Tasks.ProjectModel
var noWarn = item.GetMetadataValue("NoWarn");
IReadOnlyList<string> noWarnItems = string.IsNullOrEmpty(noWarn)
? Array.Empty<string>()
: MSBuildListSplitter.SplitItemList(noWarn).ToArray();
: noWarn.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
var info = new PackageReferenceInfo(item.EvaluatedInclude, item.GetMetadataValue("Version"), isImplicit, noWarnItems);

Просмотреть файл

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
@ -9,6 +9,7 @@
<Content Include="*.props" CopyToPublishDirectory="PreserveNewest" />
<Content Include="*.targets" CopyToPublishDirectory="PreserveNewest" />
<Compile Include="..\..\shared\Microsoft.Extensions.CommandLineUtils.Sources\Utilities\*.cs" />
<Compile Include="..\..\shared\Utilities\MSBuildListSplitter.cs" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -4,12 +4,12 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.AspNetCore.BuildTools;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NuGet.Frameworks;
using NuGet.Packaging;
using NuGet.Packaging.Core;
using KoreBuild.Tasks.Utilties;
using NuGet.Versioning;
namespace KoreBuild.Tasks
@ -26,7 +26,7 @@ namespace KoreBuild.Tasks
public ITaskItem[] Dependencies { get; set; }
public string Properties { get; set; }
public string[] Properties { get; set; }
public bool IncludeEmptyDirectories { get; set; } = false;

Просмотреть файл

@ -1,45 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
namespace KoreBuild.Tasks.Utilties
{
public static class MSBuildListSplitter
{
private static readonly char[] SemiColon = { ';' };
public static IEnumerable<string> SplitItemList(string value)
{
return string.IsNullOrEmpty(value)
? Enumerable.Empty<string>()
: value.Split(SemiColon, StringSplitOptions.RemoveEmptyEntries);
}
public static IDictionary<string, string> GetNamedProperties(string input)
{
var values = new Dictionary<string, string>();
if (string.IsNullOrEmpty(input))
{
return values;
}
foreach (var item in input.Split(SemiColon, StringSplitOptions.RemoveEmptyEntries))
{
var splitIdx = item.IndexOf('=');
if (splitIdx <= 0)
{
continue;
}
var key = item.Substring(0, splitIdx);
var value = item.Substring(splitIdx + 1);
values[key] = value;
}
return values;
}
}
}

Просмотреть файл

@ -53,5 +53,4 @@
DotNetHome="$(DOTNET_HOME)"
InstallScript="$(_DotNetInstall)"/>
</Target>
</Project>

Просмотреть файл

@ -1,4 +1,6 @@
<Project>
<Import Project="..\..\build\tasks\RepoTasks.tasks" />
<Target Name="Publish">
<ItemGroup>
<Projects Include="$(MSBuildThisFileDirectory)console\NuGetPackageVerifier.Console.csproj" />
@ -10,5 +12,15 @@
Properties="PublishDir=$(PublishDir);Configuration=$(Configuration)" />
<Copy SourceFiles="module.targets" DestinationFolder="$(PublishDir)" />
<MSBuild Projects="$(MSBuildThisFileDirectory)console\NuGetPackageVerifier.Console.csproj"
Targets="GetRuntimeVersion"
Properties="Configuration=$(Configuration)">
<Output TaskParameter="TargetOutputs" PropertyName="NgpvRuntimeFrameworkVersion" />
</MSBuild>
<GenerateFileFromTemplate TemplateFile="$(MSBuildThisFileDirectory)module.props.in"
Properties="RuntimeFrameworkVersion=$(NgpvRuntimeFrameworkVersion)"
OutputPath="$(PublishDir)module.props" />
</Target>
</Project>

Просмотреть файл

@ -20,4 +20,6 @@
<PackageReference Include="NuGet.Packaging" Version="$(NuGetPackagesVersion)" />
</ItemGroup>
<Target Name="GetRuntimeVersion" Returns="$(RuntimeFrameworkVersion)" />
</Project>

Просмотреть файл

@ -0,0 +1,6 @@
<Project>
<ItemGroup>
<!-- Ensure we have the runtime required to execute the nuget package verifier -->
<DotNetCoreRuntime Include="${RuntimeFrameworkVersion}" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,50 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
namespace Microsoft.AspNetCore.BuildTools
{
internal static class MSBuildListSplitter
{
public static IDictionary<string, string> GetNamedProperties(string input)
{
if (string.IsNullOrEmpty(input))
{
return new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
}
return GetNamedProperties(input.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
}
public static IDictionary<string, string> GetNamedProperties(string[] input)
{
var values = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
if (input == null)
{
return values;
}
foreach (var item in input)
{
var splitIdx = item.IndexOf('=');
if (splitIdx < 0)
{
continue;
}
var key = item.Substring(0, splitIdx).Trim();
if (string.IsNullOrEmpty(key))
{
continue;
}
var value = item.Substring(splitIdx + 1);
values[key] = value;
}
return values;
}
}
}

Просмотреть файл

@ -21,6 +21,7 @@
<Compile Include="$(BuildToolsPath)*.cs" />
<Compile Include="$(BuildToolsPath)Utilities\*.cs" />
<Compile Include="..\..\shared\Microsoft.Extensions.CommandLineUtils.Sources\**\*.cs" />
<Compile Include="..\..\shared\Utilities\MSBuildListSplitter.cs" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -13,6 +13,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="$(MicrosoftBuildVersion)" />
<PackageReference Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildVersion)" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildVersion)" />
<PackageReference Include="Microsoft.DotNet.Cli.Utils" Version="$(DotNetCliUtilsVersion)" />

Просмотреть файл

@ -0,0 +1,69 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using Microsoft.AspNetCore.BuildTools;
using Xunit;
namespace BuildTools.Tasks.Tests
{
public class GenerateFileFromTemplateTests
{
[Fact]
public void WarnsForMissingVariableNames()
{
var engine = new MockEngine();
var task = new GenerateFileFromTemplate
{
BuildEngine = engine,
};
Assert.Equal("Hello !", task.Replace("Hello ${World}!", new Dictionary<string, string>()));
var warning = Assert.Single(engine.Warnings);
Assert.Contains("No property value", warning.Message);
}
[Fact]
public void WarnsWhenExpectingClosingBrace()
{
var engine = new MockEngine();
var task = new GenerateFileFromTemplate
{
BuildEngine = engine,
};
Assert.Equal("Hello ${Greeting!", task.Replace("Hello ${Greeting!", new Dictionary<string, string>()));
var warning = Assert.Single(engine.Warnings);
Assert.Contains("Expected closing bracket", warning.Message);
}
[Theory]
[MemberData(nameof(SubsitutionData))]
public void SubsitutesVariableNames(string template, IDictionary<string, string> variables, string output)
{
var engine = new MockEngine();
var task = new GenerateFileFromTemplate
{
BuildEngine = engine,
};
Assert.Equal(output, task.Replace(template, variables));
Assert.Empty(engine.Warnings);
}
public static TheoryData<string, IDictionary<string, string>, string> SubsitutionData
=> new TheoryData<string, IDictionary<string, string>, string>
{
{"`", new Dictionary<string,string> {}, "`" },
{"`other", new Dictionary<string,string> {}, @"`other" },
{"```$", new Dictionary<string,string> {}, "`$" },
{"``", new Dictionary<string,string> {}, "`" },
{"`$", new Dictionary<string,string> {}, "$" },
{@"`${Hello", new Dictionary<string,string> {}, @"${Hello" },
{"Hello ${Greeting}", new Dictionary<string,string> {["Greeting"] = "World"}, "Hello World" },
{@"Hello `${Greeting}", new Dictionary<string,string> {["Greeting"] = "World"}, @"Hello ${Greeting}" },
{"Hello ${Greeting}!", new Dictionary<string,string> {["Greeting"] = "World"}, @"Hello World!" },
{"${One}${Two}${Three}", new Dictionary<string,string> {["One"] = "1", ["Two"]="2", ["Three"] = "3"}, "123" },
};
}
}

Просмотреть файл

@ -138,7 +138,7 @@ EndGlobal
MSBuildEnvironmentHelper.InitializeEnvironment(_output);
var task = new ApplyNuGetPolicies
{
ProjectProperties = "BuildNumber=123;Configuration=Release",
ProjectProperties = new[] { "BuildNumber=123", "Configuration=Release" },
Projects = items,
BuildEngine = new MockEngine(),
};

Просмотреть файл

@ -98,7 +98,7 @@ namespace KoreBuild.Tasks.Tests
BasePath = _tempDir,
BuildEngine = new MockEngine(),
DestinationFolder = _tempDir,
Properties = $"version={version};;description={description};copyright=;;;;",
Properties = new[] { $"version={version}", "", "", $" description ={description}", "copyright=", },
};
Assert.True(task.Execute(), "The task should have passed");

Просмотреть файл

@ -4,6 +4,7 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git \
# KoreBuild dependencies
jq \
curl \
unzip \
apt-transport-https \

Просмотреть файл

@ -14,7 +14,8 @@
"default": "dev",
"enum": [
"dev",
"rel/2.0.0"
"rel/2.0.0",
"rel/2.0.2"
]
}
}

Просмотреть файл

@ -3,6 +3,6 @@
<KoreBuildChannel>dev</KoreBuildChannel>
<VersionPrefix>2.1.0</VersionPrefix>
<VersionSuffix>preview1</VersionSuffix>
<VersionSuffix Condition="'$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
<VersionSuffix Condition="'$(VersionSuffix)' != '' AND '$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
</PropertyGroup>
</Project>