When compiling Razor components, take base namespace from host project
This commit is contained in:
parent
a32b857d96
commit
a03cb48c7a
|
|
@ -25,13 +25,16 @@ namespace Microsoft.Blazor.Build.Cli.Commands
|
||||||
var outputFilePath = command.Option("--output",
|
var outputFilePath = command.Option("--output",
|
||||||
"The location where the resulting C# source file should be written",
|
"The location where the resulting C# source file should be written",
|
||||||
CommandOptionType.SingleValue);
|
CommandOptionType.SingleValue);
|
||||||
|
var baseNamespace = command.Option("--namespace",
|
||||||
|
"The base namespace for the generated C# classes.",
|
||||||
|
CommandOptionType.SingleValue);
|
||||||
var verboseFlag = command.Option("--verbose",
|
var verboseFlag = command.Option("--verbose",
|
||||||
"Indicates that verbose console output should written",
|
"Indicates that verbose console output should written",
|
||||||
CommandOptionType.NoValue);
|
CommandOptionType.NoValue);
|
||||||
|
|
||||||
command.OnExecute(() =>
|
command.OnExecute(() =>
|
||||||
{
|
{
|
||||||
if (!VerifyRequiredOptionsProvided(sourceDirPath, outputFilePath))
|
if (!VerifyRequiredOptionsProvided(sourceDirPath, outputFilePath, baseNamespace))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -49,7 +52,7 @@ namespace Microsoft.Blazor.Build.Cli.Commands
|
||||||
var diagnostics = new RazorCompiler().CompileFiles(
|
var diagnostics = new RazorCompiler().CompileFiles(
|
||||||
sourceDirPathValue,
|
sourceDirPathValue,
|
||||||
inputRazorFilePaths,
|
inputRazorFilePaths,
|
||||||
"Blazor", // TODO: Add required option for namespace
|
baseNamespace.Value(),
|
||||||
outputWriter,
|
outputWriter,
|
||||||
verboseFlag.HasValue() ? Console.Out : null);
|
verboseFlag.HasValue() ? Console.Out : null);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
<Project>
|
<Project>
|
||||||
<Target Name="BlazorCompileRazorComponents" BeforeTargets="CoreCompile">
|
<Target Name="BlazorCompileRazorComponents" BeforeTargets="CoreCompile">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<BlazorComponentsNamespace>BlazorComponents</BlazorComponentsNamespace>
|
<BlazorComponentsNamespace>$(RootNamespace)</BlazorComponentsNamespace>
|
||||||
<IsDesignTimeBuild Condition="'$(DesignTimeBuild)' == 'true' OR '$(BuildingProject)' != 'true'">true</IsDesignTimeBuild>
|
<IsDesignTimeBuild Condition="'$(DesignTimeBuild)' == 'true' OR '$(BuildingProject)' != 'true'">true</IsDesignTimeBuild>
|
||||||
<GeneratedFilePath>$(IntermediateOutputPath)BlazorRazorComponents.g.cs</GeneratedFilePath>
|
<GeneratedFilePath>$(IntermediateOutputPath)BlazorRazorComponents.g.cs</GeneratedFilePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Exec Command="$(BlazorBuildExe) buildrazor --source $(ProjectDir) --output $(GeneratedFilePath)" />
|
<Exec Command="$(BlazorBuildExe) buildrazor --source $(ProjectDir) --namespace $(BlazorComponentsNamespace) --output $(GeneratedFilePath)" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="$(GeneratedFilePath)" />
|
<Compile Include="$(GeneratedFilePath)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue