summaryrefslogtreecommitdiff
path: root/clr.targets
blob: 5572178c4e9244bfa33710f3b6aacbfc1bc73a7c (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
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
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <!-- Differences in the native vs managed devdiv targets mean that we want to output to
         IntermediateOutputDirectory under native, since we can set BinplaceRoot and have
         BinPlace do all the final copying of binaries and pdbs.  We output to BinariesDirectory
         under managed, since BinplaceRoot doesn't exist in Microsoft.DevDiv.targets
    -->
    <PropertyGroup>
      <OutputPath Condition="'$(ProjectLanguage)' != 'Native'">$(BinariesDirectory)\</OutputPath>
      <OutputPath Condition="'$(LinkResourceOnlyDll)' == 'true' and '$(ResourceOnlyDllWithSymbols)' != 'true'">$(BinariesDirectory)\</OutputPath>
    </PropertyGroup>
    
    <!-- Import the file that based on feature flags generates the defines -->
    <Import Project="$(MSBuildThisFileDirectory)clr.defines.targets" />

    <!--
        Assembly Signing
        
        NTBuild uses a central file list to determine which assemblies get binplaced and signed.
        Reuse this for our build so we correctly sign only that which needs signing and don't
        blindly sign everything.
    -->
    <PropertyGroup>
      <SignFile Condition="$(SignFile)==''">$(IntermediateOutputDirectory)\sign.txt</SignFile>
    </PropertyGroup>
    
    <Target Name="GenerateSignFile"
      Condition="'$(ProjectLanguage)' != 'Native'"
      Inputs="@(FileList)"
      Outputs="$(SignFile)"
      BeforeTargets="CheckIfAssemblyNeedsSigning">
      <Exec Command="$(DevDivToolsPath)\gensignfile.bat $(SignFile) @(FileList) $(BuildProjectName)" 
            StandardOutputImportance="Normal"/>
    </Target>
       
    <PropertyGroup>
      <CheckIfAssemblyNeedsSigningDependsOn Condition="'$(ProjectLanguage)' == 'Native'">GenerateAssemblyAttributes</CheckIfAssemblyNeedsSigningDependsOn>
      <CheckIfAssemblyNeedsSigningDependsOn Condition="'$(ProjectLanguage)' != 'Native'">Preprocess</CheckIfAssemblyNeedsSigningDependsOn>
    </PropertyGroup>
    <Target Name="CheckIfAssemblyNeedsSigning"
            Condition="'$(ProjectLanguage)' != 'Native' and '$(AlwaysSign)' != 'true'"
            AfterTargets="GenerateSignFile"
            BeforeTargets="$(CheckIfAssemblyNeedsSigningDependsOn)">
      <Exec Command="findstr /i /x /c:&quot;$(TargetFileName)&quot; $(SignFile) >nul 2>&amp;1" IgnoreExitCode="true">
        <Output TaskParameter="ExitCode" PropertyName="ExitCode" />
      </Exec>
      
      <PropertyGroup>
        <SignAssemblyAttribute Condition="'$(ExitCode)' == '0'">true</SignAssemblyAttribute>
        <SignAssemblyAttribute Condition="'$(ExitCode)' != '0'">false</SignAssemblyAttribute>
      </PropertyGroup>
      
      <ItemGroup>
        <Internal_ClDefines Condition="'$(ExitCode)' != '0'" Remove="SIGN_ASSEMBLY=1" />
      </ItemGroup>
      <Message Text="CheckIfAssemblyNeedsSigning  assembly: $(TargetFileName)  Exitcode: $(ExitCode)  SignAssemblyAttribute: $(SignAssemblyAttribute)" />
    </Target>

    <!-- Overriding a Target that's defined in Microsoft.DevDiv.Common.targets since it uses the wrong defines and includes for RC in CSC projects  -->
    <Target Name="GenerateUnmanagedResources"
        Condition="'@(RCResourceFile)' != '' and '$(CallRcFromCscProject)'=='true'"
        DependsOnTargets="$(GenerateUnmanagedResourcesDependsOn)">
        
        <PropertyGroup>
            <Internal_GURIncludes>$(ClrBase)\src\inc</Internal_GURIncludes>
            <Internal_GURIncludes>$(Internal_GURIncludes);$(VCPublicIncPath)</Internal_GURIncludes> 
            <Internal_GURIncludes>$(Internal_GURIncludes);$(EnlistmentRootPath)\ndp\inc\version</Internal_GURIncludes>
            <Internal_GURIncludes>$(Internal_GURIncludes);$(EnlistmentRootPath)\InternalAPIs\NDP_Common\Inc</Internal_GURIncludes>
            <Internal_GURIncludes>$(Internal_GURIncludes);$(SdkIncPath)</Internal_GURIncludes>
        </PropertyGroup>
          
        <RC 
            AdditionalIncludeDirectories="$(Internal_GURIncludes)"
            Culture="409"
            TrackerLogDirectory="$(IntermediateOutputDirectory)"
            MinimalRebuildFromTracking="$(Internal_MinimalRebuildFromTracking)"
            PreprocessorDefinitions="$(CDefines)"
            ResourceOutputFileName="@(RCResourceFile->'$(IntermediateOutputPath)%(Filename).res')"
            Source="%(RCResourceFile.Identity)"
            ToolPath="$(RCToolPath)"
            TrackFileAccess="$(TrackFileAccess)"
            SuppressStartupBanner="$(RCSupressStartupBanner)"
            />
        <PropertyGroup>
            <Win32Resource>@(RCResourceFile->'$(IntermediateOutputPath)%(Filename).res')</Win32Resource>
        </PropertyGroup>
    </Target>    


    <Import Project="clr.native.targets" Condition="'$(ProjectLanguage)' == 'Native'" />
    <Import Project="$(_NTDRIVE)$(_NTROOT)\InternalAPIs\NDP_Common\inc\Microsoft.Ndp.targets" />
    <Import Project="clr.prefast.targets" Condition="'$(DoPrefastBuild)' == 'true'" />

</Project>