Add design-time MSBuild support for components
\n\nCommit migrated from f6f6e16467
This commit is contained in:
parent
14abd88648
commit
19bc651858
|
|
@ -52,9 +52,15 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)Rules\RazorGenerateWithTargetPath.xaml">
|
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)Rules\RazorGenerateWithTargetPath.xaml">
|
||||||
<Context>Project</Context>
|
<Context>Project</Context>
|
||||||
</PropertyPageSchema>
|
</PropertyPageSchema>
|
||||||
|
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)Rules\RazorComponentWithTargetPath.xaml">
|
||||||
|
<Context>Project</Context>
|
||||||
|
</PropertyPageSchema>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="RazorGenerateDesignTime" DependsOnTargets="ResolveRazorGenerateInputs;AssignRazorGenerateTargetPaths" Returns="@(RazorGenerateWithTargetPath)">
|
<Target
|
||||||
|
Name="RazorGenerateDesignTime"
|
||||||
|
DependsOnTargets="ResolveRazorGenerateInputs;AssignRazorGenerateTargetPaths;ResolveRazorComponentInputs;AssignRazorComponentTargetPaths"
|
||||||
|
Returns="@(RazorGenerateWithTargetPath);@(RazorComponentWithTargetPath)">
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Rule
|
||||||
|
Description="Razor Document Properties"
|
||||||
|
DisplayName="Razor Document Properties"
|
||||||
|
Name="RazorGenerateWithTargetPath"
|
||||||
|
PageTemplate="generic"
|
||||||
|
xmlns="http://schemas.microsoft.com/build/2009/properties">
|
||||||
|
<Rule.DataSource>
|
||||||
|
<DataSource
|
||||||
|
Persistence="ProjectFile"
|
||||||
|
ItemType="RazorComponentWithTargetPath"
|
||||||
|
MSBuildTarget="RazorGenerateDesignTime"
|
||||||
|
HasConfigurationCondition="False"
|
||||||
|
SourceOfDefaultValue="AfterContext"
|
||||||
|
SourceType="TargetResults" />
|
||||||
|
</Rule.DataSource>
|
||||||
|
|
||||||
|
<Rule.Categories>
|
||||||
|
<Category
|
||||||
|
Name="General"
|
||||||
|
DisplayName="General" />
|
||||||
|
</Rule.Categories>
|
||||||
|
|
||||||
|
<StringProperty
|
||||||
|
Category="General"
|
||||||
|
Name="TargetPath"
|
||||||
|
ReadOnly="True"
|
||||||
|
Visible="False" />
|
||||||
|
|
||||||
|
</Rule>
|
||||||
|
|
@ -68,11 +68,6 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
-->
|
-->
|
||||||
<RazorGenerateOutputFileExtension>.g.cs</RazorGenerateOutputFileExtension>
|
<RazorGenerateOutputFileExtension>.g.cs</RazorGenerateOutputFileExtension>
|
||||||
|
|
||||||
<!--
|
|
||||||
Configures the file extension used for the generated C# definition files.
|
|
||||||
-->
|
|
||||||
<RazorGenerateOutputDefinitionFileExtension>.g.i.cs</RazorGenerateOutputDefinitionFileExtension>
|
|
||||||
|
|
||||||
<PreserveCompilationContext>true</PreserveCompilationContext>
|
<PreserveCompilationContext>true</PreserveCompilationContext>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,5 +64,29 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
$@"RazorGenerateWithTargetPath: {filePath} {filePath} {Path.Combine(RazorIntermediateOutputPath, filePath + ".g.cs")}");
|
$@"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")}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@
|
||||||
<Message Text="RazorGenerateWithTargetPath: %(RazorGenerateWithTargetPath.Identity) %(RazorGenerateWithTargetPath.TargetPath) %(RazorGenerateWithTargetPath.GeneratedOutput)" Importance="High" />
|
<Message Text="RazorGenerateWithTargetPath: %(RazorGenerateWithTargetPath.Identity) %(RazorGenerateWithTargetPath.TargetPath) %(RazorGenerateWithTargetPath.GeneratedOutput)" Importance="High" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="_IntrospectRazorComponentWithTargetPath">
|
||||||
|
<Message Text="RazorComponentWithTargetPath: %(RazorComponentWithTargetPath.Identity) %(RazorComponentWithTargetPath.TargetPath) %(RazorComponentWithTargetPath.GeneratedOutput) %(RazorComponentWithTargetPath.GeneratedDeclaration)" Importance="High" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
<Target Name="_IntrospectRazorEmbeddedResources">
|
<Target Name="_IntrospectRazorEmbeddedResources">
|
||||||
<Message Text="CompileResource: %(_RazorCoreCompileResourceInputs.Identity) %(_RazorCoreCompileResourceInputs.LogicalName)" Importance="High" />
|
<Message Text="CompileResource: %(_RazorCoreCompileResourceInputs.Identity) %(_RazorCoreCompileResourceInputs.LogicalName)" Importance="High" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue