Fixup invalid configuration error message (dotnet/aspnetcore-tooling#365)

* Fix invalid parameter used in error message
* Re-organize test code\n\nCommit migrated from 5a73c2abe9
This commit is contained in:
Pranav K 2019-03-26 08:58:38 -07:00 committed by GitHub
parent 9c35c07a0b
commit 6eb9044660
3 changed files with 44 additions and 27 deletions

View File

@ -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.
-->
<Warning Text="Unable to resolve a Razor configuration for the value '$(_RazorConfiguration)'. Available configurations '@(RazorConfiguration)'.'"
Code="RazorSDK1000"
<Warning Text="Unable to resolve a Razor configuration for the value '$(RazorDefaultConfiguration)'. Available configurations '@(RazorConfiguration->'%(Identity)', ', ')'.'"
Code="RAZORSDK1000"
Condition="'@(ResolvedRazorConfiguration->Count())' == '0'" />
<Warning Text="More than one Razor configuration was resolved for the value '$(_RazorConfiguration)'. Available configurations '@(RazorConfiguration)'.
A common cause is a reference to an incompatible version of the 'Microsoft.AspNetCore.Mvc' or 'Microsoft.AspNetCore.Razor.Design' package."
Code="RazorSDK1001"
<Warning Text="More than one Razor configuration was resolved for the value '$(RazorDefaultConfiguration)'. Available configurations '@(RazorConfiguration->'%(Identity)', ', ')'."
Code="RAZORSDK1001"
Condition="'@(ResolvedRazorConfiguration->Count())' &gt; '1'" />
<FindInList

View File

@ -606,28 +606,6 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.Equal(firstAssemblyBytes, secondAssemblyBytes);
}
[Fact]
[InitializeTestProject("SimpleMvc21")]
public async Task Building_WorksWhenMultipleRazorConfigurationsArePresent()
{
TargetFramework = "netcoreapp2.1";
AddProjectFileContent(@"
<ItemGroup>
<RazorConfiguration Include=""MVC-2.1"">
<Extensions>MVC-2.1;$(CustomRazorExtension)</Extensions>
</RazorConfiguration>
</ItemGroup>");
// 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(@"
<PropertyGroup>
<RazorDefaultConfiguration>Custom12.3</RazorDefaultConfiguration>
</PropertyGroup>");
var result = await DotnetMSBuild("Build");
Assert.BuildWarning(result, "RAZORSDK1000");
}
private static DependencyContext ReadDependencyContext(string depsFilePath)
{
var reader = new DependencyContextJsonReader();

View File

@ -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(@"
<ItemGroup>
<RazorConfiguration Include=""MVC-2.1"">
<Extensions>MVC-2.1;$(CustomRazorExtension)</Extensions>
</RazorConfiguration>
</ItemGroup>");
// 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");
}
}
}
}