Fixup error on SDK restore

This commit is contained in:
Pranav K 2020-02-04 08:22:21 -08:00
parent f54902f169
commit af8aa0fe6e
No known key found for this signature in database
GPG Key ID: F748807460A27E91
7 changed files with 12 additions and 158 deletions

View File

@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<AspNetCoreBaselineVersion>3.1.1</AspNetCoreBaselineVersion>
<AspNetCoreBaselineVersion>3.1.2</AspNetCoreBaselineVersion>
</PropertyGroup>
<!-- Package: AspNetCoreRuntime.3.0.x64-->
<PropertyGroup Condition=" '$(PackageId)' == 'AspNetCoreRuntime.3.0.x64' ">

View File

@ -139,7 +139,6 @@ function InitializeDotNetCli([bool]$install) {
InstallDotNetSdk $dotnetRoot $dotnetSdkVersion
} else {
Write-PipelineTelemetryError -Category "InitializeToolset" -Message "Unable to find dotnet with SDK version '$dotnetSdkVersion'"
ExitWithExitCode 1
}
}
@ -184,7 +183,7 @@ function InstallDotNetSdk([string] $dotnetRoot, [string] $version, [string] $arc
InstallDotNet $dotnetRoot $version $architecture
}
function InstallDotNet([string] $dotnetRoot, [string] $version, [string] $architecture = "", [string] $runtime = "", [bool] $skipNonVersionedFiles = $false) {
function InstallDotNet([string] $dotnetRoot, [string] $version, [string] $architecture = "", [string] $runtime = "", [bool] $skipNonVersionedFiles = $true) {
$installScript = GetDotNetInstallScript $dotnetRoot
$installParameters = @{
Version = $version

View File

@ -41,7 +41,7 @@ fi
# Configures warning treatment in msbuild.
warn_as_error=${warn_as_error:-true}
# True to attempt using .NET Core already that meets requirements specified in global.json
# True to attempt using .NET Core already that meets requirements specified in global.json
# installed on the machine instead of downloading one.
use_installed_dotnet_cli=${use_installed_dotnet_cli:-true}
@ -143,7 +143,6 @@ function InitializeDotNetCli {
InstallDotNetSdk "$dotnet_root" "$dotnet_sdk_version"
else
Write-PipelineTelemetryError -category 'InitializeToolset' "Unable to find dotnet with SDK version '$dotnet_sdk_version'"
ExitWithExitCode 1
fi
fi
fi
@ -181,7 +180,7 @@ function InstallDotNetSdk {
function InstallDotNet {
local root=$1
local version=$2
GetDotNetInstallScript "$root"
local install_script=$_GetDotNetInstallScript
@ -222,7 +221,7 @@ function GetDotNetInstallScript {
Write-PipelineTelemetryError -category 'InitializeToolset' "Failed to acquire dotnet install script (exit code '$exit_code')."
ExitWithExitCode $exit_code
}
else
else
wget -q -O "$install_script" "$install_script_url" || {
local exit_code=$?
Write-PipelineTelemetryError -category 'InitializeToolset' "Failed to acquire dotnet install script (exit code '$exit_code')."
@ -238,11 +237,11 @@ function InitializeBuildTool {
if [[ -n "${_InitializeBuildTool:-}" ]]; then
return
fi
InitializeDotNetCli $restore
# return values
_InitializeBuildTool="$_InitializeDotNetCli/dotnet"
_InitializeBuildTool="$_InitializeDotNetCli/dotnet"
_InitializeBuildToolCommand="msbuild"
_InitializeBuildToolFramework="netcoreapp2.1"
}
@ -303,7 +302,7 @@ function InitializeToolset {
if [[ "$binary_log" == true ]]; then
bl="/bl:$log_dir/ToolsetRestore.binlog"
fi
echo '<Project Sdk="Microsoft.DotNet.Arcade.Sdk"/>' > "$proj"
MSBuild-Core "$proj" $bl /t:__WriteToolsetLocation /clp:ErrorsOnly\;NoSummary /p:__ToolsetLocationOutputFile="$toolset_location_file"

View File

@ -1,137 +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.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Templates.Test.Helpers;
using Xunit;
using Xunit.Abstractions;
namespace Templates.Test
{
public class BaselineTest
{
private static readonly Regex TemplateNameRegex = new Regex(
"new (?<template>[a-zA-Z]+)",
RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Singleline,
TimeSpan.FromSeconds(1));
private static readonly Regex AuthenticationOptionRegex = new Regex(
"-au (?<auth>[a-zA-Z]+)",
RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Singleline,
TimeSpan.FromSeconds(1));
private static readonly Regex LanguageRegex = new Regex(
"--language (?<language>\\w+)",
RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Singleline,
TimeSpan.FromSeconds(1));
public BaselineTest(ProjectFactoryFixture projectFactory, ITestOutputHelper output)
{
ProjectFactory = projectFactory;
Output = output;
}
public Project Project { get; set; }
public static TheoryData<string, string[]> TemplateBaselines
{
get
{
using (var stream = typeof(BaselineTest).Assembly.GetManifestResourceStream("ProjectTemplates.Tests.template-baselines.json"))
{
using (var jsonReader = new JsonTextReader(new StreamReader(stream)))
{
var baseline = JObject.Load(jsonReader);
var data = new TheoryData<string, string[]>();
foreach (var template in baseline)
{
foreach (var authOption in (JObject)template.Value)
{
data.Add(
(string)authOption.Value["Arguments"],
((JArray)authOption.Value["Files"]).Select(s => (string)s).ToArray());
}
}
return data;
}
}
}
}
public ProjectFactoryFixture ProjectFactory { get; }
public ITestOutputHelper Output { get; }
[Theory]
[MemberData(nameof(TemplateBaselines))]
public async Task Template_Produces_The_Right_Set_Of_FilesAsync(string arguments, string[] expectedFiles)
{
Project = await ProjectFactory.GetOrCreateProject("baseline" + SanitizeArgs(arguments), Output);
var createResult = await Project.RunDotNetNewRawAsync(arguments);
Assert.True(createResult.ExitCode == 0, createResult.GetFormattedOutput());
foreach (var file in expectedFiles)
{
AssertFileExists(Project.TemplateOutputDir, file, shouldExist: true);
}
var filesInFolder = Directory.EnumerateFiles(Project.TemplateOutputDir, "*", SearchOption.AllDirectories);
foreach (var file in filesInFolder)
{
var relativePath = file.Replace(Project.TemplateOutputDir, "").Replace("\\", "/").Trim('/');
if (relativePath.EndsWith(".csproj", StringComparison.Ordinal) ||
relativePath.EndsWith(".fsproj", StringComparison.Ordinal) ||
relativePath.EndsWith(".props", StringComparison.Ordinal) ||
relativePath.EndsWith(".targets", StringComparison.Ordinal) ||
relativePath.StartsWith("bin/", StringComparison.Ordinal) ||
relativePath.StartsWith("obj/", StringComparison.Ordinal))
{
continue;
}
Assert.Contains(relativePath, expectedFiles);
}
}
private string SanitizeArgs(string arguments)
{
var text = TemplateNameRegex.Match(arguments)
.Groups.TryGetValue("template", out var template) ? template.Value : "";
text += AuthenticationOptionRegex.Match(arguments)
.Groups.TryGetValue("auth", out var auth) ? auth.Value : "";
text += arguments.Contains("--uld") ? "uld" : "";
text += LanguageRegex.Match(arguments)
.Groups.TryGetValue("language", out var language) ? language.Value.Replace("#", "Sharp") : "";
if (arguments.Contains("--support-pages-and-views true"))
{
text += "supportpagesandviewstrue";
}
return text;
}
private void AssertFileExists(string basePath, string path, bool shouldExist)
{
var fullPath = Path.Combine(basePath, path);
var doesExist = File.Exists(fullPath);
if (shouldExist)
{
Assert.True(doesExist, "Expected file to exist, but it doesn't: " + path);
}
else
{
Assert.False(doesExist, "Expected file not to exist, but it does: " + path);
}
}
}
}

View File

@ -20,7 +20,7 @@ namespace Templates.Test
}
[Theory]
[InlineData("Microsoft.AspNetCore.Blazor.Templates")]
[InlineData("BlazorWasm.ProjectTemplates")]
public void JSAndJSONInAllTemplates_ShouldNotContainBOM(string projectName)
{
var currentDirectory = Directory.GetCurrentDirectory();

View File

@ -123,12 +123,7 @@ namespace Templates.Test.Helpers
}
}
await VerifyCannotFindTemplateAsync(output, "web");
await VerifyCannotFindTemplateAsync(output, "webapp");
await VerifyCannotFindTemplateAsync(output, "mvc");
await VerifyCannotFindTemplateAsync(output, "react");
await VerifyCannotFindTemplateAsync(output, "reactredux");
await VerifyCannotFindTemplateAsync(output, "angular");
await VerifyCannotFindTemplateAsync(output, "blazorwasm");
foreach (var packagePath in builtPackages)
{
@ -137,9 +132,7 @@ namespace Templates.Test.Helpers
Assert.True(result.ExitCode == 0, result.GetFormattedOutput());
}
await VerifyCanFindTemplate(output, "webapp");
await VerifyCanFindTemplate(output, "web");
await VerifyCanFindTemplate(output, "react");
await VerifyCanFindTemplate(output, "blazorwasm");
}
private static async Task VerifyCanFindTemplate(ITestOutputHelper output, string templateName)

View File

@ -30,7 +30,7 @@
<PropertyGroup>
<PropsProperties>
RestoreAdditionalProjectSources=$([MSBuild]::Escape("$(RestoreAdditionalProjectSources);$(ArtifactsShippingPackagesDir);$(ArtifactsNonShippingPackagesDir)"));
RestoreAdditionalProjectSources=$([MSBuild]::Escape("$(RestoreAdditionalProjectSources);$(ArtifactsShippingPackagesDir)"));
MicrosoftNetCompilersToolsetPackageVersion=$(MicrosoftNetCompilersToolsetPackageVersion);
MicrosoftNETCoreAppRuntimeVersion=$(MicrosoftNETCoreAppRuntimeVersion);
MicrosoftNETCoreAppRefPackageVersion=$(MicrosoftNETCoreAppRefPackageVersion);