From 19bc651858d49c3eb80af41f8f39c2b1b7aaa16f Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Wed, 2 Jan 2019 16:22:43 -0800 Subject: [PATCH] Add design-time MSBuild support for components \n\nCommit migrated from https://github.com/dotnet/aspnetcore-tooling/commit/f6f6e164672c0488115423f2db3d7ce1c1c92a1b --- ...Microsoft.NET.Sdk.Razor.DesignTime.targets | 8 ++++- .../Rules/RazorComponentWithTargetPath.xaml | 30 +++++++++++++++++++ .../Sdk.Razor.CurrentVersion.props | 5 ---- .../DesignTimeBuildIntegrationTest.cs | 24 +++++++++++++++ .../RazorTest.Introspection.targets | 4 +++ 5 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorComponentWithTargetPath.xaml diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets index cfb0e4e046..bd66729778 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets @@ -52,9 +52,15 @@ Copyright (c) .NET Foundation. All rights reserved. Project + + Project + - + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorComponentWithTargetPath.xaml b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorComponentWithTargetPath.xaml new file mode 100644 index 0000000000..14a479afe3 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorComponentWithTargetPath.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.props b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.props index 673a61d3da..71100e6541 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.props +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.props @@ -68,11 +68,6 @@ Copyright (c) .NET Foundation. All rights reserved. --> .g.cs - - .g.i.cs - true diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/DesignTimeBuildIntegrationTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/DesignTimeBuildIntegrationTest.cs index 6514e73057..7d5f88d9fb 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/DesignTimeBuildIntegrationTest.cs +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/DesignTimeBuildIntegrationTest.cs @@ -64,5 +64,29 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests $@"RazorGenerateWithTargetPath: {filePath} {filePath} {Path.Combine(RazorIntermediateOutputPath, filePath + ".g.cs")}"); } } + + [Fact] + [InitializeTestProject("ComponentLibrary")] + public async Task RazorGenerateDesignTime_ReturnsRazorComponentWithTargetPath() + { + TargetFramework = "netstandard2.0"; + + var result = await DotnetMSBuild("RazorGenerateDesignTime;_IntrospectRazorComponentWithTargetPath"); + + Assert.BuildPassed(result); + + var filePaths = new string[] + { + Path.Combine("MyComponent.cshtml"), + Path.Combine("GenericComponent.razor"), + }; + + foreach (var filePath in filePaths) + { + Assert.BuildOutputContainsLine( + result, + $@"RazorComponentWithTargetPath: {filePath} {filePath} {Path.Combine(RazorIntermediateOutputPath, filePath + ".g.cs")} {Path.Combine(RazorComponentIntermediateOutputPath, filePath + ".g.cs")}"); + } + } } } diff --git a/src/Razor/test/testassets/RazorTest.Introspection.targets b/src/Razor/test/testassets/RazorTest.Introspection.targets index f0e8f860ab..b3e93737f3 100644 --- a/src/Razor/test/testassets/RazorTest.Introspection.targets +++ b/src/Razor/test/testassets/RazorTest.Introspection.targets @@ -3,6 +3,10 @@ + + + +