SDK does not correctly resolve RazorExtension when multiple instances of RazorConfiguration are present

Fixes https://github.com/aspnet/Razor/issues/2721
This commit is contained in:
Pranav K 2018-11-09 10:59:42 -08:00
parent d3482e7bd0
commit 9d2c394b99
4 changed files with 27 additions and 2 deletions

View File

@ -276,10 +276,10 @@ Copyright (c) .NET Foundation. All rights reserved.
Condition="'$(RazorDefaultConfiguration)'!=''">
<ItemGroup>
<ResolvedRazorConfiguration Include="@(RazorConfiguration)" Condition="'%(RazorConfiguration.Identity)'=='$(RazorDefaultConfiguration)'" />
<ResolvedRazorConfiguration Include="@(RazorConfiguration->WithMetadataValue('Identity', '$(RazorDefaultConfiguration)')->Distinct())" />
</ItemGroup>
<FindInList List="@(RazorExtension)" ItemSpecToFind="@(RazorConfiguration->Metadata('Extensions'))">
<FindInList List="@(RazorExtension)" ItemSpecToFind="@(ResolvedRazorConfiguration->Metadata('Extensions'))">
<Output TaskParameter="ItemFound" ItemName="ResolvedRazorExtension" />
</FindInList>
</Target>

View File

@ -630,6 +630,28 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.pdb");
}
[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");
}
private static DependencyContext ReadDependencyContext(string depsFilePath)
{
var reader = new DependencyContextJsonReader();

View File

@ -9,6 +9,8 @@
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<!-- Test Placeholder -->
<PropertyGroup Condition="'$(RunningAsTest)' == ''">
<!-- We don't want to run build server when not running as tests. -->
<UseRazorBuildServer>false</UseRazorBuildServer>

View File

@ -1,3 +1,4 @@
@using SimpleMvc
@using SimpleMvc.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@namespace SimpleMvc21