Razor 423 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. commit fbb73bccd055b31037c41557ca520909bc06d213
  2. Author: Ryan Nowak <[email protected]>
  3. Date: Sun Jan 7 21:29:36 2018 -0800
  4. Update our version of the RazorCoreCompile
  5. Updating RazorCoreCompile to be based on a much newer
  6. version of the Core.CSharp.targets.
  7. This adds support for some things we're missing like determinism and
  8. analzyers.
  9. diff --git a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.Compilation.targets b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.Compilation.targets
  10. index fb3751101a8..3af2791f185 100644
  11. --- a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.Compilation.targets
  12. +++ b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.Compilation.targets
  13. @@ -1,60 +1,85 @@
  14. <Project>
  15. - <!--
  16. - What follows here was copied and modified from the XamlPreCompile target in
  17. - Microsoft.CSharp.CurrentVersion.targets
  18. -
  19. - The XamlPreCompile target must remain identical to
  20. - the CoreCompile target in Microsoft.CSharp.Core.targets.
  21. - Any updates to one must be made to the other.
  22. - -->
  23. -
  24. -
  25. <ItemGroup>
  26. <!-- Used to creating the final compiled Razor dll -->
  27. - <_RazorIntermediateAssembly Include="$(IntermediateOutputPath)$(RazorTargetName).dll" />
  28. + <RazorIntermediateAssembly Include="$(IntermediateOutputPath)$(RazorTargetName).dll" />
  29. <!-- Similar to https://github.com/Microsoft/msbuild/blob/908cc9ccd4961441628f68e37a148183a87bb067/src/Tasks/Microsoft.Common.CurrentVersion.targets#L146-L153 -->
  30. - <_RazorIntermediatePdb
  31. + <_RazorDebugSymbolsIntermediatePath
  32. Condition="'$(DebugSymbols)'=='true' and '$(DebugType)'!='' and '$(DebugType)'!='none' and '$(DebugType)'!='embedded'"
  33. Include="$(IntermediateOutputPath)$(RazorTargetName).pdb" />
  34. </ItemGroup>
  35. -
  36. - <Target
  37. - Name="RazorCoreCompile"
  38. - Inputs="$(MSBuildAllProjects);
  39. - @(RazorCompile);
  40. - @(_CoreCompileResourceInputs);
  41. - $(ApplicationIcon);
  42. - $(AssemblyOriginatorKeyFile);
  43. - @(RazorReferencePath);"
  44. -
  45. - Outputs="@(_RazorIntermediateAssembly);
  46. - @(_RazorIntermediatePdb)"
  47. - Returns=""
  48. - DependsOnTargets="_RazorResolveTagHelpers;RazorCoreGenerate">
  49. + <!--
  50. + What follows in this file is based on:
  51. + https://github.com/dotnet/roslyn/blob/4d92b18aee99ba8b1b4770ce65133e9ca65a94fe/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets
  52. +
  53. + We need to keep this basically up to date, as well as track the set of modifications we've made. Try to keep the formatting
  54. + similar to the original to reduce noise. In general try to only deviate from the CoreCompile target when we need to for
  55. + correctness.
  56. +
  57. + We also want to avoid doubling up on things that don't make a ton of sense in the Razor views assembly, like
  58. + embedded files and resources, these are already present in the application's assembly.
  59. +
  60. + Changes:
  61. + Name="RazorCoreCompile" and DependsOnTarget="RazorCoreGenerate"
  62. +
  63. + Replace @(Compile) with @(RazorCompile)
  64. + Replace @(_DebugSymbolsIntermediatePath) with @(_RazorDebugSymbolsIntermediatePath)
  65. + Replace @(IntermediateAssembly) with @(RazorIntermediateAssembly)
  66. + Replace @(ReferencePathWithRefAssemblies) with @(RazorReferencePath)
  67. +
  68. + Set TargetType="$(OutputType)" to TargetType="Library" - Razor is always a .dll
  69. +
  70. + Remove Returns="@(CscCommandLineArgs)"
  71. + Remove @(_CoreCompileResourceInputs)
  72. + Remove $(ApplicationIcon) $(Win32Resource) $(Win32Manifest)
  73. + Remove @(EmbeddedDocumentation) and @(EmbeddedFiles)
  74. + Remove @(CustomAdditionalCompileInputs) and @(CustomAdditionalCompileOutputs)
  75. + Remove @(DocFileItem)
  76. + Remove PdbFile="$(PdbFile)"
  77. + Remove OutputRefAssembly="@(IntermediateRefAssembly)"
  78. +
  79. + Remove EmbedAllSources="$(EmbedAllSources)" - not supported by our supported version of MSBuild
  80. +
  81. + Remove additional steps after calling CSC
  82. +
  83. + Add our FileWrites after the call to CSC
  84. + -->
  85. + <Target Name="RazorCoreCompile"
  86. + Inputs="$(MSBuildAllProjects);
  87. + @(RazorCompile);
  88. + $(AssemblyOriginatorKeyFile);
  89. + @(RazorReferencePath);
  90. + @(CompiledLicenseFile);
  91. + @(LinkResource);
  92. + $(ResolvedCodeAnalysisRuleSet);
  93. + @(AdditionalFiles)"
  94. + Outputs="@(RazorIntermediateAssembly);
  95. + @(_RazorDebugSymbolsIntermediatePath);
  96. + $(NonExistentFile)"
  97. + DependsOnTargets="RazorCoreGenerate">
  98. <!-- These two compiler warnings are raised when a reference is bound to a different version
  99. - than specified in the assembly reference version number. MSBuild raises the same warning in this case,
  100. - so the compiler warning would be redundant. -->
  101. + than specified in the assembly reference version number. MSBuild raises the same warning in this case,
  102. + so the compiler warning would be redundant. -->
  103. <PropertyGroup Condition="('$(TargetFrameworkVersion)' != 'v1.0') and ('$(TargetFrameworkVersion)' != 'v1.1')">
  104. <NoWarn>$(NoWarn);1701;1702</NoWarn>
  105. </PropertyGroup>
  106. <PropertyGroup>
  107. <!-- To match historical behavior, when inside VS11+ disable the warning from csc.exe indicating that no sources were passed in-->
  108. - <NoWarn Condition=" '$(BuildingInsideVisualStudio)' == 'true' and '$(VisualStudioVersion)' != '' and '$(VisualStudioVersion)' > '10.0' ">$(NoWarn);2008</NoWarn>
  109. + <NoWarn Condition="'$(BuildingInsideVisualStudio)' == 'true' AND '$(VisualStudioVersion)' != '' AND '$(VisualStudioVersion)' &gt; '10.0'">$(NoWarn);2008</NoWarn>
  110. </PropertyGroup>
  111. - <ItemGroup Condition="'$(TargetingClr2Framework)'=='true'">
  112. - <ReferencePath>
  113. - <EmbedInteropTypes/>
  114. - </ReferencePath>
  115. + <ItemGroup Condition="'$(TargetingClr2Framework)' == 'true'">
  116. + <ReferencePathWithRefAssemblies>
  117. + <EmbedInteropTypes />
  118. + </ReferencePathWithRefAssemblies>
  119. </ItemGroup>
  120. <PropertyGroup>
  121. <!-- If the user has specified AppConfigForCompiler, we'll use it. If they have not, but they set UseAppConfigForCompiler,
  122. - then we'll use AppConfig -->
  123. - <AppConfigForCompiler Condition="'$(AppConfigForCompiler)' == '' and '$(UseAppConfigForCompiler)' == 'true'">$(AppConfig)</AppConfigForCompiler>
  124. + then we'll use AppConfig -->
  125. + <AppConfigForCompiler Condition="'$(AppConfigForCompiler)' == '' AND '$(UseAppConfigForCompiler)' == 'true'">$(AppConfig)</AppConfigForCompiler>
  126. </PropertyGroup>
  127. <!-- Prefer32Bit was introduced in .NET 4.5. Set it to false if we are targeting 4.0 -->
  128. @@ -62,15 +87,28 @@
  129. <Prefer32Bit>false</Prefer32Bit>
  130. </PropertyGroup>
  131. + <!-- TODO: Remove this ItemGroup once it has been moved to "_GenerateCompileInputs" target in Microsoft.Common.CurrentVersion.targets.
  132. + https://github.com/dotnet/roslyn/issues/12223 -->
  133. + <ItemGroup Condition="('$(AdditionalFileItemNames)' != '')">
  134. + <AdditionalFileItems Include="$(AdditionalFileItemNames)" />
  135. + <AdditionalFiles Include="@(%(AdditionalFileItems.Identity))" />
  136. + </ItemGroup>
  137. +
  138. <PropertyGroup Condition="'$(UseSharedCompilation)' == ''">
  139. <UseSharedCompilation>true</UseSharedCompilation>
  140. </PropertyGroup>
  141. <Csc
  142. + AdditionalLibPaths="$(AdditionalLibPaths)"
  143. + AddModules="@(AddModules)"
  144. + AdditionalFiles="@(AdditionalFiles)"
  145. AllowUnsafeBlocks="$(AllowUnsafeBlocks)"
  146. + Analyzers="@(Analyzer)"
  147. ApplicationConfiguration="$(AppConfigForCompiler)"
  148. BaseAddress="$(BaseAddress)"
  149. CheckForOverflowUnderflow="$(CheckForOverflowUnderflow)"
  150. + ChecksumAlgorithm="$(ChecksumAlgorithm)"
  151. + CodeAnalysisRuleSet="$(ResolvedCodeAnalysisRuleSet)"
  152. CodePage="$(CodePage)"
  153. DebugType="$(DebugType)"
  154. DefineConstants="$(DefineConstants)"
  155. @@ -81,25 +119,36 @@
  156. ErrorEndLocation="$(ErrorEndLocation)"
  157. ErrorLog="$(ErrorLog)"
  158. ErrorReport="$(ErrorReport)"
  159. + Features="$(Features)"
  160. FileAlignment="$(FileAlignment)"
  161. GenerateFullPaths="$(GenerateFullPaths)"
  162. HighEntropyVA="$(HighEntropyVA)"
  163. + Instrument="$(Instrument)"
  164. KeyContainer="$(KeyContainerName)"
  165. KeyFile="$(KeyOriginatorFile)"
  166. LangVersion="$(LangVersion)"
  167. + LinkResources="@(LinkResource)"
  168. + MainEntryPoint="$(StartupObject)"
  169. + ModuleAssemblyName="$(ModuleAssemblyName)"
  170. NoConfig="true"
  171. NoLogo="$(NoLogo)"
  172. NoStandardLib="$(NoCompilerStandardLib)"
  173. NoWin32Manifest="$(NoWin32Manifest)"
  174. Optimize="$(Optimize)"
  175. - OutputAssembly="@(_RazorIntermediateAssembly)"
  176. - PdbFile="@(_RazorIntermediatePdb)"
  177. + Deterministic="$(Deterministic)"
  178. + PublicSign="$(PublicSign)"
  179. + OutputAssembly="@(RazorIntermediateAssembly)"
  180. Platform="$(PlatformTarget)"
  181. Prefer32Bit="$(Prefer32Bit)"
  182. PreferredUILang="$(PreferredUILang)"
  183. + ProvideCommandLineArgs="$(ProvideCommandLineArgs)"
  184. References="@(RazorReferencePath)"
  185. ReportAnalyzer="$(ReportAnalyzer)"
  186. + Resources="@(CompiledLicenseFile)"
  187. ResponseFiles="$(CompilerResponseFile)"
  188. + RuntimeMetadataVersion="$(RuntimeMetadataVersion)"
  189. + SharedCompilationId="$(SharedCompilationId)"
  190. + SkipCompilerExecution="$(SkipCompilerExecution)"
  191. Sources="@(RazorCompile)"
  192. SubsystemVersion="$(SubsystemVersion)"
  193. TargetType="Library"
  194. @@ -113,55 +162,14 @@
  195. WarningLevel="$(WarningLevel)"
  196. WarningsAsErrors="$(WarningsAsErrors)"
  197. WarningsNotAsErrors="$(WarningsNotAsErrors)"
  198. - Win32Icon="$(ApplicationIcon)"
  199. - Win32Manifest="$(Win32Manifest)"
  200. - Win32Resource="$(Win32Resource)">
  201. + PathMap="$(PathMap)"
  202. + SourceLink="$(SourceLink)">
  203. + <Output TaskParameter="CommandLineArgs" ItemName="CscCommandLineArgs" />
  204. </Csc>
  205. <ItemGroup>
  206. <FileWrites Include="@(_RazorIntermediateAssembly)" Condition="Exists('@(_RazorIntermediateAssembly)')" />
  207. - <FileWrites Include="@(_RazorIntermediatePdb)" Condition="Exists('@(_RazorIntermediatePdb)')" />
  208. + <FileWrites Include="@(_RazorDebugSymbolsIntermediatePath)" Condition="Exists('@(_RazorDebugSymbolsIntermediatePath)')" />
  209. </ItemGroup>
  210. -
  211. -</Target>
  212. -
  213. -<Target Name="_CopyRazorAssemblies"
  214. - AfterTargets="CopyFilesToOutputDirectory">
  215. -
  216. - <!-- Copy the Razor dll -->
  217. - <Copy
  218. - SourceFiles="@(_RazorIntermediateAssembly)"
  219. - DestinationFolder="$(OutDir)"
  220. - SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
  221. - OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
  222. - Retries="$(CopyRetryCount)"
  223. - RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
  224. - UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
  225. - UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)"
  226. - Condition="Exists('@(_RazorIntermediateAssembly)') and '$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true'">
  227. -
  228. - <Output TaskParameter="DestinationFiles" ItemName="_RazorAssembly"/>
  229. - <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
  230. -
  231. - </Copy>
  232. -
  233. - <Message Importance="High" Text="$(MSBuildProjectName) -&gt; @(_RazorAssembly->'%(FullPath)')" Condition="Exists('@(_RazorIntermediateAssembly)') and '$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)'!='true'" />
  234. -
  235. - <!-- Copy the Razor debug information file (.pdb), if any -->
  236. - <Copy
  237. - SourceFiles="$(_RazorIntermediatePdb)"
  238. - DestinationFiles="@(_DebugSymbolsOutputPath)"
  239. - SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
  240. - OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
  241. - Retries="$(CopyRetryCount)"
  242. - RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
  243. - UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
  244. - UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)"
  245. - Condition="Exists('@(_RazorIntermediatePdb)') and '$(SkipCopyingSymbolsToOutputDirectory)' != 'true' and '$(CopyOutputSymbolsToOutputDirectory)'=='true'">
  246. -
  247. - <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
  248. -
  249. - </Copy>
  250. -
  251. </Target>
  252. </Project>
  253. diff --git a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.targets b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.targets
  254. index 05baefe3ca4..3f5ea7784a6 100644
  255. --- a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.targets
  256. +++ b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.targets
  257. @@ -140,4 +140,45 @@
  258. <RazorCompile Include="@(_RazorGenerateOutput)" />
  259. </ItemGroup>
  260. </Target>
  261. +
  262. + <Target Name="_RazorCopyFilesToOutputDirectory" AfterTargets="CopyFilesToOutputDirectory">
  263. +
  264. + <!-- Copy the Razor dll -->
  265. + <Copy
  266. + SourceFiles="@(RazorIntermediateAssembly)"
  267. + DestinationFolder="$(OutDir)"
  268. + SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
  269. + OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
  270. + Retries="$(CopyRetryCount)"
  271. + RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
  272. + UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
  273. + UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)"
  274. + Condition="Exists('@(RazorIntermediateAssembly)') and '$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true'">
  275. +
  276. + <Output TaskParameter="DestinationFiles" ItemName="_RazorAssembly"/>
  277. + <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
  278. + </Copy>
  279. +
  280. + <Message
  281. + Importance="High"
  282. + Text="$(MSBuildProjectName) -&gt; @(_RazorAssembly->'%(FullPath)')"
  283. + Condition="Exists('@(RazorIntermediateAssembly)') and '$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)'!='true'" />
  284. +
  285. + <!-- Copy the Razor debug information file (.pdb), if any -->
  286. + <Copy
  287. + SourceFiles="$(_RazorDebugSymbolsIntermediatePath)"
  288. + DestinationFiles="@(_DebugSymbolsOutputPath)"
  289. + SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
  290. + OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
  291. + Retries="$(CopyRetryCount)"
  292. + RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
  293. + UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
  294. + UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)"
  295. + Condition="Exists('@(_RazorDebugSymbolsIntermediatePath)') and '$(SkipCopyingSymbolsToOutputDirectory)' != 'true' and '$(CopyOutputSymbolsToOutputDirectory)'=='true'">
  296. +
  297. + <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
  298. + </Copy>
  299. +
  300. + </Target>
  301. +
  302. </Project>