From 6eb90446609b2e18c1e5f30171ac4620912f520c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 26 Mar 2019 08:58:38 -0700 Subject: [PATCH] Fixup invalid configuration error message (dotnet/aspnetcore-tooling#365) * Fix invalid parameter used in error message * Re-organize test code\n\nCommit migrated from https://github.com/dotnet/aspnetcore-tooling/commit/5a73c2abe9284a8b0bbc5bbd0b81431f1c592ee0 --- .../Sdk.Razor.CurrentVersion.targets | 9 +++-- .../IntegrationTests/BuildIntegrationTest.cs | 36 ++++++++----------- .../BuildIntegrationTest21.cs | 26 ++++++++++++++ 3 files changed, 44 insertions(+), 27 deletions(-) diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets index f1ac38844b..065201d247 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -372,13 +372,12 @@ Copyright (c) .NET Foundation. All rights reserved. ResolvedRazorConfiguration should only ever have one item in it. If misconfigured, we may resolve more than one item which may result in incorrect results or poorly worded build errors. --> - - - - MVC-2.1;$(CustomRazorExtension) - -"); - - // Build - var result = await DotnetMSBuild("Build"); - - Assert.BuildPassed(result); - Assert.FileExists(result, OutputPath, "SimpleMvc21.dll"); - Assert.FileExists(result, OutputPath, "SimpleMvc21.pdb"); - Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.dll"); - Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.pdb"); - } - [Fact] [InitializeTestProject("SimpleMvc")] public async Task Build_WithoutServer_ErrorDuringBuild_DisplaysErrorInMsBuildOutput() @@ -690,6 +668,20 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.BuildWarning(result, "RAZORSDK1004"); } + [Fact] + [InitializeTestProject("ClassLibrary")] + public async Task Build_WithNoResolvedRazorConfiguration() + { +AddProjectFileContent(@" + + Custom12.3 +"); + + var result = await DotnetMSBuild("Build"); + + Assert.BuildWarning(result, "RAZORSDK1000"); + } + private static DependencyContext ReadDependencyContext(string depsFilePath) { var reader = new DependencyContextJsonReader(); diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest21.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest21.cs index a513f29aa7..9b317f0bd0 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest21.cs +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest21.cs @@ -1,6 +1,9 @@ // 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.Threading.Tasks; +using Xunit; + namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { public class BuildIntegrationTest21 : BuildIntegrationTestLegacy @@ -12,5 +15,28 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests public override string TestProjectName => "SimpleMvc21"; public override string TargetFramework => "netcoreapp2.1"; + + [Fact] + public async Task Building_WorksWhenMultipleRazorConfigurationsArePresent() + { + using (var project = CreateTestProject()) + { + AddProjectFileContent(@" + + + MVC-2.1;$(CustomRazorExtension) + +"); + + // Build + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + Assert.FileExists(result, OutputPath, "SimpleMvc21.dll"); + Assert.FileExists(result, OutputPath, "SimpleMvc21.pdb"); + Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.dll"); + Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.pdb"); + } + } } }