File size: 7,046 Bytes
090629c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!--

***********************************************************************************************

Microsoft.NET.Sdk.Razor.CodeGeneration



WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have

          created a backup copy.  Incorrect changes to this file will make it

          impossible to load or build your projects from the command-line or the IDE.



Copyright (c) .NET Foundation. All rights reserved.

***********************************************************************************************

-->

<Project ToolsVersion="14.0">
  <!--

    Targets used for Razor SDK code generation. Support for the RazorCoreGenerate target.

    This target is explicitly imported by Razor SDK.

  -->

  <UsingTask

    TaskName="Microsoft.AspNetCore.Razor.Tasks.SdkRazorGenerate"

    AssemblyFile="$(RazorSdkBuildTasksAssembly)"

    Condition="'$(RazorSdkBuildTasksAssembly)' != ''" />

  <UsingTask

    TaskName="Microsoft.AspNetCore.Razor.Tasks.SdkRazorTagHelper"

    AssemblyFile="$(RazorSdkBuildTasksAssembly)"

    Condition="'$(RazorSdkBuildTasksAssembly)' != ''" />

  <!--

    Consider these properties to be private to this targets file. The main Razor SDK should define all of the properties

    that we use to pass data back and forth.

  -->
  <PropertyGroup>
    <!-- Used for tag helper discovery -->
    <_RazorTagHelperInputCache>$(IntermediateOutputPath)$(TargetName).TagHelpers.input.cache</_RazorTagHelperInputCache>
    <_RazorTagHelperOutputCache>$(IntermediateOutputPath)$(TargetName).TagHelpers.output.cache</_RazorTagHelperOutputCache>

    <!-- Used to hash file inputs for RazorGenerate -->
    <_RazorGenerateInputsHash></_RazorGenerateInputsHash>
    <_RazorGenerateInputsHashFile>$(IntermediateOutputPath)$(MSBuildProjectName).RazorCoreGenerate.cache</_RazorGenerateInputsHashFile>
  </PropertyGroup>

  <!--

    This target will only be called when we have some .cshtml files that are going to participate in code generation.



    This is part of the chain of targets that are called once we've actually committed to generating code.

  -->
  <Target

    Name="_HashRazorGenerateInputs"

    Condition="'@(RazorGenerateWithTargetPath)' != ''">

    <Hash ItemsToHash="@(RazorGenerateWithTargetPath)">
      <Output TaskParameter="HashResult" PropertyName="_RazorGenerateInputsHash" />
    </Hash>

    <MakeDir

      Directories="$(IntermediateOutputPath)"

      Condition="!Exists('$(IntermediateOutputPath)')" />

    <WriteLinesToFile

      Lines="$(_RazorGenerateInputsHash)"

      File="$(_RazorGenerateInputsHashFile)"

      Overwrite="True"

      WriteOnlyWhenDifferent="True" />

    <ItemGroup>
      <FileWrites Include="$(_RazorGenerateInputsHashFile)" />
    </ItemGroup>
  </Target>

   <!-- Force a Compile to happen if we are not doing a components build. This keeps parity with 2.x CodeGeneration targets -->
   <Target

    Name="_RazorEnsureCompiled"

    Condition="'$(_RazorComponentDeclarationAssemblyFullPath)' == ''"

    DependsOnTargets="Compile" />

  <Target

    Name="ResolveTagHelperRazorGenerateInputs"

    Inputs="$(MSBuildAllProjects);@(RazorReferencePath)"

    DependsOnTargets="_RazorEnsureCompiled"

    Outputs="$(_RazorTagHelperInputCache)"

    Condition="'@(RazorGenerateWithTargetPath)' != ''">

    <!--

      We're manipulating our output directly here because we want to separate the actual up-to-date check

      of RazorCoreGenerate from the output of this target. Many times the set of tag helpers doesn't change

      so we don't need to regenerate the code.

      -->
    <Touch

      Files="$(_RazorTagHelperInputCache)"

      AlwaysCreate="true" />

    <ItemGroup>
      <FileWrites Include="$(_RazorTagHelperInputCache)" />
    </ItemGroup>

    <SdkRazorTagHelper

      Debug="$(_RazorDebugTagHelperTask)"

      DebugTool="$(_RazorDebugTagHelperTool)"

      ToolAssembly="$(_RazorSdkToolAssembly)"

      ToolExe="$(_RazorSdkDotNetHostFileName)"

      ToolPath="$(_RazorSdkDotNetHostDirectory)"

      UseServer="$(UseRazorBuildServer)"

      ForceServer="$(_RazorForceBuildServer)"

      PipeName="$(_RazorBuildServerPipeName)"

      Version="$(RazorLangVersion)"

      Configuration="@(ResolvedRazorConfiguration)"

      Extensions="@(ResolvedRazorExtension)"

      Assemblies="@(RazorReferencePath)"

      ProjectRoot="$(MSBuildProjectDirectory)"

      TagHelperManifest="$(_RazorTagHelperOutputCache)">
      <Output

        TaskParameter="TagHelperManifest"

        ItemName="FileWrites"/>
    </SdkRazorTagHelper>
  </Target>

  <Target Name="_ResolveRazorGenerateOutputs" Condition="'@(RazorGenerateWithTargetPath)' != ''">
    <Error

      Text="RazorGenerateWithTargetPath item '%(RazorGenerateWithTargetPath.Identity)' does not specify required metadata 'GeneratedOutput'."

      Condition="'%(RazorGenerateWithTargetPath.GeneratedOutput)' == ''" />

    <ItemGroup>
      <_RazorGenerateOutput Include="%(RazorGenerateWithTargetPath.GeneratedOutput)" />
    </ItemGroup>
  </Target>

  <PropertyGroup>
    <RazorCoreGenerateDependsOn>
      _HashRazorGenerateInputs;
      _ResolveRazorGenerateOutputs;
    </RazorCoreGenerateDependsOn>
  </PropertyGroup>

  <Target

    Name="RazorCoreGenerate"

    DependsOnTargets="$(RazorCoreGenerateDependsOn)"

    Inputs="$(MSBuildAllProjects);$(_RazorGenerateInputsHashFile);$(_RazorTagHelperOutputCache);@(RazorGenerateWithTargetPath)"

    Outputs="@(_RazorGenerateOutput)"

    Condition="'@(RazorGenerateWithTargetPath)'!= ''">

    <RemoveDir

      Directories="$(RazorGenerateIntermediateOutputPath)"

      Condition = "Exists('$(RazorGenerateIntermediateOutputPath)')"/>

    <MakeDir

      Directories="%(_RazorGenerateOutput.RelativeDir)"

      Condition="!Exists('%(_RazorGenerateOutput.RelativeDir)')" />

    <SdkRazorGenerate

      Debug="$(_RazorDebugGenerateCodeTask)"

      DebugTool="$(_RazorDebugGenerateCodeTool)"

      ToolAssembly="$(_RazorSdkToolAssembly)"

      ToolExe="$(_RazorSdkDotNetHostFileName)"

      ToolPath="$(_RazorSdkDotNetHostDirectory)"

      UseServer="$(UseRazorBuildServer)"

      ForceServer="$(_RazorForceBuildServer)"

      PipeName="$(_RazorBuildServerPipeName)"

      Version="$(RazorLangVersion)"

      RootNamespace="$(RootNamespace)"

      CSharpLanguageVersion="$(LangVersion)"

      Configuration="@(ResolvedRazorConfiguration)"

      Extensions="@(ResolvedRazorExtension)"

      Sources="@(RazorGenerateWithTargetPath)"

      ProjectRoot="$(MSBuildProjectDirectory)"

      TagHelperManifest="$(_RazorTagHelperOutputCache)"

      SupportLocalizedComponentNames="$(SupportLocalizedComponentNames)" />

    <ItemGroup>
      <FileWrites Include="@(_RazorGenerateOutput)" />
    </ItemGroup>
  </Target>

  <PropertyGroup>
    <ResolveRazorCompileInputsDependsOn>$(ResolveRazorCompileInputsDependsOn)</ResolveRazorCompileInputsDependsOn>
  </PropertyGroup>

</Project>