From a03cb48c7a427c4265f5b8a458d8df93bf258721 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Sun, 14 Jan 2018 14:40:57 +0000 Subject: [PATCH] When compiling Razor components, take base namespace from host project --- .../Cli/Commands/BuildRazorCommand.cs | 7 +++++-- .../targets/RazorCompilation.targets | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.Blazor.Build/Cli/Commands/BuildRazorCommand.cs b/src/Microsoft.Blazor.Build/Cli/Commands/BuildRazorCommand.cs index f9acd45ec8..4a7451a7c2 100644 --- a/src/Microsoft.Blazor.Build/Cli/Commands/BuildRazorCommand.cs +++ b/src/Microsoft.Blazor.Build/Cli/Commands/BuildRazorCommand.cs @@ -25,13 +25,16 @@ namespace Microsoft.Blazor.Build.Cli.Commands var outputFilePath = command.Option("--output", "The location where the resulting C# source file should be written", CommandOptionType.SingleValue); + var baseNamespace = command.Option("--namespace", + "The base namespace for the generated C# classes.", + CommandOptionType.SingleValue); var verboseFlag = command.Option("--verbose", "Indicates that verbose console output should written", CommandOptionType.NoValue); command.OnExecute(() => { - if (!VerifyRequiredOptionsProvided(sourceDirPath, outputFilePath)) + if (!VerifyRequiredOptionsProvided(sourceDirPath, outputFilePath, baseNamespace)) { return 1; } @@ -49,7 +52,7 @@ namespace Microsoft.Blazor.Build.Cli.Commands var diagnostics = new RazorCompiler().CompileFiles( sourceDirPathValue, inputRazorFilePaths, - "Blazor", // TODO: Add required option for namespace + baseNamespace.Value(), outputWriter, verboseFlag.HasValue() ? Console.Out : null); diff --git a/src/Microsoft.Blazor.Build/targets/RazorCompilation.targets b/src/Microsoft.Blazor.Build/targets/RazorCompilation.targets index 290fc0e884..1eaa949419 100644 --- a/src/Microsoft.Blazor.Build/targets/RazorCompilation.targets +++ b/src/Microsoft.Blazor.Build/targets/RazorCompilation.targets @@ -1,11 +1,11 @@  - BlazorComponents + $(RootNamespace) true $(IntermediateOutputPath)BlazorRazorComponents.g.cs - +