Skip to content

Commit 93d5371

Browse files
authored
Disable Razor Source generators from VS Design time builds (#16702)
Follow up to #16648. We want to continue allowing source generators from being used in design time builds outside of Visual Studio. This is required for hot reload of Razor files (.razor and .cshtml files) to continue working.
1 parent 19a05b9 commit 93d5371

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/RazorSdk/Targets/Microsoft.NET.Sdk.Razor.SourceGenerators.targets

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ Copyright (c) .NET Foundation. All rights reserved.
99
-->
1010

1111
<Project ToolsVersion="14.0">
12-
<!-- Temporary workaround for design-time and build-time files being produced at
13-
the same time. See https://github.com/dotnet/sdk/pull/16648 for more info. -->
1412
<Target Name="_PrepareRazorSourceGenerators"
15-
Condition="'$(DesignTimeBuild)'!='true'"
1613
BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun"
1714
DependsOnTargets="PrepareForRazorGenerate;PrepareForRazorComponentGenerate">
1815

@@ -28,7 +25,11 @@ Copyright (c) .NET Foundation. All rights reserved.
2825
<_RazorAnalyzer Include="$(_RazorSdkToolsDirectoryRoot)Microsoft.CodeAnalysis.Razor.dll" />
2926
<_RazorAnalyzer Include="$(_RazorSdkSourceGeneratorDirectoryRoot)Microsoft.NET.Sdk.Razor.SourceGenerators.dll" />
3027

31-
<Analyzer Include="@(_RazorAnalyzer)" />
28+
<!--
29+
Temporary workaround for design-time and build-time files being produced at
30+
the same time. See https://github.com/dotnet/sdk/pull/16648 for more info.
31+
-->
32+
<Analyzer Include="@(_RazorAnalyzer)" Condition="'$(BuildingInsideVisualStudio)' != 'true' OR '$(DesignTimeBuild)' != 'true'" />
3233

3334
<RazorComponentWithTargetPath
3435
GeneratedOutputFullPath="$([System.IO.Path]::GetFullPath(%(GeneratedOutput)))"

0 commit comments

Comments
 (0)