1+ <!--
2+ ***********************************************************************************************
3+ Microsoft.CSharpExtension.DesignTime.targets
4+
5+ A polyfill for the real Microsoft.CSharp.DesignTime.targets file that is supplied by the .NET
6+ project system in Visual Studio and the C# Dev Kit extension.
7+ https://github.com/dotnet/project-system/blob/8ba13c7fa917b86462e0ff32a07ef3e15eb8dfa6/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/DesignTimeTargets/Microsoft.CSharp.DesignTime.targets
8+
9+ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
10+ created a backup copy. Incorrect changes to this file will make it
11+ impossible to load or build your projects from the command-line or the IDE.
12+
13+ Copyright (c) .NET Foundation. All rights reserved.
14+ ***********************************************************************************************
15+ -->
16+
17+ <Project >
18+
19+ <!-- Razor cohosting support for projects that don't use the Razor SDK -->
20+
21+ <!--
22+ If there are any .razor or .cshtml files in this project we want to do three things:
23+
24+ 1. Add a 'RazorWithoutSdk' capability to the project so tooling can light up as necessary
25+ 2. Reference the Razor source generator
26+ 3. Add each .razor and .cshtml file to the project as an AdditionalFiles item so the source generator can see it
27+ -->
28+
29+ <!-- .NET Framework uses a different editor in VS -->
30+ <Target Name =" DetectRazorOrCshtmlFiles" BeforeTargets =" AssignProjectConfiguration" Condition =" '$(UsingMicrosoftNETSdkRazor)' != 'true'" >
31+ <ItemGroup >
32+ <!-- Collect all Razor and CSHTML files -->
33+ <_RazorOrCshtmlFiles Include =" **\*.razor;**\*.cshtml" />
34+ </ItemGroup >
35+
36+ <!-- Add a capability to control initialization of Razor in the IDE -->
37+ <ItemGroup Condition =" '@(_RazorOrCshtmlFiles)' != ''" >
38+ <ProjectCapability Include =" RazorWithoutSdk" />
39+ </ItemGroup >
40+
41+ <!-- As a get out of jail card, we let users turn off anything impactful, but their IDE won't really work. -->
42+ <ItemGroup Condition =" '$(DisableAllRazorFilesAsAdditionalFiles)' != 'true' And '@(_RazorOrCshtmlFiles)' != ''" >
43+ <AdditionalFiles Include =" @(_RazorOrCshtmlFiles)" />
44+ </ItemGroup >
45+
46+ <ItemGroup Condition =" '$(DisableAutomaticRazorSourceGeneratorReference)' != 'true' And '@(_RazorOrCshtmlFiles)' != ''" >
47+ <!-- Our analyzer loader will redirect DLL loads to the right place for tooling, as long as the right filename is referenced -->
48+ <Analyzer Include =" Microsoft.CodeAnalysis.Razor.Compiler.dll" />
49+ </ItemGroup >
50+ </Target >
51+
52+ </Project >
0 commit comments