提交 aa8d4ae4 编写于 作者: A Andy Gocke

Add the CoreCompile targets for C# & VB to MSBuildTask project

This extracts the CoreCompile target from the Microsoft.CSharp.CurrentVersion
and Microsoft.VisualBasic.CurrentVersion targets files and creates two new
targets files, Microsoft.CSharp.Core and Microsoft.VisualBasic.Core, to contain
it.

This is necessary because the CoreCompile target contains the actual invocation
of the Csc/Vbc tasks, which the MSBuildTask assembly contains. Any changes in
the public surface area of the tasks need to be reflected in the targets. These
targets should eventually be inserted into the MSBuild install with the task as
the compiler public entry point.
上级 e463d455
......@@ -35,6 +35,12 @@
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="Microsoft.CSharp.Core.targets">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Microsoft.VisualBasic.Core.targets">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
......
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target
Name="CoreCompile"
Inputs="$(MSBuildAllProjects);
@(Compile);
@(_CoreCompileResourceInputs);
$(ApplicationIcon);
$(AssemblyOriginatorKeyFile);
@(ReferencePath);
@(CompiledLicenseFile);
@(LinkResource);
@(EmbeddedDocumentation);
$(Win32Resource);
$(Win32Manifest);
@(CustomAdditionalCompileInputs);
$(ResolvedCodeAnalysisRuleSet)"
Outputs="@(DocFileItem);
@(IntermediateAssembly);
@(_DebugSymbolsIntermediatePath);
$(NonExistentFile);
@(CustomAdditionalCompileOutputs)"
Returns=""
DependsOnTargets="$(CoreCompileDependsOn)"
>
<!-- 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,
so the compiler warning would be redundant. -->
<PropertyGroup Condition="('$(TargetFrameworkVersion)' != 'v1.0') and ('$(TargetFrameworkVersion)' != 'v1.1')">
<NoWarn>$(NoWarn);1701;1702</NoWarn>
</PropertyGroup>
<PropertyGroup>
<!-- 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>
</PropertyGroup>
<PropertyGroup>
<!-- If we are building in visual studio setting the CscToolPath will prevent the inproc compiler from being used during compile-->
<CscToolPath Condition="'$(CscToolPath)' == '' and '$(BuildingOutOfProcess)' != 'false'" >$(MsBuildToolsPath)</CscToolPath>
</PropertyGroup>
<ItemGroup Condition="'$(TargetingClr2Framework)'=='true'">
<ReferencePath>
<EmbedInteropTypes/>
</ReferencePath>
</ItemGroup>
<PropertyGroup>
<!-- If the user has specified AppConfigForCompiler, we'll use it. If they have not, but they set UseAppConfigForCompiler,
then we'll use AppConfig -->
<AppConfigForCompiler Condition="'$(AppConfigForCompiler)' == '' and '$(UseAppConfigForCompiler)' == 'true'">$(AppConfig)</AppConfigForCompiler>
<!-- If we are targeting winmdobj we want to specifically the pdbFile property since we do not want it to collide with the output of winmdexp-->
<PdbFile Condition="'$(PdbFile)' == '' and '$(OutputType)' == 'winmdobj' and '$(_DebugSymbolsProduced)' == 'true'">$(IntermediateOutputPath)$(TargetName).compile.pdb</PdbFile>
</PropertyGroup>
<!-- Prefer32Bit was introduced in .NET 4.5. Set it to false if we are targeting 4.0 -->
<PropertyGroup Condition="('$(TargetFrameworkVersion)' == 'v4.0')">
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup Condition="('$(AdditionalFileItemNames)' != '')">
<AdditionalFileItems Include="$(AdditionalFileItemNames)" />
<AdditionalFiles Include="@(%(AdditionalFileItems.Identity))" />
</ItemGroup>
<!-- Condition is to filter out the _CoreCompileResourceInputs so that it doesn't pass in culture resources to the compiler -->
<Csc Condition=" '%(_CoreCompileResourceInputs.WithCulture)' != 'true' "
AdditionalLibPaths="$(AdditionalLibPaths)"
AddModules="@(AddModules)"
AdditionalFiles="@(AdditionalFiles)"
AllowUnsafeBlocks="$(AllowUnsafeBlocks)"
Analyzers="@(Analyzer)"
ApplicationConfiguration="$(AppConfigForCompiler)"
BaseAddress="$(BaseAddress)"
CheckForOverflowUnderflow="$(CheckForOverflowUnderflow)"
CodeAnalysisRuleSet="$(ResolvedCodeAnalysisRuleSet)"
CodePage="$(CodePage)"
DebugType="$(DebugType)"
DefineConstants="$(DefineConstants)"
DelaySign="$(DelaySign)"
DisabledWarnings="$(NoWarn)"
DocumentationFile="@(DocFileItem)"
EmitDebugInformation="$(DebugSymbols)"
EnvironmentVariables="$(CscEnvironment)"
ErrorEndLocation="$(ErrorEndLocation)"
ErrorReport="$(ErrorReport)"
FileAlignment="$(FileAlignment)"
GenerateFullPaths="$(GenerateFullPaths)"
HighEntropyVA="$(HighEntropyVA)"
KeyContainer="$(KeyContainerName)"
KeyFile="$(KeyOriginatorFile)"
LangVersion="$(LangVersion)"
LinkResources="@(LinkResource)"
MainEntryPoint="$(StartupObject)"
ModuleAssemblyName="$(ModuleAssemblyName)"
NoConfig="true"
NoLogo="$(NoLogo)"
NoStandardLib="$(NoCompilerStandardLib)"
NoWin32Manifest="$(NoWin32Manifest)"
Optimize="$(Optimize)"
OutputAssembly="@(IntermediateAssembly)"
PdbFile="$(PdbFile)"
Platform="$(PlatformTarget)"
Prefer32Bit="$(Prefer32Bit)"
PreferredUILang="$(PreferredUILang)"
References="@(ReferencePath)"
Resources="@(_CoreCompileResourceInputs);@(CompiledLicenseFile)"
ResponseFiles="$(CompilerResponseFile)"
Sources="@(Compile)"
SubsystemVersion="$(SubsystemVersion)"
TargetType="$(OutputType)"
ToolExe="$(CscToolExe)"
ToolPath="$(CscToolPath)"
TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
UseHostCompilerIfAvailable="$(UseHostCompilerIfAvailable)"
Utf8Output="$(Utf8Output)"
VsSessionGuid="$(VsSessionGuid)"
WarningLevel="$(WarningLevel)"
WarningsAsErrors="$(WarningsAsErrors)"
WarningsNotAsErrors="$(WarningsNotAsErrors)"
Win32Icon="$(ApplicationIcon)"
Win32Manifest="$(Win32Manifest)"
Win32Resource="$(Win32Resource)"
/>
<ItemGroup>
<_CoreCompileResourceInputs Remove="@(_CoreCompileResourceInputs)" />
</ItemGroup>
<CallTarget Targets="$(TargetsTriggeredByCompilation)" Condition="'$(TargetsTriggeredByCompilation)' != ''"/>
</Target>
</Project>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target
Name="CoreCompile"
Inputs="$(MSBuildAllProjects);
@(Compile);
@(_CoreCompileResourceInputs);
$(ApplicationIcon);
$(AssemblyOriginatorKeyFile);
@(ReferencePath);
@(CompiledLicenseFile);
@(LinkResource);
@(EmbeddedDocumentation);
$(Win32Resource);
$(Win32Manifest);
@(CustomAdditionalCompileInputs);
$(ResolvedCodeAnalysisRuleSet)"
Outputs="@(DocFileItem);
@(IntermediateAssembly);
@(_DebugSymbolsIntermediatePath);
$(NonExistentFile);
@(CustomAdditionalCompileOutputs)"
Returns=""
DependsOnTargets="$(CoreCompileDependsOn)"
>
<PropertyGroup>
<_NoWarnings Condition=" '$(WarningLevel)' == '0' ">true</_NoWarnings>
<_NoWarnings Condition=" '$(WarningLevel)' == '1' ">false</_NoWarnings>
</PropertyGroup>
<PropertyGroup>
<!-- If we are building in visual studio setting the VbcToolPath will prevent the inproc compiler from being used during compile-->
<VbcToolPath Condition="'$(VbcToolPath)' == '' and '$(BuildingInsideVisualStudio)' != 'true'">$(MsBuildToolsPath)</VbcToolPath>
<!-- If we are targeting winmdobj we want to specifically the pdbFile property since we do not want it to collide with the output of winmdexp-->
<PdbFile Condition="'$(PdbFile)' == '' and '$(OutputType)' == 'winmdobj' and '$(DebugSymbols)' == 'true'">$(IntermediateOutputPath)$(TargetName).compile.pdb</PdbFile>
</PropertyGroup>
<ItemGroup Condition="'$(TargetingClr2Framework)'=='true'">
<ReferencePath>
<EmbedInteropTypes/>
</ReferencePath>
</ItemGroup>
<!-- Prefer32Bit was introduced in .NET 4.5. Set it to false if we are targeting 4.0 -->
<PropertyGroup Condition="('$(TargetFrameworkVersion)' == 'v4.0')">
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup Condition="('$(AdditionalFileItemNames)' != '')">
<AdditionalFileItems Include="$(AdditionalFileItemNames)" />
<AdditionalFiles Include="@(%(AdditionalFileItems.Identity))" />
</ItemGroup>
<!-- Condition is to filter out the _CoreCompileResourceInputs so that it doesn't pass in culture resources to the compiler -->
<Vbc Condition=" '%(_CoreCompileResourceInputs.WithCulture)' != 'true' "
AdditionalLibPaths="$(AdditionalLibPaths)"
AddModules="@(AddModules)"
AdditionalFiles="@(AdditionalFiles)"
Analyzers="@(Analyzer)"
BaseAddress="$(BaseAddress)"
CodeAnalysisRuleSet="$(ResolvedCodeAnalysisRuleSet)"
CodePage="$(CodePage)"
DebugType="$(DebugType)"
DefineConstants="$(FinalDefineConstants)"
DelaySign="$(DelaySign)"
DisabledWarnings="$(NoWarn)"
DocumentationFile="@(DocFileItem)"
EmitDebugInformation="$(DebugSymbols)"
EnvironmentVariables="$(VbcEnvironment)"
ErrorReport="$(ErrorReport)"
FileAlignment="$(FileAlignment)"
GenerateDocumentation="$(GenerateDocumentation)"
HighEntropyVA="$(HighEntropyVA)"
Imports="@(Import)"
KeyContainer="$(KeyContainerName)"
KeyFile="$(KeyOriginatorFile)"
LangVersion="$(LangVersion)"
LinkResources="@(LinkResource)"
MainEntryPoint="$(StartupObject)"
ModuleAssemblyName="$(ModuleAssemblyName)"
NoConfig="true"
NoStandardLib="$(NoCompilerStandardLib)"
NoVBRuntimeReference="$(NoVBRuntimeReference)"
NoWarnings="$(_NoWarnings)"
NoWin32Manifest="$(NoWin32Manifest)"
Optimize="$(Optimize)"
OptionCompare="$(OptionCompare)"
OptionExplicit="$(OptionExplicit)"
OptionInfer="$(OptionInfer)"
OptionStrict="$(OptionStrict)"
OptionStrictType="$(OptionStrictType)"
OutputAssembly="@(IntermediateAssembly)"
PdbFile="$(PdbFile)"
Platform="$(PlatformTarget)"
Prefer32Bit="$(Prefer32Bit)"
PreferredUILang="$(PreferredUILang)"
References="@(ReferencePath)"
RemoveIntegerChecks="$(RemoveIntegerChecks)"
Resources="@(_CoreCompileResourceInputs);@(CompiledLicenseFile)"
ResponseFiles="$(CompilerResponseFile)"
RootNamespace="$(RootNamespace)"
SdkPath="$(FrameworkPathOverride)"
Sources="@(Compile)"
SubsystemVersion="$(SubsystemVersion)"
TargetCompactFramework="$(TargetCompactFramework)"
TargetType="$(OutputType)"
ToolExe="$(VbcToolExe)"
ToolPath="$(VbcToolPath)"
TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
UseHostCompilerIfAvailable="$(UseHostCompilerIfAvailable)"
Utf8Output="$(Utf8Output)"
VBRuntimePath="$(VBRuntimePath)"
Verbosity="$(VbcVerbosity)"
VsSessionGuid="$(VsSessionGuid)"
WarningsAsErrors="$(WarningsAsErrors)"
WarningsNotAsErrors="$(WarningsNotAsErrors)"
Win32Icon="$(ApplicationIcon)"
Win32Manifest="$(Win32Manifest)"
Win32Resource="$(Win32Resource)"
VBRuntime="$(VBRuntime)"
/>
<ItemGroup>
<_CoreCompileResourceInputs Remove="@(_CoreCompileResourceInputs)" />
</ItemGroup>
<CallTarget Targets="$(TargetsTriggeredByCompilation)" Condition="'$(TargetsTriggeredByCompilation)' != ''"/>
</Target>
</Project>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册