Update our version of the RazorCoreCompile
Updating RazorCoreCompile to be based on a much newer version of the Core.CSharp.targets. This adds support for some things we're missing like determinism and analzyers.
This commit is contained in:
parent
595d05965a
commit
fbb73bccd0
|
|
@ -1,60 +1,85 @@
|
||||||
<Project>
|
<Project>
|
||||||
<!--
|
|
||||||
What follows here was copied and modified from the XamlPreCompile target in
|
|
||||||
Microsoft.CSharp.CurrentVersion.targets
|
|
||||||
|
|
||||||
The XamlPreCompile target must remain identical to
|
|
||||||
the CoreCompile target in Microsoft.CSharp.Core.targets.
|
|
||||||
Any updates to one must be made to the other.
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Used to creating the final compiled Razor dll -->
|
<!-- Used to creating the final compiled Razor dll -->
|
||||||
<_RazorIntermediateAssembly Include="$(IntermediateOutputPath)$(RazorTargetName).dll" />
|
<RazorIntermediateAssembly Include="$(IntermediateOutputPath)$(RazorTargetName).dll" />
|
||||||
|
|
||||||
<!-- Similar to https://github.com/Microsoft/msbuild/blob/908cc9ccd4961441628f68e37a148183a87bb067/src/Tasks/Microsoft.Common.CurrentVersion.targets#L146-L153 -->
|
<!-- Similar to https://github.com/Microsoft/msbuild/blob/908cc9ccd4961441628f68e37a148183a87bb067/src/Tasks/Microsoft.Common.CurrentVersion.targets#L146-L153 -->
|
||||||
<_RazorIntermediatePdb
|
<_RazorDebugSymbolsIntermediatePath
|
||||||
Condition="'$(DebugSymbols)'=='true' and '$(DebugType)'!='' and '$(DebugType)'!='none' and '$(DebugType)'!='embedded'"
|
Condition="'$(DebugSymbols)'=='true' and '$(DebugType)'!='' and '$(DebugType)'!='none' and '$(DebugType)'!='embedded'"
|
||||||
Include="$(IntermediateOutputPath)$(RazorTargetName).pdb" />
|
Include="$(IntermediateOutputPath)$(RazorTargetName).pdb" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target
|
<!--
|
||||||
Name="RazorCoreCompile"
|
What follows in this file is based on:
|
||||||
Inputs="$(MSBuildAllProjects);
|
https://github.com/dotnet/roslyn/blob/4d92b18aee99ba8b1b4770ce65133e9ca65a94fe/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets
|
||||||
@(RazorCompile);
|
|
||||||
@(_CoreCompileResourceInputs);
|
|
||||||
$(ApplicationIcon);
|
|
||||||
$(AssemblyOriginatorKeyFile);
|
|
||||||
@(RazorReferencePath);"
|
|
||||||
|
|
||||||
Outputs="@(_RazorIntermediateAssembly);
|
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
|
||||||
@(_RazorIntermediatePdb)"
|
similar to the original to reduce noise. In general try to only deviate from the CoreCompile target when we need to for
|
||||||
Returns=""
|
correctness.
|
||||||
DependsOnTargets="_RazorResolveTagHelpers;RazorCoreGenerate">
|
|
||||||
|
|
||||||
|
We also want to avoid doubling up on things that don't make a ton of sense in the Razor views assembly, like
|
||||||
|
embedded files and resources, these are already present in the application's assembly.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
Name="RazorCoreCompile" and DependsOnTarget="RazorCoreGenerate"
|
||||||
|
|
||||||
|
Replace @(Compile) with @(RazorCompile)
|
||||||
|
Replace @(_DebugSymbolsIntermediatePath) with @(_RazorDebugSymbolsIntermediatePath)
|
||||||
|
Replace @(IntermediateAssembly) with @(RazorIntermediateAssembly)
|
||||||
|
Replace @(ReferencePathWithRefAssemblies) with @(RazorReferencePath)
|
||||||
|
|
||||||
|
Set TargetType="$(OutputType)" to TargetType="Library" - Razor is always a .dll
|
||||||
|
|
||||||
|
Remove Returns="@(CscCommandLineArgs)"
|
||||||
|
Remove @(_CoreCompileResourceInputs)
|
||||||
|
Remove $(ApplicationIcon) $(Win32Resource) $(Win32Manifest)
|
||||||
|
Remove @(EmbeddedDocumentation) and @(EmbeddedFiles)
|
||||||
|
Remove @(CustomAdditionalCompileInputs) and @(CustomAdditionalCompileOutputs)
|
||||||
|
Remove @(DocFileItem)
|
||||||
|
Remove PdbFile="$(PdbFile)"
|
||||||
|
Remove OutputRefAssembly="@(IntermediateRefAssembly)"
|
||||||
|
|
||||||
|
Remove EmbedAllSources="$(EmbedAllSources)" - not supported by our supported version of MSBuild
|
||||||
|
|
||||||
|
Remove additional steps after calling CSC
|
||||||
|
|
||||||
|
Add our FileWrites after the call to CSC
|
||||||
|
-->
|
||||||
|
<Target Name="RazorCoreCompile"
|
||||||
|
Inputs="$(MSBuildAllProjects);
|
||||||
|
@(RazorCompile);
|
||||||
|
$(AssemblyOriginatorKeyFile);
|
||||||
|
@(RazorReferencePath);
|
||||||
|
@(CompiledLicenseFile);
|
||||||
|
@(LinkResource);
|
||||||
|
$(ResolvedCodeAnalysisRuleSet);
|
||||||
|
@(AdditionalFiles)"
|
||||||
|
Outputs="@(RazorIntermediateAssembly);
|
||||||
|
@(_RazorDebugSymbolsIntermediatePath);
|
||||||
|
$(NonExistentFile)"
|
||||||
|
DependsOnTargets="RazorCoreGenerate">
|
||||||
<!-- These two compiler warnings are raised when a reference is bound to a different version
|
<!-- These two compiler warnings are raised when a reference is bound to a different version
|
||||||
than specified in the assembly reference version number. MSBuild raises the same warning in this case,
|
than specified in the assembly reference version number. MSBuild raises the same warning in this case,
|
||||||
so the compiler warning would be redundant. -->
|
so the compiler warning would be redundant. -->
|
||||||
<PropertyGroup Condition="('$(TargetFrameworkVersion)' != 'v1.0') and ('$(TargetFrameworkVersion)' != 'v1.1')">
|
<PropertyGroup Condition="('$(TargetFrameworkVersion)' != 'v1.0') and ('$(TargetFrameworkVersion)' != 'v1.1')">
|
||||||
<NoWarn>$(NoWarn);1701;1702</NoWarn>
|
<NoWarn>$(NoWarn);1701;1702</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- To match historical behavior, when inside VS11+ disable the warning from csc.exe indicating that no sources were passed in-->
|
<!-- To match historical behavior, when inside VS11+ disable the warning from csc.exe indicating that no sources were passed in-->
|
||||||
<NoWarn Condition=" '$(BuildingInsideVisualStudio)' == 'true' and '$(VisualStudioVersion)' != '' and '$(VisualStudioVersion)' > '10.0' ">$(NoWarn);2008</NoWarn>
|
<NoWarn Condition="'$(BuildingInsideVisualStudio)' == 'true' AND '$(VisualStudioVersion)' != '' AND '$(VisualStudioVersion)' > '10.0'">$(NoWarn);2008</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetingClr2Framework)'=='true'">
|
<ItemGroup Condition="'$(TargetingClr2Framework)' == 'true'">
|
||||||
<ReferencePath>
|
<ReferencePathWithRefAssemblies>
|
||||||
<EmbedInteropTypes/>
|
<EmbedInteropTypes />
|
||||||
</ReferencePath>
|
</ReferencePathWithRefAssemblies>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- If the user has specified AppConfigForCompiler, we'll use it. If they have not, but they set UseAppConfigForCompiler,
|
<!-- If the user has specified AppConfigForCompiler, we'll use it. If they have not, but they set UseAppConfigForCompiler,
|
||||||
then we'll use AppConfig -->
|
then we'll use AppConfig -->
|
||||||
<AppConfigForCompiler Condition="'$(AppConfigForCompiler)' == '' and '$(UseAppConfigForCompiler)' == 'true'">$(AppConfig)</AppConfigForCompiler>
|
<AppConfigForCompiler Condition="'$(AppConfigForCompiler)' == '' AND '$(UseAppConfigForCompiler)' == 'true'">$(AppConfig)</AppConfigForCompiler>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Prefer32Bit was introduced in .NET 4.5. Set it to false if we are targeting 4.0 -->
|
<!-- Prefer32Bit was introduced in .NET 4.5. Set it to false if we are targeting 4.0 -->
|
||||||
|
|
@ -62,15 +87,28 @@
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- TODO: Remove this ItemGroup once it has been moved to "_GenerateCompileInputs" target in Microsoft.Common.CurrentVersion.targets.
|
||||||
|
https://github.com/dotnet/roslyn/issues/12223 -->
|
||||||
|
<ItemGroup Condition="('$(AdditionalFileItemNames)' != '')">
|
||||||
|
<AdditionalFileItems Include="$(AdditionalFileItemNames)" />
|
||||||
|
<AdditionalFiles Include="@(%(AdditionalFileItems.Identity))" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(UseSharedCompilation)' == ''">
|
<PropertyGroup Condition="'$(UseSharedCompilation)' == ''">
|
||||||
<UseSharedCompilation>true</UseSharedCompilation>
|
<UseSharedCompilation>true</UseSharedCompilation>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Csc
|
<Csc
|
||||||
|
AdditionalLibPaths="$(AdditionalLibPaths)"
|
||||||
|
AddModules="@(AddModules)"
|
||||||
|
AdditionalFiles="@(AdditionalFiles)"
|
||||||
AllowUnsafeBlocks="$(AllowUnsafeBlocks)"
|
AllowUnsafeBlocks="$(AllowUnsafeBlocks)"
|
||||||
|
Analyzers="@(Analyzer)"
|
||||||
ApplicationConfiguration="$(AppConfigForCompiler)"
|
ApplicationConfiguration="$(AppConfigForCompiler)"
|
||||||
BaseAddress="$(BaseAddress)"
|
BaseAddress="$(BaseAddress)"
|
||||||
CheckForOverflowUnderflow="$(CheckForOverflowUnderflow)"
|
CheckForOverflowUnderflow="$(CheckForOverflowUnderflow)"
|
||||||
|
ChecksumAlgorithm="$(ChecksumAlgorithm)"
|
||||||
|
CodeAnalysisRuleSet="$(ResolvedCodeAnalysisRuleSet)"
|
||||||
CodePage="$(CodePage)"
|
CodePage="$(CodePage)"
|
||||||
DebugType="$(DebugType)"
|
DebugType="$(DebugType)"
|
||||||
DefineConstants="$(DefineConstants)"
|
DefineConstants="$(DefineConstants)"
|
||||||
|
|
@ -81,25 +119,36 @@
|
||||||
ErrorEndLocation="$(ErrorEndLocation)"
|
ErrorEndLocation="$(ErrorEndLocation)"
|
||||||
ErrorLog="$(ErrorLog)"
|
ErrorLog="$(ErrorLog)"
|
||||||
ErrorReport="$(ErrorReport)"
|
ErrorReport="$(ErrorReport)"
|
||||||
|
Features="$(Features)"
|
||||||
FileAlignment="$(FileAlignment)"
|
FileAlignment="$(FileAlignment)"
|
||||||
GenerateFullPaths="$(GenerateFullPaths)"
|
GenerateFullPaths="$(GenerateFullPaths)"
|
||||||
HighEntropyVA="$(HighEntropyVA)"
|
HighEntropyVA="$(HighEntropyVA)"
|
||||||
|
Instrument="$(Instrument)"
|
||||||
KeyContainer="$(KeyContainerName)"
|
KeyContainer="$(KeyContainerName)"
|
||||||
KeyFile="$(KeyOriginatorFile)"
|
KeyFile="$(KeyOriginatorFile)"
|
||||||
LangVersion="$(LangVersion)"
|
LangVersion="$(LangVersion)"
|
||||||
|
LinkResources="@(LinkResource)"
|
||||||
|
MainEntryPoint="$(StartupObject)"
|
||||||
|
ModuleAssemblyName="$(ModuleAssemblyName)"
|
||||||
NoConfig="true"
|
NoConfig="true"
|
||||||
NoLogo="$(NoLogo)"
|
NoLogo="$(NoLogo)"
|
||||||
NoStandardLib="$(NoCompilerStandardLib)"
|
NoStandardLib="$(NoCompilerStandardLib)"
|
||||||
NoWin32Manifest="$(NoWin32Manifest)"
|
NoWin32Manifest="$(NoWin32Manifest)"
|
||||||
Optimize="$(Optimize)"
|
Optimize="$(Optimize)"
|
||||||
OutputAssembly="@(_RazorIntermediateAssembly)"
|
Deterministic="$(Deterministic)"
|
||||||
PdbFile="@(_RazorIntermediatePdb)"
|
PublicSign="$(PublicSign)"
|
||||||
|
OutputAssembly="@(RazorIntermediateAssembly)"
|
||||||
Platform="$(PlatformTarget)"
|
Platform="$(PlatformTarget)"
|
||||||
Prefer32Bit="$(Prefer32Bit)"
|
Prefer32Bit="$(Prefer32Bit)"
|
||||||
PreferredUILang="$(PreferredUILang)"
|
PreferredUILang="$(PreferredUILang)"
|
||||||
|
ProvideCommandLineArgs="$(ProvideCommandLineArgs)"
|
||||||
References="@(RazorReferencePath)"
|
References="@(RazorReferencePath)"
|
||||||
ReportAnalyzer="$(ReportAnalyzer)"
|
ReportAnalyzer="$(ReportAnalyzer)"
|
||||||
|
Resources="@(CompiledLicenseFile)"
|
||||||
ResponseFiles="$(CompilerResponseFile)"
|
ResponseFiles="$(CompilerResponseFile)"
|
||||||
|
RuntimeMetadataVersion="$(RuntimeMetadataVersion)"
|
||||||
|
SharedCompilationId="$(SharedCompilationId)"
|
||||||
|
SkipCompilerExecution="$(SkipCompilerExecution)"
|
||||||
Sources="@(RazorCompile)"
|
Sources="@(RazorCompile)"
|
||||||
SubsystemVersion="$(SubsystemVersion)"
|
SubsystemVersion="$(SubsystemVersion)"
|
||||||
TargetType="Library"
|
TargetType="Library"
|
||||||
|
|
@ -113,55 +162,14 @@
|
||||||
WarningLevel="$(WarningLevel)"
|
WarningLevel="$(WarningLevel)"
|
||||||
WarningsAsErrors="$(WarningsAsErrors)"
|
WarningsAsErrors="$(WarningsAsErrors)"
|
||||||
WarningsNotAsErrors="$(WarningsNotAsErrors)"
|
WarningsNotAsErrors="$(WarningsNotAsErrors)"
|
||||||
Win32Icon="$(ApplicationIcon)"
|
PathMap="$(PathMap)"
|
||||||
Win32Manifest="$(Win32Manifest)"
|
SourceLink="$(SourceLink)">
|
||||||
Win32Resource="$(Win32Resource)">
|
<Output TaskParameter="CommandLineArgs" ItemName="CscCommandLineArgs" />
|
||||||
</Csc>
|
</Csc>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<FileWrites Include="@(_RazorIntermediateAssembly)" Condition="Exists('@(_RazorIntermediateAssembly)')" />
|
<FileWrites Include="@(_RazorIntermediateAssembly)" Condition="Exists('@(_RazorIntermediateAssembly)')" />
|
||||||
<FileWrites Include="@(_RazorIntermediatePdb)" Condition="Exists('@(_RazorIntermediatePdb)')" />
|
<FileWrites Include="@(_RazorDebugSymbolsIntermediatePath)" Condition="Exists('@(_RazorDebugSymbolsIntermediatePath)')" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
<Target Name="_CopyRazorAssemblies"
|
|
||||||
AfterTargets="CopyFilesToOutputDirectory">
|
|
||||||
|
|
||||||
<!-- Copy the Razor dll -->
|
|
||||||
<Copy
|
|
||||||
SourceFiles="@(_RazorIntermediateAssembly)"
|
|
||||||
DestinationFolder="$(OutDir)"
|
|
||||||
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
|
|
||||||
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
|
|
||||||
Retries="$(CopyRetryCount)"
|
|
||||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
|
|
||||||
UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
|
|
||||||
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)"
|
|
||||||
Condition="Exists('@(_RazorIntermediateAssembly)') and '$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true'">
|
|
||||||
|
|
||||||
<Output TaskParameter="DestinationFiles" ItemName="_RazorAssembly"/>
|
|
||||||
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
|
|
||||||
|
|
||||||
</Copy>
|
|
||||||
|
|
||||||
<Message Importance="High" Text="$(MSBuildProjectName) -> @(_RazorAssembly->'%(FullPath)')" Condition="Exists('@(_RazorIntermediateAssembly)') and '$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)'!='true'" />
|
|
||||||
|
|
||||||
<!-- Copy the Razor debug information file (.pdb), if any -->
|
|
||||||
<Copy
|
|
||||||
SourceFiles="$(_RazorIntermediatePdb)"
|
|
||||||
DestinationFiles="@(_DebugSymbolsOutputPath)"
|
|
||||||
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
|
|
||||||
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
|
|
||||||
Retries="$(CopyRetryCount)"
|
|
||||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
|
|
||||||
UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
|
|
||||||
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)"
|
|
||||||
Condition="Exists('@(_RazorIntermediatePdb)') and '$(SkipCopyingSymbolsToOutputDirectory)' != 'true' and '$(CopyOutputSymbolsToOutputDirectory)'=='true'">
|
|
||||||
|
|
||||||
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
|
|
||||||
|
|
||||||
</Copy>
|
|
||||||
|
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -140,4 +140,45 @@
|
||||||
<RazorCompile Include="@(_RazorGenerateOutput)" />
|
<RazorCompile Include="@(_RazorGenerateOutput)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="_RazorCopyFilesToOutputDirectory" AfterTargets="CopyFilesToOutputDirectory">
|
||||||
|
|
||||||
|
<!-- Copy the Razor dll -->
|
||||||
|
<Copy
|
||||||
|
SourceFiles="@(RazorIntermediateAssembly)"
|
||||||
|
DestinationFolder="$(OutDir)"
|
||||||
|
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
|
||||||
|
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
|
||||||
|
Retries="$(CopyRetryCount)"
|
||||||
|
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
|
||||||
|
UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
|
||||||
|
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)"
|
||||||
|
Condition="Exists('@(RazorIntermediateAssembly)') and '$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true'">
|
||||||
|
|
||||||
|
<Output TaskParameter="DestinationFiles" ItemName="_RazorAssembly"/>
|
||||||
|
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
|
||||||
|
</Copy>
|
||||||
|
|
||||||
|
<Message
|
||||||
|
Importance="High"
|
||||||
|
Text="$(MSBuildProjectName) -> @(_RazorAssembly->'%(FullPath)')"
|
||||||
|
Condition="Exists('@(RazorIntermediateAssembly)') and '$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)'!='true'" />
|
||||||
|
|
||||||
|
<!-- Copy the Razor debug information file (.pdb), if any -->
|
||||||
|
<Copy
|
||||||
|
SourceFiles="$(_RazorDebugSymbolsIntermediatePath)"
|
||||||
|
DestinationFiles="@(_DebugSymbolsOutputPath)"
|
||||||
|
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
|
||||||
|
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
|
||||||
|
Retries="$(CopyRetryCount)"
|
||||||
|
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
|
||||||
|
UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
|
||||||
|
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)"
|
||||||
|
Condition="Exists('@(_RazorDebugSymbolsIntermediatePath)') and '$(SkipCopyingSymbolsToOutputDirectory)' != 'true' and '$(CopyOutputSymbolsToOutputDirectory)'=='true'">
|
||||||
|
|
||||||
|
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
|
||||||
|
</Copy>
|
||||||
|
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue