Correctly set UpToDateReloadFileTypes (dotnet/aspnetcore-tooling#858)

* Correctly set UpToDateReloadFileTypes

UpToDateReloadFileTypes was incorrectly set in the preview6 DesignTime targets and this was worked
around in the SDK's targets. Unfortunately the updated copy of DesignTime targets (current as of 7/13)
also has a bug.

This fixes the issue and adds some tests to verify we're correct with the past, present & future.

Fixes https://github.com/aspnet/AspNetCore/issues/11873

\n\nCommit migrated from 525d0c1ad3
This commit is contained in:
Pranav K 2019-07-22 09:16:09 -07:00 committed by GitHub
parent d30eb2f58e
commit c9ed74d84a
4 changed files with 68 additions and 12 deletions

View File

@ -17,7 +17,7 @@ Copyright (c) .NET Foundation. All rights reserved.
Defines the list of file extensions that VS will monitor to reload the application.
We'll only define these for C# projects targeting RazorLangVersion 3.0 or later, and let VS use defaults in other cases.
-->
<UpToDateReloadFileTypes Condition="'$(Language)'=='C#' AND '$(_Targeting30OrNewerRazorLangVersion)' == 'true' AND '$(RazorUpToDateReloadFileTypes)' == ''">$(UpToDateReloadFileTypes);$(RazorUpToDateReloadFileTypes)</UpToDateReloadFileTypes>
<UpToDateReloadFileTypes Condition="'$(Language)'=='C#' AND '$(_Targeting30OrNewerRazorLangVersion)' == 'true' AND '$(RazorUpToDateReloadFileTypes)' != ''">$(UpToDateReloadFileTypes);$(RazorUpToDateReloadFileTypes)</UpToDateReloadFileTypes>
</PropertyGroup>
<ItemGroup>
@ -42,7 +42,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<ProjectCapability Include="WebNestingDefaults" />
</ItemGroup>
<!--
<!--
For now we need to treat component files as if they have a single file generator. This will allow us
to trigger a workspace update for the declaration files when they change.
-->
@ -84,9 +84,9 @@ Copyright (c) .NET Foundation. All rights reserved.
</PropertyPageSchema>
</ItemGroup>
<Target
Name="RazorGenerateDesignTime"
DependsOnTargets="ResolveRazorGenerateInputs;AssignRazorGenerateTargetPaths"
<Target
Name="RazorGenerateDesignTime"
DependsOnTargets="ResolveRazorGenerateInputs;AssignRazorGenerateTargetPaths"
Returns="@(RazorGenerateWithTargetPath)">
</Target>
@ -94,9 +94,9 @@ Copyright (c) .NET Foundation. All rights reserved.
Using DependsOnTargets here because real dependencies of this target aren't defined in
a downlevel (pre-3.0) SDK.
-->
<Target
Name="RazorGenerateComponentDesignTime"
DependsOnTargets="$(_RazorGenerateComponentDesignTimeDependsOn)"
<Target
Name="RazorGenerateComponentDesignTime"
DependsOnTargets="$(_RazorGenerateComponentDesignTimeDependsOn)"
Returns="@(RazorComponentWithTargetPath)">
</Target>
@ -107,8 +107,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Called by the project system to update generated declaration files
-->
<Target
Name="RazorGenerateComponentDeclarationDesignTime"
<Target
Name="RazorGenerateComponentDeclarationDesignTime"
DependsOnTargets="$(_RazorGenerateComponentDeclarationDesignTimeDependsOn)">
</Target>

View File

@ -865,14 +865,14 @@ Copyright (c) .NET Foundation. All rights reserved.
<Import Project="$(RazorDesignTimeTargets)" />
<PropertyGroup>
<PropertyGroup Condition="'$(_RazorUpToDateReloadFileTypesAllowWorkaround)' != 'false'">
<!--
Defines the list of file extensions that VS will monitor to reload the application.
We'll only define these for C# projects targeting RazorLangVersion 3.0 or later, and let VS use defaults in other cases.
This property can be removed after the next insertion in to VS.
-->
<UpToDateReloadFileTypes Condition="'$(Language)'=='C#' AND '$(_Targeting30OrNewerRazorLangVersion)' == 'true' AND '$(RazorUpToDateReloadFileTypes)' == ''">$(RazorUpToDateReloadFileTypes)</UpToDateReloadFileTypes>
<UpToDateReloadFileTypes Condition="'$(Language)'=='C#' AND '$(_Targeting30OrNewerRazorLangVersion)' == 'true' AND '$(UpToDateReloadFileTypes)' == ''">$(RazorUpToDateReloadFileTypes)</UpToDateReloadFileTypes>
</PropertyGroup>
<!--

View File

@ -142,5 +142,57 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.BuildOutputContainsLine(result, "RazorLangVersion: 3.0");
Assert.BuildOutputContainsLine(result, "ResolvedRazorConfiguration: MVC-3.0");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task UpToDateReloadFileTypes_Default()
{
var result = await DotnetMSBuild("_IntrospectUpToDateReloadFileTypes");
Assert.BuildPassed(result);
Assert.BuildOutputContainsLine(result, "UpToDateReloadFileTypes: ;.cs;.razor;.resx;.cshtml");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task UpToDateReloadFileTypes_WithRuntimeCompilation()
{
AddProjectFileContent(
@"
<PropertyGroup>
<RazorUpToDateReloadFileTypes>$(RazorUpToDateReloadFileTypes.Replace('.cshtml', ''))</RazorUpToDateReloadFileTypes>
</PropertyGroup>");
var result = await DotnetMSBuild("_IntrospectUpToDateReloadFileTypes");
Assert.BuildPassed(result);
Assert.BuildOutputContainsLine(result, "UpToDateReloadFileTypes: ;.cs;.razor;.resx;");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task UpToDateReloadFileTypes_WithwWorkAroundRemoved()
{
var result = await DotnetMSBuild("_IntrospectUpToDateReloadFileTypes", "/p:_RazorUpToDateReloadFileTypesAllowWorkaround=false");
Assert.BuildPassed(result);
Assert.BuildOutputContainsLine(result, "UpToDateReloadFileTypes: ;.cs;.razor;.resx;.cshtml");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task UpToDateReloadFileTypes_WithRuntimeCompilationAndWorkaroundRemoved()
{
AddProjectFileContent(
@"
<PropertyGroup>
<RazorUpToDateReloadFileTypes>$(RazorUpToDateReloadFileTypes.Replace('.cshtml', ''))</RazorUpToDateReloadFileTypes>
</PropertyGroup>");
var result = await DotnetMSBuild("_IntrospectUpToDateReloadFileTypes", "/p:_RazorUpToDateReloadFileTypesAllowWorkaround=false");
Assert.BuildPassed(result);
Assert.BuildOutputContainsLine(result, "UpToDateReloadFileTypes: ;.cs;.razor;.resx;");
}
}
}

View File

@ -38,4 +38,8 @@
<Message Text="RazorLangVersion: $(RazorLangVersion)" Importance="High" />
<Message Text="ResolvedRazorConfiguration: @(ResolvedRazorConfiguration)" Importance="High" />
</Target>
<Target Name="_IntrospectUpToDateReloadFileTypes">
<Message Text="UpToDateReloadFileTypes: $(UpToDateReloadFileTypes)" Importance="High" />
</Target>
</Project>