summaryrefslogtreecommitdiff
path: root/Tools/IL.targets
blob: ed536452e0b394250f8465c1031235557261fa55 (plain)
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
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <!-- Required by Microsoft.Common.targets -->
  <Target Name="CreateManifestResourceNames" Condition="'@(EmbeddedResource)' != ''" />

  <!-- Default to ILAsm shipped with buildtools -->
  <PropertyGroup Condition="'$(IlasmToolPath)' == ''">
    <IlasmPath>$(MSBuildThisFileDirectory)\ilasm\</IlasmPath>
    <IlasmToolPath Condition="'$(RunningOnUnix)'!='true' And Exists('$(IlasmPath)ilasm.exe')">$(IlasmPath)ilasm.exe</IlasmToolPath>
    <IlasmToolPath Condition="'$(RunningOnUnix)'=='true' And Exists('$(IlasmPath)ilasm')">$(IlasmPath)ilasm</IlasmToolPath>
  </PropertyGroup>

  <!-- If buildtools wasn't restored with ILAsm, on Windows we can fallback to ILAsm from the framework -->
  <Target Name="GetIlasmPath"
          Condition="'$(RunningOnUnix)'!='true' And '$(IlasmToolPath)' == ''">
    <GetFrameworkPath>
      <Output TaskParameter="Path" PropertyName="IlasmPath" />
    </GetFrameworkPath>
    <PropertyGroup>
      <IlasmPath>$(IlasmPath)\</IlasmPath>
      <IlasmToolPath>$(IlasmPath)ilasm</IlasmToolPath>
    </PropertyGroup>
  </Target>

  <Target Name="CoreCompile"
          Inputs="$(MSBuildAllProjects);
                  @(Compile)"
          Outputs="@(IntermediateAssembly);"
          Returns=""
          DependsOnTargets="GetIlasmPath;$(CoreCompileDependsOn)">
    <Error Condition="'$(IlasmToolPath)' == ''" Text="IlasmToolPath must be set in order to build ilproj's outside of Windows." />
    <PropertyGroup>
      <_OutputTypeArgument Condition="'$(OutputType)' == 'Library'">-DLL</_OutputTypeArgument>
      <_OutputTypeArgument Condition="'$(OutputType)' == 'Exe'">-EXE</_OutputTypeArgument>

      <_KeyFileArgument Condition="'$(KeyOriginatorFile)' != ''">-KEY=$(KeyOriginatorFile)</_KeyFileArgument>

      <_IlasmSwitches>-QUIET -NOLOGO</_IlasmSwitches> 
      <_IlasmSwitches Condition="'$(FoldIdenticalMethods)' == 'True'">$(_IlasmSwitches) -FOLD</_IlasmSwitches>
      <_IlasmSwitches Condition="'$(SizeOfStackReserve)' != ''">$(_IlasmSwitches) -STACK=$(SizeOfStackReserve)</_IlasmSwitches>
      <_IlasmSwitches Condition="'$(DebugType)' == 'Full'">$(_IlasmSwitches) -DEBUG</_IlasmSwitches>
      <_IlasmSwitches Condition="'$(DebugType)' == 'Impl'">$(_IlasmSwitches) -DEBUG=IMPL</_IlasmSwitches>
      <_IlasmSwitches Condition="'$(DebugType)' == 'PdbOnly'">$(_IlasmSwitches) -DEBUG=OPT</_IlasmSwitches>
      <_IlasmSwitches Condition="'$(Optimize)' == 'True'">$(_IlasmSwitches) -OPTIMIZE</_IlasmSwitches>
    </PropertyGroup>

    <Exec Command="$(IlasmToolPath) $(_IlasmSwitches) $(_OutputTypeArgument) $(IlasmFlags) -OUTPUT=@(IntermediateAssembly) $(_KeyFileArgument) @(Compile, ' ')">
      <Output TaskParameter="ExitCode" PropertyName="_ILAsmExitCode" />
    </Exec>
    <Error Text="ILAsm failed" Condition="'$(_ILAsmExitCode)' != '0'" />

    <CallTarget Targets="$(TargetsTriggeredByCompilation)" Condition="'$(TargetsTriggeredByCompilation)' != ''"/>
  </Target>

  <Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />

</Project>