Ensure updates to Razor components trigger design time build

* Use _RazorComponentInclude to determine the set of files to set Generator property for
* Run RazorGenerateComponentDeclarationDesignTime instead of RazorComponentGenerate during design time builds
* Update design time targets to set Generator for content files with .razor extension.

Fixes https://github.com/aspnet/AspNetCore/issues/6859
Fixes https://github.com/aspnet/AspNetCore/issues/6860
\n\nCommit migrated from 37d96aa417
This commit is contained in:
Pranav K 2019-01-18 17:54:20 -08:00
parent 2bbd247b13
commit ada61cf03d
2 changed files with 25 additions and 3 deletions

View File

@ -34,9 +34,12 @@ Copyright (c) .NET Foundation. All rights reserved.
to trigger a workspace update for the declaration files when they change.
-->
<ItemGroup>
<Content Update="@(RazorComponent)">
<Content Update="**\*.razor">
<Generator>MSBuild:RazorGenerateComponentDeclarationDesignTime</Generator>
</Content>
<Content Update="$(_RazorComponentInclude)">
<Generator>MSBuild:RazorGenerateComponentDeclarationDesignTime</Generator>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</Content>
</ItemGroup>

View File

@ -92,11 +92,16 @@ Copyright (c) .NET Foundation. All rights reserved.
_RazorAddDebugSymbolsProjectOutputGroupOutput
</DebugSymbolsProjectOutputGroupDependsOn>
<CoreCompileDependsOn>
<CoreCompileDependsOn Condition="'$(DesignTimeBuild)'!='true'">
RazorComponentGenerate;
$(CoreCompileDependsOn)
</CoreCompileDependsOn>
<CoreCompileDependsOn Condition="'$(DesignTimeBuild)'=='true'">
RazorGenerateComponentDeclarationDesignTime;
$(CoreCompileDependsOn)
</CoreCompileDependsOn>
<PrepareForBuildDependsOn>
$(PrepareForBuildDependsOn);
ResolveRazorGenerateInputs
@ -408,8 +413,22 @@ Copyright (c) .NET Foundation. All rights reserved.
<RazorComponent Include="@(Content)" Condition="'%(Content.Extension)'=='.razor'" />
<RazorComponent Include="$(_RazorComponentInclude)" />
</ItemGroup>
<ItemGroup>
<Content Condition="'%(Content.Extension)'=='.razor'" CopyToPublishDirectory="Never" />
</ItemGroup>
</Target>
<!--
Temporarary workaround for https://github.com/aspnet/AspNetCore/issues/6859. This can be removed after a VS insertion with a newer copy of the DesignTime targets.
-->
<ItemGroup>
<Content Update="$(_RazorComponentInclude)">
<Generator>MSBuild:RazorGenerateComponentDeclarationDesignTime</Generator>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</Content>
</ItemGroup>
<Target Name="AssignRazorComponentTargetPaths" Condition="'@(RazorComponent)' != ''">
<AssignTargetPath Files="@(RazorComponent)" RootFolder="$(MSBuildProjectDirectory)">
<Output TaskParameter="AssignedFiles" ItemName="RazorComponentWithTargetPath" />