Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Commit 9d2c394

Browse files
committed
SDK does not correctly resolve RazorExtension when multiple instances of RazorConfiguration are present
Fixes #2721
1 parent d3482e7 commit 9d2c394

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,10 @@ Copyright (c) .NET Foundation. All rights reserved.
276276
Condition="'$(RazorDefaultConfiguration)'!=''">
277277

278278
<ItemGroup>
279-
<ResolvedRazorConfiguration Include="@(RazorConfiguration)" Condition="'%(RazorConfiguration.Identity)'=='$(RazorDefaultConfiguration)'" />
279+
<ResolvedRazorConfiguration Include="@(RazorConfiguration->WithMetadataValue('Identity', '$(RazorDefaultConfiguration)')->Distinct())" />
280280
</ItemGroup>
281281

282-
<FindInList List="@(RazorExtension)" ItemSpecToFind="@(RazorConfiguration->Metadata('Extensions'))">
282+
<FindInList List="@(RazorExtension)" ItemSpecToFind="@(ResolvedRazorConfiguration->Metadata('Extensions'))">
283283
<Output TaskParameter="ItemFound" ItemName="ResolvedRazorExtension" />
284284
</FindInList>
285285
</Target>

test/Microsoft.NET.Sdk.Razor.Test/IntegrationTests/BuildIntegrationTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,28 @@ public async Task Building_NETCoreApp21TargetingProject()
630630
Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.pdb");
631631
}
632632

633+
[Fact]
634+
[InitializeTestProject("SimpleMvc21")]
635+
public async Task Building_WorksWhenMultipleRazorConfigurationsArePresent()
636+
{
637+
TargetFramework = "netcoreapp2.1";
638+
AddProjectFileContent(@"
639+
<ItemGroup>
640+
<RazorConfiguration Include=""MVC-2.1"">
641+
<Extensions>MVC-2.1;$(CustomRazorExtension)</Extensions>
642+
</RazorConfiguration>
643+
</ItemGroup>");
644+
645+
// Build
646+
var result = await DotnetMSBuild("Build");
647+
648+
Assert.BuildPassed(result);
649+
Assert.FileExists(result, OutputPath, "SimpleMvc21.dll");
650+
Assert.FileExists(result, OutputPath, "SimpleMvc21.pdb");
651+
Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.dll");
652+
Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.pdb");
653+
}
654+
633655
private static DependencyContext ReadDependencyContext(string depsFilePath)
634656
{
635657
var reader = new DependencyContextJsonReader();

test/testapps/SimpleMvc21/SimpleMvc21.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<TargetFramework>netcoreapp2.1</TargetFramework>
1010
</PropertyGroup>
1111

12+
<!-- Test Placeholder -->
13+
1214
<PropertyGroup Condition="'$(RunningAsTest)' == ''">
1315
<!-- We don't want to run build server when not running as tests. -->
1416
<UseRazorBuildServer>false</UseRazorBuildServer>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
@using SimpleMvc
22
@using SimpleMvc.Models
33
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4+
@namespace SimpleMvc21

0 commit comments

Comments
 (0)