Browse Source

Allow dotnet-watch to look for changes to .razor.css files (#25792)

Fixes https://github.com/dotnet/aspnetcore/issues/25483
Pranav K 5 years ago
parent
commit
ab5dfe5374

+ 12 - 0
src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/BuildIntrospectionTest.cs

@@ -275,5 +275,17 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
             Assert.BuildPassed(result);
             Assert.BuildOutputContainsLine(result, $"RazorTasksPath: {expected}");
         }
+
+        [Fact]
+        [InitializeTestProject("ComponentApp")]
+        public async Task IntrospectRazorSdkWatchItems()
+        {
+            // Arrange
+            var result = await DotnetMSBuild("_IntrospectWatchItems");
+
+            Assert.BuildPassed(result);
+            Assert.BuildOutputContainsLine(result, "Watch: Index.razor");
+            Assert.BuildOutputContainsLine(result, "Watch: Index.razor.css");
+        }
     }
 }

+ 1 - 1
src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets

@@ -877,7 +877,7 @@ Copyright (c) .NET Foundation. All rights reserved.
   <Target Name="_RazorSdkCustomCollectWatchItems">
     <ItemGroup>
       <Watch Include="%(Content.FullPath)" Condition="'%(Content.Extension)' == '.razor' AND '%(Content.Watch)' != 'false'" />
-      <Watch Include="%(Content.FullPath)" Condition="'%(Content.Extension)' == '.razor.css' AND '%(Content.Watch)' != 'false'" />
+      <Watch Include="%(None.FullPath)" Condition="$([System.String]::Copy('%(None.FullPath)').EndsWith('.razor.css')) AND '%(None.Watch)' != 'false'" />
       <Watch Include="%(Content.FullPath)"
         Condition="'$(_Targeting30OrNewerRazorLangVersion)' == 'true' AND '$(AddCshtmlFilesToDotNetWatchList)' != 'false' AND '%(Content.Extension)' == '.cshtml' AND '%(Content.Watch)' != 'false'" />
     </ItemGroup>

+ 4 - 0
src/Razor/test/testassets/RazorTest.Introspection.targets

@@ -47,6 +47,10 @@
     <Message Text="Content: %(Content.Identity) CopyToOutputDirectory=%(Content.CopyToOutputDirectory) CopyToPublishDirectory=%(Content.CopyToPublishDirectory) ExcludeFromSingleFile=%(Content.ExcludeFromSingleFile)" Importance="High" />
   </Target>
 
+  <Target Name="_IntrospectWatchItems" DependsOnTargets="_RazorSdkCustomCollectWatchItems">
+    <Message Text="Watch: %(Watch.FileName)%(Watch.Extension)" Importance="High" />
+  </Target>
+
   <Target Name="_IntrospectRazorTasks">
     <PropertyGroup>
       <_SdkTaskPath>$([System.IO.Path]::GetFullPath('$(RazorSdkBuildTasksAssembly)'))</_SdkTaskPath>